2021年6月26日 星期六

HDLBits FSM / Fsm3comb

 HDLBits FSM / Fsm3comb

The following is the state transition table for a Moore state machine with one input, one output, and four states. Use the following state encoding: A=2'b00, B=2'b01, C=2'b10, D=2'b11.

Implement only the state transition logic and output logic (the combinational logic portion) for this state machine. Given the current state (state), compute the next_state and output (out) based on the state transition table.

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

module top_module(
    input in,
    input [1:0] state,
    output [1:0] next_state,
    output out); //


    parameter A=0, B=1, C=2, D=3;


    always @(*) begin    // This is a combinational always block
        // State transition logic

        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;
        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

沒有留言:

張貼留言

2024_09 作業3 以Node-Red 為主

 2024_09 作業3  (以Node-Red 為主  Arduino 可能需要配合修改 ) Arduino 可能需要修改的部分 1)mqtt broker  2) 主題Topic (發行 接收) 3) WIFI ssid , password const char br...