2021年5月1日 星期六

HBLbits_Verilog Basic_Fsm3

HBLbits_Verilog Basic_Fsm3 

The following is the state transition table for a Moore state machine with one input, one output, and four states. Implement this state machine. Include an asynchronous reset that resets the FSM to state A.

StateNext stateOutput
in=0in=1
AAB0
BCB0
CAD0
DCB1


module top_module(

    input clk,
    input in,
    input areset,
    output out); //
parameter A=2'b00, B=2'b01, C=2'b10, D=2'b11;
    reg[1:0] state,next_state;
    // State transition logic
    always@(state or in)
        begin
            case(state)
                A: next_state = (in)? B:A;
                B: next_state = (in)? B:C;
                C: next_state = (in)? D:A;
                D: next_state = (in)? B:C;
                default:;
            endcase
        end
    // State flip-flops with synchronous reset
    always@(posedge clk or posedge areset)
        begin
            if(areset)
                state = A;
            else
                state = next_state;
        end
    // Output logic
    assign out = (state==D)? 1'b1:1'b0;
endmodule


沒有留言:

張貼留言

Telegram +ESP32自動發報機

  Telegram   +ESP32自動發報機 這套系統是一個典型的 IoT(物聯網)架構 ,結合了遠端配置(Python)、通訊中介(MQTT)與硬體執行(ESP32)。 以下我為您拆解這兩支程式的核心運作原理: 一、 系統架構流程 Python 端 (控制台) :使用者輸入...