data/full_repos/permissive/194781874/keyboard_freq.v
 line:7: before: "="
1: b'%Warning-WIDTH: data/full_repos/permissive/194781874/keyboard_freq.v:7: Operator ASSIGN expects 20 bits on the Assign RHS, but Assign RHS\'s CONST \'16\'h0\' generates 16 bits.\n                                                                      : ... In instance keyboard_freq\n    output reg [19:0] NUM = 16\'b0,\n                            ^~~~~\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/194781874/keyboard_freq.v:41: Operator ADD expects 20 bits on the RHS, but RHS\'s CONST \'4\'h1\' generates 4 bits.\n                                                                       : ... In instance keyboard_freq\n                    NUM = NUM + 4\'b0001;\n                              ^\n%Warning-WIDTH: data/full_repos/permissive/194781874/keyboard_freq.v:45: Operator ADD expects 20 bits on the RHS, but RHS\'s CONST \'4\'h2\' generates 4 bits.\n                                                                       : ... In instance keyboard_freq\n                    NUM = NUM + 4\'b0010;\n                              ^\n%Warning-WIDTH: data/full_repos/permissive/194781874/keyboard_freq.v:49: Operator ADD expects 20 bits on the RHS, but RHS\'s CONST \'4\'h3\' generates 4 bits.\n                                                                       : ... In instance keyboard_freq\n                    NUM = NUM + 4\'b0011;\n                              ^\n%Warning-WIDTH: data/full_repos/permissive/194781874/keyboard_freq.v:53: Operator ADD expects 20 bits on the RHS, but RHS\'s CONST \'4\'h4\' generates 4 bits.\n                                                                       : ... In instance keyboard_freq\n                    NUM = NUM + 4\'b0100;\n                              ^\n%Warning-WIDTH: data/full_repos/permissive/194781874/keyboard_freq.v:57: Operator ADD expects 20 bits on the RHS, but RHS\'s CONST \'4\'h5\' generates 4 bits.\n                                                                       : ... In instance keyboard_freq\n                    NUM = NUM + 4\'b0101;\n                              ^\n%Warning-WIDTH: data/full_repos/permissive/194781874/keyboard_freq.v:61: Operator ADD expects 20 bits on the RHS, but RHS\'s CONST \'4\'h6\' generates 4 bits.\n                                                                       : ... In instance keyboard_freq\n                    NUM = NUM + 4\'b0110;\n                              ^\n%Warning-WIDTH: data/full_repos/permissive/194781874/keyboard_freq.v:65: Operator ADD expects 20 bits on the RHS, but RHS\'s CONST \'4\'h7\' generates 4 bits.\n                                                                       : ... In instance keyboard_freq\n                    NUM = NUM + 4\'b0111;\n                              ^\n%Warning-WIDTH: data/full_repos/permissive/194781874/keyboard_freq.v:69: Operator ADD expects 20 bits on the RHS, but RHS\'s CONST \'4\'h8\' generates 4 bits.\n                                                                       : ... In instance keyboard_freq\n                    NUM = NUM + 4\'b1000;\n                              ^\n%Warning-WIDTH: data/full_repos/permissive/194781874/keyboard_freq.v:73: Operator ADD expects 20 bits on the RHS, but RHS\'s CONST \'4\'h9\' generates 4 bits.\n                                                                       : ... In instance keyboard_freq\n                    NUM = NUM + 4\'b1001;\n                              ^\n%Warning-WIDTH: data/full_repos/permissive/194781874/keyboard_freq.v:77: Operator ADD expects 20 bits on the RHS, but RHS\'s CONST \'4\'h0\' generates 4 bits.\n                                                                       : ... In instance keyboard_freq\n                    NUM = NUM + 4\'b0000;\n                              ^\n%Error: Exiting due to 11 warning(s)\n'
module keyboard_freq(
    input PS2Clk,
    input PS2Data,
    input ENABLE, 
    output reg [19:0] NUM = 16'b0,
    output reg KB_FLAG = 1'b0
    );
    
    reg [1:0] COUNT = 2'b00;
    reg [7:0] KB_CURR = 8'hf0;
    reg [7:0] KB_PREV = 8'hf0;
    reg [3:0] KB_COUNT = 4'h1;

    always @ (negedge PS2Clk) begin
        if (ENABLE == 1) begin
            case (KB_COUNT)
                1:;
                2: KB_CURR[0] <= PS2Data;
                3: KB_CURR[1] <= PS2Data;
                4: KB_CURR[2] <= PS2Data;
                5: KB_CURR[3] <= PS2Data;
                6: KB_CURR[4] <= PS2Data;
                7: KB_CURR[5] <= PS2Data;
                8: KB_CURR[6] <= PS2Data;
                9: KB_CURR[7] <= PS2Data;
                10: KB_FLAG <= 1'b1;
                11: KB_FLAG <= 1'b0;
            endcase
            if (KB_COUNT <= 10) KB_COUNT <= KB_COUNT + 1;
            else if (KB_COUNT == 11) KB_COUNT <= 1;
        end
    end
    
    always @ (posedge KB_FLAG) begin
        if (KB_CURR == 8'hf0) begin
            case (KB_PREV)
                8'h16: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0001;
                end
                8'h1E: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0010;
                end
                8'h26: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0011;
                end
                8'h25: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0100;
                end
                8'h2E: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0101;
                end
                8'h36: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0110;
                end
                8'h3D: begin 
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0111;
                end
                8'h3E: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b1000;
                end
                8'h46: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b1001;
                end
                8'h45: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0000;
                end
                default: NUM = NUM;
            endcase
        end
        else KB_PREV <= KB_CURR;
    end
    
endmodule
module keyboard_freq(
    input PS2Clk,
    input PS2Data,
    input ENABLE, 
    output reg [19:0] NUM = 16'b0,
    output reg KB_FLAG = 1'b0
    );

    
    reg [1:0] COUNT = 2'b00;
    reg [7:0] KB_CURR = 8'hf0;
    reg [7:0] KB_PREV = 8'hf0;
    reg [3:0] KB_COUNT = 4'h1;

    always @ (negedge PS2Clk) begin
        if (ENABLE == 1) begin
            case (KB_COUNT)
                1:;
                2: KB_CURR[0] <= PS2Data;
                3: KB_CURR[1] <= PS2Data;
                4: KB_CURR[2] <= PS2Data;
                5: KB_CURR[3] <= PS2Data;
                6: KB_CURR[4] <= PS2Data;
                7: KB_CURR[5] <= PS2Data;
                8: KB_CURR[6] <= PS2Data;
                9: KB_CURR[7] <= PS2Data;
                10: KB_FLAG <= 1'b1;
                11: KB_FLAG <= 1'b0;
            endcase
            if (KB_COUNT <= 10) KB_COUNT <= KB_COUNT + 1;
            else if (KB_COUNT == 11) KB_COUNT <= 1;
        end
    end
    
    always @ (posedge KB_FLAG) begin
        if (KB_CURR == 8'hf0) begin
            case (KB_PREV)
                8'h16: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0001;
                end
                8'h1E: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0010;
                end
                8'h26: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0011;
                end
                8'h25: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0100;
                end
                8'h2E: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0101;
                end
                8'h36: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0110;
                end
                8'h3D: begin 
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0111;
                end
                8'h3E: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b1000;
                end
                8'h46: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b1001;
                end
                8'h45: begin
                    NUM = NUM << 4;
                    NUM = NUM + 4'b0000;
                end
                default: NUM = NUM;
            endcase
        end
        else KB_PREV <= KB_CURR;
    end
    
endmodule