Verilog HDL 有限状态机的设计
来源:互联网 发布:政府数据开放平台 编辑:程序博客网 时间:2024/05/21 10:00
Verilog HDL 有限状态机的设计
【转自教科书】
有限状态机根据输出逻辑的不同可以分为Mealy状态机和Moore状态机,两者设计方法基本一致,唯一不同的是输出结果是否取决于输入信号。
Mealy 状态机:输出结果不仅取决于当前状态,还与输入信号有关;
Moore 状态机:输出结果只取决于系统当前状态。
有限状态机可分为三个主要变量:现状态、次状态和输出结果。
有限状态机的设计,根据使用的Always过程块的不同而分为:
【一段式】上述三个状态都放在一个always过程快中描述。而这种方法包含所有的逻辑设计,使得整体设计变得复杂增加设计难度。【两段式】把现状态用一个always过程块描述,次状态和输出结果用另一个always过程块描述。
【三段式】分别把三个变量用三个always过程块分开描述。
现对下图进行两段式和三段式状态机设计:
两段式设计:
module state_ji(clk,rst,q,a,b,c,d,state,nextstate); input clk,rst,a,b,c,d; output q,state,nextstate; reg[2:0] q; reg[1:0] state,nextstate; parameter s0=2'b00, s1=2'b01, s2=2'b10, s3=2'b11; always@(posedge clk) begin if(rst) state <= s0; else state <= nextstate; end/*********************************************/ //两段式状态机:把现状态写进一个always模块,// 次状态和输出值写进一个always模块 always@(state or a or b or c or d) begin case(state ) s0:begin q <= 3'b001; if(a) nextstate <= s1; else nextstate <= s0; end s1:begin q <= 3'b010; if(b) nextstate <= s2; else nextstate <= s0; end s2:begin q <= 3'b100; if(c) nextstate <= s3; else nextstate <= s0; end s3:begin q <= 3'b111; if(d) nextstate <= s0; else nextstate <= s2; end endcase endendmodule
三段式设计:
module state_ji(clk,rst,q,a,b,c,d,state,nextstate); input clk,rst,a,b,c,d; output q,state,nextstate; reg[2:0] q; reg[1:0] state,nextstate; parameter s0=2'b00, s1=2'b01, s2=2'b10, s3=2'b11;//三段式状态机:把现状态、次状态、输出值分别写进三个always模块 always@(posedge clk) begin if(rst) state <= s0; else state <= nextstate; end always@(state or a or b or c or d) begin case(state ) s0:begin if(a) nextstate <= s1; else nextstate <= s0; end s1:begin if(b) nextstate <= s2; else nextstate <= s0; end s2:begin if(c) nextstate <= s3; else nextstate <= s0; end s3:begin if(d) nextstate <= s0; else nextstate <= s2; end endcase end always@(state) begin case(state) s0: q = 3'b001; s1: q = 3'b010; s2: q = 3'b100; s3: q = 3'b111; endcase end******************************************************************/endmodule
阅读全文
0 0
- Verilog HDL 有限状态机的设计
- 基于Verilog HDL的有限状态机
- 基于Verilog HDL的有限状态机
- 基于Verilog HDL的有限状态机
- Verilog HDL 音乐盒设计
- Verilog HDL模块化设计
- Verilog-HDL 的基本概念
- Verilog HDL的建模
- Verilog HDL 与数字电路设计
- 设计与验证:verilog hdl
- [verilog读书笔记]1.Verilog HDL数字设计
- verilog语言设计有限状态机习题
- 基于Verilog HDL语言的32X8 FIFO设计
- 数字电路设计之同步状态机的verilog HDL实现
- 基于Verilog HDL的模60BCD码计数器设计
- Verilog HDL的Testbench简介
- 关于Verilog HDL的学习
- Verilog HDL模块的结构
- Ambari Alert告警服务梳理
- struts中的ognl表达式
- 「笔记」《大话数据结构》第二章:算法
- 信号量down, up, sem_p, sem_v, sem_wait, sem_post 的区别
- Tomcat集群(一)
- Verilog HDL 有限状态机的设计
- 10月28日考试解题报告
- Hibernate 实体类注解
- DrawerLayout+NavigationView实现侧滑菜单
- Spring-MVC 4 ajax提交json数据 报错415
- c++中的多重继承和虚函数
- pandas groupby 详解
- 自定义轮播
- ZooKeeper 使用中的问题:Len error