文档详情

交通灯的设计与实现交通灯的设计与实现.doc

发布:2017-01-03约8.94千字共16页下载文档
文本预览下载声明
一、设计任务 设计一个十字路口的红、绿、黄三色信号交通灯控制电路,具体要求如下: 1)用红、绿、黄三色发光二极管作信号灯。主干道为东西向,有红、绿、黄三个灯;干道为南北向,也有红、绿、黄三个灯。红灯亮禁止通行;绿灯亮允许通行;黄灯亮则给行驶中的车辆有时间停靠到禁行线之外。 2)每次放行s,。 在每次由亮绿灯变成亮红灯的转换过程中间,需要亮5s的黄灯作为过渡,以使行驶中的车辆有时间停靠到禁行线以外。 3)能实现正常的、即时显示功能,用实验箱上的4个七段数码管作为到计时显示器,分别显示东西、南北方向的红灯、绿灯、黄灯时间。 然后,我们这里用了BCD码表示倒计时时间。灯亮或闪烁时间(绿、黄、红分别为26s、130s、5s)用BCD码表示(分别为26h、30h、5h),倒计时的时候个位和十位分别是BCD码的高四位和低四位,首先是低四位倒数,当倒数到0时,给它重新赋值为9,且高四位减1,如此循环,直到这个数减到0,此时表示某一个灯亮的时间到,接着进行下一个状态,为了能使进入下一个状态, 必须在时间减到0的时候,给使能端en 赋值1;由于用的BCD码,高四位和低四位就分别是我们要在译码模块的要用数码管显示的十位和个位。用数据选择器来控制东西、南北的灯亮。 三、程序流程图 1.1分频器的设计流程图 1.2 5进制的设计流程图 1.3 30进制的设计流程图 1.4 26进制的设计流程图 1.5 状态机的程序流程图 四、程序设计 1、5进制的设计 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity jinzhi5 is port(clk,en,rst:in std_logic; ge,shi: out std_logic_vector(3 downto 0); cout:out std_logic); end jinzhi5; architecture behav of jinzhi5 is begin process(clk,en) variable a,b: std_logic_vector(3 downto 0); begin if(rst=0) then a:=0101;b:=0000 elsif clkevent and clk=1 then if(en=1) then if(a=0) then a:=0101;b:=0000,cout=1; else a:=a-1;b:=0000,cout=0; end if; end if; end if; ge=a;shi=b; end process; end behav; 仿真结果 2、 26进制的程序 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity jinzhi26 is port(clk,en:in std_logic; ge: out std_logic_vector(3 downto 0); shi: out std_logic_vector(3 downto 0); cout:out std_logic); end jinzhi26; architecture behav of jinzhi26 is begin process(clk,en) variable a: std_logic_vector(3 downto 0); variable b: std_logic_vector(3 downto 0); begin if(en=0) then a:=0010;b:=0101; elsif clkevent and cl
显示全部
相似文档