交通灯控制系统EDA实验报告.docx

交通灯控制系统 EDA实验报告 2014 2014 姓名: 学号: 课题名称 用状态机设计的交通信号控制系统。 实验目的 利用所学习的EDA相关知识,完成对交通灯控制系统的设计并实现,提高对所学知识的理解和利用熟练程度。 设计任务 设计一个十字路口交通控制系统,要求如下: 东西(用A表示)、南北(用B表示)方向均有绿灯、黄灯、红灯指示,持续时间分别是40秒、五秒和45秒,交通灯运行的切换示意图与时间关系如下。 交通控制系统运行切换示意图 更方向灯光时间关系 系统设有时钟,以倒计时的方式显示每一路允许通行的时间。 当东西或南北两路中任意一路出现特殊状况时,系统可由交警手动控制立即进入特殊运行状态,即红灯全亮,始终停止计时,东西、南北两路所有车辆禁止通行;当特殊状况结束后,系统恢复工作,继续正常运行。 实验过程 VHDL设计流程 交通控制系统顶层原理图如下,它主要由50MHz分频器(devide50M)、控制器(control)、45秒倒计时计数器(m45)、7字段译码器(SEG7)组成。 控制器的设计 控制器的逻辑符号如图所示。其中CLK为时钟输入信号;HOLD为紧急制动信号;ARED、AGREEN、AYELLOW分别为东西方向的红灯、绿灯、黄灯指示的输出信号;BRED、BGREEN、BYELLOW分别为南北方向的红灯、绿灯、黄灯指示的输出信号。 控制器的VHDL描述文件control.vhd如下: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity control is port(clk,hold:in std_logic; ared,agreen,ayellow,bred,bgreen,byellow:out std_logic); end control; architecture behavior of control is type state_type is (s0,s1,s2,s3,s4); signal current_state,next_state:state_type; signal counter : std_logic_vector(6 downto 0); begin synch:process begin wait until clkevent and clk=1; if hold=0 then --当紧急制动信号有效时,计数器停止计数 counter=counter; else if counter89 then counter=counter+1; else counter=(others=0); end if; end if; end process; process --待机状态 begin wait until clkevent and clk=1; current_state= next_state; end process; state_trans:process(current_state) begin case current_state is when s0= if hold=0 then next_state=s4; else if counter39 then next_state=s0; else next_state=s1; end if; end if; when s1= if hold=0 then next_state=s4; else if counter44 then next_state=s1; else next_state=s2; end if; end if; when s2= if hold=0 then next_state=s4; else if counter84 then next_state=s2; else next_state=s3; end if; end if; when s3 = if hold=0 then next_state=s4; else if counter89 then next_state=s3; else next_state=s0; end if; end if; when

文档评论(0)

1亿VIP精品文档

相关文档