Always nolatches

2023. 6. 24. 21:50FPGA/HDLBits

728x90

Your circuit has one 16-bit input, and four outputs. Build this circuit that recognizes these four scancodes and asserts the correct output.

 

[Scancode [15:0]Arrow key]

16'he06b left arrow
16'he072 down arrow
16'he074 right arrow
16'he075 up arrow
Anything else none

 

// synthesis verilog_input_version verilog_2001
module top_module (
    input [15:0] scancode,
    output reg left,
    output reg down,
    output reg right,
    output reg up  ); 

    always @(*) begin
            left = 1'b0;
            down = 1'b0;
            right = 1'b0;
            up = 1'b0;
        case(scancode)
            16'he06b : left = 1'b1;
            16'he072 : down = 1'b1;
            16'he074 : right = 1'b1;
            16'he075 : up = 1'b1;
        endcase
    end
endmodule

'FPGA > HDLBits' 카테고리의 다른 글

Reduction  (0) 2023.06.24
Conditional  (0) 2023.06.24
Always casez  (0) 2023.06.24
Always case2  (0) 2023.06.24
Sim/circuit9  (0) 2023.06.20