본문 바로가기

Verilog/HDLbits

[HDLBits] Count15

1. 문제 및 설명

  • 0부터 15까지 카운트하는 주기 16의 4비트 이진 카운터를 구현하시오
    • reset입력은 동기식이며, 카운터를 0으로 초기화해야 한다.

 

 

2. 모듈 정의

module top_module (
    input clk,
    input reset,      // Synchronous active-high reset
    output [3:0] q);

 

 

 

3. 답

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

endmodule

'Verilog > HDLbits' 카테고리의 다른 글

[HDLBits] Count1to10  (0) 2026.01.05
[HDLBits] Count10  (0) 2026.01.05
[HDLBits] Dualedge  (0) 2026.01.03
[HDLBits] Edgecapture  (0) 2026.01.03
[HDLBits] Edgedetect2  (0) 2026.01.01