第4章状态机设计祥解.pptVIP

  • 2
  • 0
  • 约5.64千字
  • 约 28页
  • 2016-11-03 发布于湖北
  • 举报
第4章状态机设计祥解.ppt

电子科学学院 LOGO 第4章 状态机设计 主 讲:赵丽华 电子科学学院 主要内容 4.3 Mealy状态机 4.2 Moore状态机 4.1 什么是状态机? 4.4状态机设计实例 电子科学学院 4.1 什么是状态机? 状态转移图 健康 感冒 康复 淋雨(t1) 吃药(t2) 打针(t3) 休息(t4) t1 t2 t4 t3 t4 触 发 条 件 电子科学学院 状态机的用途 控制系统中 电机停止 电机反转 电机正转 洗衣机控制系统 stop 20秒/010 20秒/100 20秒/001 电机控制信号 001 010 100 电子科学学院 为什么要使用状态机? 控制灵活 利于综合器的优化 结构清晰,层析分明 在高速运算和控制方面优势明显 可靠性高 电子科学学院 VHDL状态机的定义 SIGNAL current_state, next_state: states; 主要是设计者使用TYPE语句定义新的数据类型 TYPE 数据类型名 IS 数据类型定义; Type week is (sun,mon,tue,wed,thu,fri,sat); 例: Type states IS (st0, st1, st2, st3, st4, st5); 电子科学学院 状态机的VHDL结构 主控组合进程:根据当前状态完成状态译码和状态输出,并将状态译码反馈给主控时序进程,将状态输出给系统输出。 两个进程语句 主控时序进程 主控组合进程 主控时序进程:在时钟的驱动下进行状态转换。 case语句 If语句 电子科学学院 主要内容 4.3 Mealy状态机 4.2 Moore状态机 4.1 什么是状态机? 4.4状态机设计实例 电子科学学院 4.2 Moore状态机 输出只取决于系统当前的状态,而与系统的输入无关 current_state next_state 输入控制信号 电子科学学院 4.2 Moore状态机 x clock rest z X:输入控制信号 clock:为状态转换提供的时钟信号 rest:复位信号 z:控制器输出信号 电子科学学院 Moore状态机程序 library ieee; use ieee.std_logic_1164.all; entity moore is port(x,clock,rest:in std_logic; z:out std_logic); end moore; architecture behavior of moore is type state_type is (s0,s1,s2,s3); signal current_state , next_state:state_type; begin x clock rest z 定义状态 电子科学学院 主控组合程序 combin: process(current_state,x) begin case current_state is when s0=z=’0’; if x=’0’ then next_state=s0; else next_state=s2; end if; when s1=z=’1’; if x=’0’ then next_state=s0; else next_state=s2; end if; if语句根据当前状态和输入判定 下一个状态及输出情况 case语句判断当前状态 S0 0 S1 1 S2 1 S3 0 0 1 0 1 0 1 1 0 when s2=z=’1’; if x=’0’ then next_state=s2; else next_state=s3; end if; when s3=z=’0’; if x=’0’ then next_state=s3; else next_state=s1; end if; end case; end process; 电子科学学院 主控时序程序 synch: process(rest,clock) begin if rest=‘1’ then current_state=s0; elsif clock’event and clock=‘1’ then current_state=next_state; end if; end proc

文档评论(0)

1亿VIP精品文档

相关文档