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產專班 作業2 (純模擬)

2024產專班 作業2  (純模擬) 1) LED ON,OFF,TIMER,FLASH 模擬 (switch 控制) 2)RFID卡號模擬 (buttom  模擬RFID UID(不從ESP32) Node-Red 程式 [{"id":"d8886...