| module fsm(I,clock,reset,out); input I,clock,reset; output [2:0] out; reg [2:0] out; reg [2:0] currentState,nextState; parameter [2:0] A=0, // The state labels and their assignments B=1, C=2, D=3, E=4, F=5; always@(I or currentState) // The state labels and their logic case (currentState) A: begin nextState=(I==0)?A:B; out=(I==0)?3’b000:3’b100; end B: begin nextState=(I==0)?A:C; out=(I==0)?3’b000:3’b100; end C: begin nextState=(I==0)?A:D; out=(I==0)?3’b000:3’b101; end D: begin nextState=(I==0)?D:F; out=(I==0)?3’b010:3’b110; end E: begin nextState=(I==0)?D:F; out=(I==0)?3’b010:3’b110; end F:begin nextState=D; out=(I==0)?3’b000:3’b101; end default: begin // oops,undefined ststes.Go to state A nextState=A; out=(I==0)?3’bxxx:3’bxxx; end endcase always@(posedge clock or negedge reset) // The state register if(~reset) currentState<=A; else currentState<=nextState; endmodule |
共1条
1/1 1 跳转至页
接触认识状态机
简单FSM示例
可以作为以后写的一个模板哦!![em07][em07]
关键词: 接触 认识 状态机
共1条
1/1 1 跳转至页
回复
我要赚赏金打赏帖 |
|
|---|---|
| 基于MCP23S17的输入输出功能模块控制被打赏¥20元 | |
| 【S32K3XX】SPD 软件包使用Link文件修改被打赏¥22元 | |
| Switch-Case局部变量定义问题被打赏¥23元 | |
| 基于米尔TIAM62L开发板的串口通信及应用被打赏¥20元 | |
| PCF8574功能模块及其使用被打赏¥20元 | |
| 传感器LSM6DSO及LIS3MDL的功能检测被打赏¥18元 | |
| LPS25HB气压传感器及其检测被打赏¥18元 | |
| HTS221温湿度传感器及其检测被打赏¥18元 | |
| 【S32K3XX】HSE FW 版本更新被打赏¥21元 | |
| 基于ArduinoUNO开发板的AT24C02读写测试被打赏¥16元 | |
我要赚赏金
