본문 바로가기

Verilog/HDLbits

[HDLBits] Fsm1

1. 문제 및 설명

  • 두 가지 상태를 가지는 아래 FSM을 설계하시오
    • 비동기식 리셋을 가진다.
    • reset 상태는 B이다.

2. 모듈 정의

module top_module(
    input clk,
    input areset,    // Asynchronous reset to state B
    input in,
    output out);

 

 

3. 답

module top_module(
    input clk,
    input areset,    // Asynchronous reset to state B
    input in,
    output out);//  

    parameter A=0, B=1; 
    reg state, next_state;

    always @(*) begin    // This is a combinational always block
        // State transition logic
        next_state = in?state:(!state);
        out = state;
    end

    always @(posedge clk, posedge areset) begin    // This is a sequential always block
        // State flip-flops with asynchronous reset
        if(areset)
            state <= B;
        else
            state <= next_state;
    end

    // Output logic
    // assign out = (state == ...);

endmodule
 

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

[HDLBits] Fsm2  (0) 2026.02.01
[HDLBits] Fsm1s  (0) 2026.02.01
[HDLBits] Rule110  (0) 2026.01.25
[HDLBits] Rule90  (0) 2026.01.25
[HDLBits] Exams/ece241 2013 q12  (0) 2026.01.25