目录
- 理论解读
- 写几段式状态机?
- 设计实战
- 两种state的FSM(异步复位)
理论解读
写几段式状态机?
设计实战
两种state的FSM(异步复位)
实现下图所示的摩尔状态机,复位为异步复位。
代码实现:
module top_module(input clk,input areset, // Asynchronous reset to state Binput in,output out);// parameter A=0, B=1; reg state, next;// State transition logicalways@(*)begin // This is a combinational always blockcase(state)A: next = in ? A : B;B: next = in ? B : A;endcaseend// State flip-flops with asynchronous resetalways @(posedge clk or posedge areset) begin // This is a sequential always blockif(areset == 1'b1)beginstate <= B;end else beginstate <= next;endend// Output logicassign out = (state == B);endmodule
- 验证结果