Count15

2023. 6. 20. 10:51FPGA/HDLBits

728x90

Problem Statement

Build a 4-bit binary counter that counts from 0 through 15, inclusive, with a period of 16. The reset input is synchronous, and should reset the counter to 0.

module top_module (
    input clk,
    input reset,      // Synchronous active-high reset
    output [3:0] q);
    
    always @(posedge clk) begin
        if(reset)
            q = 0;
        else if(q == 4'hf)
            q = 0;
        else
            q = q + 1;
    end
endmodule

 

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

Count1to10  (0) 2023.06.20
Count10  (0) 2023.06.20
Tb/tff  (0) 2023.06.20
Tb/tb2  (0) 2023.06.20
Tb/and  (0) 2023.06.20