2021年6月26日 星期六

HDLBiots FSM/Fsm3

HDLBiots FSM/Fsm3

See also: State transition logic for this FSM

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'd0,B=2'd1,C=2'd2,D=2'd3; 
    reg [1:0] state; // Make sure state and next are big enough to hold the state encodings.
    reg [1:0] next;
    
    // This is a sequential always block
    always @(posedge clk, posedge areset) begin
if (areset) state <= A;
        else state <= next;
end

 // State transition logic

    always@(*) begin
case (state)
A: next = in ? B : A;
B: next = in ? B : C;
C: next = in ? D : A;
D: next = in ? B : C;
endcase
    end


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

    always@(*) begin
   case (state)
A: out = 1'b0;
B: out = 1'b0;
C: out = 1'b0;
D: out = 1'b1;
       endcase
    end  
endmodule


 

沒有留言:

張貼留言

WOKWI ESP32 LED Control , Node-Red MQTT SQLITE  

WOKWI ESP32 LED Control ,  Node-Red  MQTT SQLITE   const char broker[] = "test.mosquitto.org" ; //const char broker[] = "br...