Verilog学习记录之状态机设计
状态机设计
四段论
- 状态空间定义
- 状态跳转
- 下个状态判断
- 各状态下的动作
1.状态空间定义
状态空间是区分状态机工作在不同状况下的标志,用常量定义。
parameter SLEEP = 2'b00;
parameter STUDY = 2'b01;
parameter EAT = 2'b 10;
parameter AMUSE = 2'b11;
reg [1:0] current_state;
reg [1:0] next_state;
2.状态跳转(时序逻辑)
always @(posedge clk or negedge rst_n)
begin
if (!rst_n)
current_state <= SLEEP;
else
current_state