VHDL与数字电路设计PPT课件-第七章 状态机设计.ppt_第1页
VHDL与数字电路设计PPT课件-第七章 状态机设计.ppt_第2页
VHDL与数字电路设计PPT课件-第七章 状态机设计.ppt_第3页
VHDL与数字电路设计PPT课件-第七章 状态机设计.ppt_第4页
VHDL与数字电路设计PPT课件-第七章 状态机设计.ppt_第5页
免费预览已结束,剩余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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论