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

沒有留言:

張貼留言

Messaging API作為替代方案

  LINE超好用功能要沒了!LINE Notify明年3月底終止服務,有什麼替代方案? LINE Notify將於2025年3月31日結束服務,官方建議改用Messaging API作為替代方案。 //CHANNEL_ACCESS_TOKEN = 'Messaging ...