data/full_repos/permissive/194450802/keyboard.v
1: b'%Warning-WIDTH: data/full_repos/permissive/194450802/keyboard.v:33: Operator ASSIGN expects 6 bits on the Assign RHS, but Assign RHS\'s VARREF \'ZERO\' generates 5 bits.\n                                                                  : ... In instance keyboard\n    reg [5:0] counter = ZERO;\n                        ^~~~\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/194450802/keyboard.v:39: Bit extraction of var[10:0] requires 4 bit index, not 6 bits.\n                                                                  : ... In instance keyboard\n        make_code[counter] = kb_data;\n                 ^\n%Warning-WIDTH: data/full_repos/permissive/194450802/keyboard.v:55: Operator ASSIGN expects 6 bits on the Assign RHS, but Assign RHS\'s VARREF \'ZERO\' generates 5 bits.\n                                                                  : ... In instance keyboard\n                counter = ZERO;\n                        ^\n%Warning-WIDTH: data/full_repos/permissive/194450802/keyboard.v:41: Operator EQ expects 6 bits on the RHS, but RHS\'s VARREF \'KEY_BITS\' generates 5 bits.\n                                                                  : ... In instance keyboard\n        if (counter == KEY_BITS)\n                    ^~\n%Error: Exiting due to 4 warning(s)\n'
module keyboard(mapped_key, kb_clock, kb_data, LEDR);
    input kb_clock, kb_data;
    output [7:0] mapped_key;
	output [8:0] LEDR;


    reg [10:0] make_code;
    reg [8:0] scan_code;
    reg [7:0] prev_scan_code;
    

	localparam ZERO = 5'd0, KEY_BITS = 5'd11; 
    reg [5:0] counter = ZERO;
    
    localparam ESCAPE = 8'hE0;

    always@(negedge kb_clock)
    begin: input_detection
        make_code[counter] = kb_data;
        counter = counter + 1'd1;
        if (counter == KEY_BITS)
            begin
                if (prev_scan_code == ESCAPE)
						begin
                    scan_code <= {1'b1, make_code[8:1]};
						  prev_scan_code <= make_code[8:1];
						end
                else if (prev_scan_code != ESCAPE && make_code[8:1] != ESCAPE)
						begin
                    scan_code <= {1'b0, make_code[8:1]};
						  prev_scan_code <= make_code[8:1];
						end
                else
                    prev_scan_code <= make_code[8:1];
                counter = ZERO;
            end
    end
	 
	 assign LEDR[8:0] = scan_code;











    localparam KEY_UP = {1'b1, 8'h75},
            KEY_DOWN = {1'b1, 8'h72},
            KEY_LEFT = {1'b1, 8'h6B},
            KEY_RIGHT = {1'b1, 8'h74},


            KEY_S = {1'b0, 8'h1B};


    localparam OUT_UP = 8'b00001,
            OUT_DOWN = 8'b00010,
            OUT_LEFT = 8'b00100,
            OUT_RIGHT = 8'b01000,
            OUT_SHOOT = 8'b10000,
            OUT_NONE = 8'h0;

	reg [7:0] mapped_key;
    always@(*)
    begin
		  mapped_key = OUT_NONE;
        case(scan_code)
            KEY_UP: mapped_key = OUT_UP;
            KEY_DOWN: mapped_key = OUT_DOWN;
            KEY_LEFT: mapped_key = OUT_LEFT;
            KEY_RIGHT: mapped_key = OUT_RIGHT;
            KEY_S: mapped_key = OUT_SHOOT;
            default: mapped_key = mapped_key;
        endcase
    end
endmodule
module keyboard(mapped_key, kb_clock, kb_data, LEDR);

    input kb_clock, kb_data;
    output [7:0] mapped_key;
	output [8:0] LEDR;


    reg [10:0] make_code;
    reg [8:0] scan_code;
    reg [7:0] prev_scan_code;
    

	localparam ZERO = 5'd0, KEY_BITS = 5'd11; 
    reg [5:0] counter = ZERO;
    
    localparam ESCAPE = 8'hE0;

    always@(negedge kb_clock)
    begin: input_detection
        make_code[counter] = kb_data;
        counter = counter + 1'd1;
        if (counter == KEY_BITS)
            begin
                if (prev_scan_code == ESCAPE)
						begin
                    scan_code <= {1'b1, make_code[8:1]};
						  prev_scan_code <= make_code[8:1];
						end
                else if (prev_scan_code != ESCAPE && make_code[8:1] != ESCAPE)
						begin
                    scan_code <= {1'b0, make_code[8:1]};
						  prev_scan_code <= make_code[8:1];
						end
                else
                    prev_scan_code <= make_code[8:1];
                counter = ZERO;
            end
    end
	 
	 assign LEDR[8:0] = scan_code;











    localparam KEY_UP = {1'b1, 8'h75},
            KEY_DOWN = {1'b1, 8'h72},
            KEY_LEFT = {1'b1, 8'h6B},
            KEY_RIGHT = {1'b1, 8'h74},


            KEY_S = {1'b0, 8'h1B};


    localparam OUT_UP = 8'b00001,
            OUT_DOWN = 8'b00010,
            OUT_LEFT = 8'b00100,
            OUT_RIGHT = 8'b01000,
            OUT_SHOOT = 8'b10000,
            OUT_NONE = 8'h0;

	reg [7:0] mapped_key;
    always@(*)
    begin
		  mapped_key = OUT_NONE;
        case(scan_code)
            KEY_UP: mapped_key = OUT_UP;
            KEY_DOWN: mapped_key = OUT_DOWN;
            KEY_LEFT: mapped_key = OUT_LEFT;
            KEY_RIGHT: mapped_key = OUT_RIGHT;
            KEY_S: mapped_key = OUT_SHOOT;
            default: mapped_key = mapped_key;
        endcase
    end
endmodule