data/full_repos/permissive/422447942/Codebase/main.v
1: b'%Warning-LITENDIAN: data/full_repos/permissive/422447942/Codebase/main.v:19: Little bit endian vector: MSB < LSB of bit range: 0:47\n reg [0:47] currentPassword;  \n     ^\n                    ... Use "/* verilator lint_off LITENDIAN */" and lint_on around source to disable this message.\n%Error: data/full_repos/permissive/422447942/Codebase/main.v:42: Cannot find file containing module: \'keyboard\'\n keyboard ke(PS2_Clock, PS2_Data, fromKeyboard);  \n ^~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/422447942/Codebase,data/full_repos/permissive/422447942/keyboard\n             data/full_repos/permissive/422447942/Codebase,data/full_repos/permissive/422447942/keyboard.v\n             data/full_repos/permissive/422447942/Codebase,data/full_repos/permissive/422447942/keyboard.sv\n             keyboard\n             keyboard.v\n             keyboard.sv\n             obj_dir/keyboard\n             obj_dir/keyboard.v\n             obj_dir/keyboard.sv\n%Error: data/full_repos/permissive/422447942/Codebase/main.v:43: Cannot find file containing module: \'displaymodule\'\n displaymodule display(toDisplay, sevenSeg0, sevenSeg1, sevenSeg2, sevenSeg3, sevenSeg4, sevenSeg5);  \n ^~~~~~~~~~~~~\n%Error: Exiting due to 2 error(s), 1 warning(s)\n'
module main(
	input tryPassword, addPassword,
	input PS2_Data, PS2_Clock, addLetter,
	
	output [6:0] sevenSeg0, sevenSeg1, sevenSeg2, sevenSeg3, sevenSeg4, sevenSeg5, 
	output reg isValidPassword, 
	output reg [2:0] lockout
	);
	

	parameter NUM_PASSWORDS = 2;
	

	integer currPasswordIndex;
	integer k;
	integer numPasswordAttempts;
	
	reg [47:0] passwords [0:NUM_PASSWORDS - 1];
	reg [0:47] currentPassword;
	
	wire [7:0] fromKeyboard;
	
	reg [47:0] toDisplay;
	

	initial begin

		currPasswordIndex = 0;
		isValidPassword = 0;
		lockout = 0;
		numPasswordAttempts = 0;
		
		currentPassword = {6{8'b01000101}};
		toDisplay = {6{8'b01000101}};
		
		for (k = 0; k < NUM_PASSWORDS; k = k + 1) begin
			passwords[k] = {6{8'b01000101}};
		end
	end
	

	keyboard ke(PS2_Clock, PS2_Data, fromKeyboard);
	displaymodule display(toDisplay, sevenSeg0, sevenSeg1, sevenSeg2, sevenSeg3, sevenSeg4, sevenSeg5);
		

	always @(negedge addLetter) begin

		currentPassword = currentPassword >> 8;
		currentPassword[0:7] = fromKeyboard;
		toDisplay = currentPassword;
	end


	always @(negedge addPassword) begin

		passwords[currPasswordIndex] = currentPassword;
		currPasswordIndex = (currPasswordIndex + 1) % NUM_PASSWORDS;
	end


	always @(negedge tryPassword) begin

		isValidPassword = 0;
		
		if (numPasswordAttempts < 3) begin
			for (k = 0; k < NUM_PASSWORDS; k = k + 1) begin
				if (passwords[k] == currentPassword) begin
					isValidPassword = 1;
					numPasswordAttempts = 0;
				end
			end
		end
		
		if (!isValidPassword) begin
				numPasswordAttempts = numPasswordAttempts + 1;
		end
		
	end

	always @(numPasswordAttempts) begin

		if (numPasswordAttempts == 0) begin
			lockout = 3'b111;
		end
		else if (numPasswordAttempts == 1) begin
			lockout = 3'b110;
		end
		else if (numPasswordAttempts == 2) begin
			lockout = 3'b100;
		end
		else begin
			lockout = 3'b000;
		end
		
	end
	
endmodule
module main(
	input tryPassword, addPassword,
	input PS2_Data, PS2_Clock, addLetter,
	
	output [6:0] sevenSeg0, sevenSeg1, sevenSeg2, sevenSeg3, sevenSeg4, sevenSeg5, 
	output reg isValidPassword, 
	output reg [2:0] lockout
	);

	

	parameter NUM_PASSWORDS = 2;
	

	integer currPasswordIndex;
	integer k;
	integer numPasswordAttempts;
	
	reg [47:0] passwords [0:NUM_PASSWORDS - 1];
	reg [0:47] currentPassword;
	
	wire [7:0] fromKeyboard;
	
	reg [47:0] toDisplay;
	

	initial begin

		currPasswordIndex = 0;
		isValidPassword = 0;
		lockout = 0;
		numPasswordAttempts = 0;
		
		currentPassword = {6{8'b01000101}};
		toDisplay = {6{8'b01000101}};
		
		for (k = 0; k < NUM_PASSWORDS; k = k + 1) begin
			passwords[k] = {6{8'b01000101}};
		end
	end
	

	keyboard ke(PS2_Clock, PS2_Data, fromKeyboard);
	displaymodule display(toDisplay, sevenSeg0, sevenSeg1, sevenSeg2, sevenSeg3, sevenSeg4, sevenSeg5);
		

	always @(negedge addLetter) begin

		currentPassword = currentPassword >> 8;
		currentPassword[0:7] = fromKeyboard;
		toDisplay = currentPassword;
	end


	always @(negedge addPassword) begin

		passwords[currPasswordIndex] = currentPassword;
		currPasswordIndex = (currPasswordIndex + 1) % NUM_PASSWORDS;
	end


	always @(negedge tryPassword) begin

		isValidPassword = 0;
		
		if (numPasswordAttempts < 3) begin
			for (k = 0; k < NUM_PASSWORDS; k = k + 1) begin
				if (passwords[k] == currentPassword) begin
					isValidPassword = 1;
					numPasswordAttempts = 0;
				end
			end
		end
		
		if (!isValidPassword) begin
				numPasswordAttempts = numPasswordAttempts + 1;
		end
		
	end

	always @(numPasswordAttempts) begin

		if (numPasswordAttempts == 0) begin
			lockout = 3'b111;
		end
		else if (numPasswordAttempts == 1) begin
			lockout = 3'b110;
		end
		else if (numPasswordAttempts == 2) begin
			lockout = 3'b100;
		end
		else begin
			lockout = 3'b000;
		end
		
	end
	
endmodule