




免费预览已结束,剩余11页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第七章 状态机设计,vhdl与数字电路设计,本章内容,状态机的电路设计 交通灯控制器设计,1、状态机的电路设计,我们可以用输入信号x和电路状态q来描述时序电路的逻辑功能,这时时序电路称为状态机(state machine)。 根据输出信号和输入信号以及电路状态的关系,状态机可以分为两种:穆尔(moore)型和米利(mealy)型。,y=fx,q,y=fq,米利(mealy)型:,穆尔(moore)型:,(1) more型状态机,输入信号影响状态的转换。,输出信号和输入信号无关。,library ieee; use ieee.std_logic_1164.all; entity more is port( clk,reset: in std_logic; din: in std_logic; op: out std_logic); end more; architecture a of more is type state_type is (s0, s1, s2,s3); signal state: state_type; begin,process (clk,reset) begin if reset = 1 then state if din=1 then state if din=0 then state if din=0 then state if din=1 then state = s0; else state=s1; end if; end case; end if; end if; end process; op=1 when state=s1 else 0; end a;,(2) mealy型状态机,library ieee; use ieee.std_logic_1164.all; entity mealy is port( clk,reset: in std_logic; -clock din: in std_logic; op: out std_logic); end mealy; architecture a of mealy is type state_type is (s0, s1, s2,s3); signal state: state_type; begin,process (clk,reset) begin if reset = 1 then state if din=1 then state if din=0 then state if din=0 then state if din=1 then state = s0; else state=s1; end if; end case; end if; end if; end process; op=1 when (state=s0 and din=1) or (state=s1 and din=1) or (state=s3 and din=1) else 0; -输出不仅与状态有关,而且和输入有关。 end a;,2、交通灯控制器的设计,设计一个十字路口交通灯控制器,东西、南北方向有红灯、黄灯、绿灯,持续时间分别为45、5、40秒。,电路框图,交通灯控制流程图,s0,s1,s2,s3,library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity nclight is port(clk : in std_logic; ra,rb,ya,yb,ga,gb : out std_logic ); end nclight; architecture a of nclight is type state is (s0,s1,s2,s3); signal presentstate,nextstate : state; signal tmp1,tmp2 : integer range 0 to 40; signal timeout1,timeout2: std_logic; signal q: std_logic_vector(21 downto 0); signal sec: std_logic; begin,-get 1 hz clock pulse process(clk) begin if clkevent and clk=1 then q=q+1; end if; sec=q(21); -get 1 hz clock pulse end process; timing: process(sec) begin if secevent and sec=1 then if tmp1=39 then timeout1=1; timeout2=0; tmp1=0; else if timeout1=1 then if tmp2=4 then timeout2=1; timeout1=0; tmp2=0; else tmp2=tmp2+1; end if; else tmp1=tmp1+1; end if; end if; end if; end process;,changestate: process(presentstate) begin case presentstate is when s0 = if timeout1=0 then nextstate if timeout2=0 then nextstate=s1; ra=0; ya=1; ga=0; rb=1; yb=0; gb=0; else nextstate=s2; end if;,when s2 = if
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年初中学业水平考试地理模拟卷:人文地理地理信息系统应用试题及答案
- 2025年大学工会学专业题库- 工会在社会保障体系中的优化及创新研究
- 2025年刑法模拟检测试卷(刑法中的法律漏洞问题)
- 2025年高压电工考试题库:高压设备故障诊断与设备运行管理实战试题
- 2025年大学科学教育专业题库- 科学教育中的全人教育理念
- 2025年大学警卫学专业题库- 室内安全门锁设置与使用方法
- 2025年大学人文教育专业题库-阳光草堂第四卷
- 2025年大学人文教育专业题库- 人文教育的课程设计与实施
- 2025年大学华文教育专业题库- 语文教学中的情感识别培养
- 2025年起重机械作业特种作业操作证考试试卷(起重机械制动与润滑系统标准案例分析)试题
- 穴位按摩法操作评分标准
- 充电站运营管理制度(参考模板)
- 体育与健康教学设计《手倒立前滚翻》
- NISP一级考前模拟训练题库200题(含答案)
- JJG 20-2001标准玻璃量器
- 2024外研版初中英语单词表汇总(七-九年级)中考复习必背
- 《大数据平台部署与运维》课程标准(含课程思政)
- 英语中的时间表达(示范课例)
- 脊柱外科进修汇报
- 《史记》上册注音版
- 苏州大学文学院语言学纲要课程笔记
评论
0/150
提交评论