2021年5月1日 星期六

HBLbits_Verilog Basic_Fsm3s

 HBLbits_Verilog Basic_Fsm3s

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 a synchronous reset that resets the FSM to state A. (This is the same problem as Fsm3 but with a synchronous reset.)

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

module top_module(
    input clk,
    input in,
    input reset,
    output out); //
    parameter A=2'b00,B=2'b01,C=2'b10,D=2'b11;
    reg[1:0] present_state, next_state;

    always @(posedge clk) begin
        if (reset) begin  
            //  State flip-flops with synchronous reset
            present_state = A;
        end else begin
            case (present_state)
                //  State transition logic
                A: begin if(in) next_state = B; else next_state = A;end
                B: begin if(in) next_state = B; else next_state = C;end 
                C: begin if(in) next_state = D; else next_state = A;end
                D: begin if(in) next_state = B; else next_state = C;end 
                default:;                
            endcase
            // State flip-flops
            present_state = next_state;
        end
        case (present_state)
                // Output logic
    // Fill in state name declarations
                A: out <= 1'b0;
                B: out <= 1'b0;
                C: out <= 1'b0;
                D: out <= 1'b1;
                default:;
        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...