课程设计-基于EDA的交通灯的设计.doc
《课程设计-基于EDA的交通灯的设计.doc》由会员分享,可在线阅读,更多相关《课程设计-基于EDA的交通灯的设计.doc(31页珍藏版)》请在三一文库上搜索。
1、 目 录 目录.1第一章 设计思路21.1、设计内容及要求21.2、设计构思21.3、设计构思框图3第二章 单元模块设计与仿真42.1、时钟分频模块42.2、5秒倒计时计数器模块52.3、35秒倒数计时计数器模块82.4、25秒倒计时计数器模块102.5、40秒倒计时计数器模块122.6、20秒倒计时计数器模块142.7、A方向控制模块162.8、B方向控制模块172.9、显示模块192.10、顶层文件的编写222.11. 总电路图25第三章 调试273.1、硬件实验273.2、实验现象28心得体会29参考文献30第一章 设计思路1.1、设计内容及要求1. 设计制作一块十字路口的交通信号灯的控
2、制电路的专用芯片。2. A方向和B方向各设置红(R)、黄(Y)、绿(G)三盏灯,三盏灯按合理的顺序亮灭,并能将灯亮的时间以倒计时的方式显示出来。3. 两个方向各灯的时间可方便地进行设置和修改。假设A方向为主干道,车流量大,A方向通行时间比B方向长。设A方向每次至少通行t1秒,B方向每次至多通行t2秒,黄灯亮t秒。1.2、设计构思 为了方便A、B方向的车流不堵塞,默认A方向先亮绿灯,同时B方向亮红灯,时间以倒数显示出来,在绿灯时间到达时,通过3秒黄灯,过渡到红灯,使得行驶过程中的车辆有足够的时间停下来。所以,红灯的时间是另一方向的绿灯时间加上黄灯的时间。用Ga、Ya、Ra依次代表主干道A方向的绿
3、灯、黄灯和红灯。用Gb、Yb、Rb依次代表支干道B方向的绿灯、黄灯和红灯。根据A、B方向的车流量大小,令A方向绿灯亮30S,黄灯亮3s,红灯亮28S;B方向绿灯亮25S,黄灯3s,红灯33s。如图1-1,图中1代表点亮,0代表灭。 A方向(主干道)B方向(支干道)时间GaYaRaGbYbRb时间35S10000140S5S01010020S25S0010105S图1-1 交通灯亮灭时间安排1.3、设计构思框图图1-2 设计构思框图 如图所示,通过A、B方向控制器分别控制A和B方向各自的时间倒数模块以及时间显示。第2章 单元模块设计与仿真2.1、时钟分频模块 系统时钟计时模块需要1HZ的脉冲,与
4、系统的动态扫描需要的脉冲不同。分频模块主要为系统提供所需的时钟计时脉冲。该模块将50MHZ的脉冲信号进行分频,产生1S的方波,作为系统时钟计时信号。2.1.1、源程序: -模块 FEN。它是分频 得到1HZ library ieee; use ieee.std_logic_1164.all; entity chenliangfen is port(clk:in std_logic; 图2-1 分频模块 clk1S:out std_logic); end chenliangfen; architecture fen_arc of chenliangfen is begin process(clk
5、) variable cnt:integer range 0 to 49999999 begin if clkevent and clk=1then if cnt=49999999 then clk1S=1; else cnt:=cnt+1 clk1S=0; end if; end if; end process; end fen_arc;2.1.2、仿真图形:2.2、5秒倒计时计数器模块2.2.1、源程序: library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity chenliang5s i
6、s port(clk:in std_logic; cr:in std_logic; 图2-2 5S倒计时模块 en2:in std_logic; j2:out std_logic; q1:out std_logic_vector(3 downto 0) );end chenliang5s;architecture t5_arc of chenliang5s is signal bcd1n: std_logic_vector(3 downto 0);begin process(clk,cr) begin if(cr=0) then bcd1n=0101; elsif(en2=1)then if(
7、clkevent and clk=1) then if(bcd1n=0) then bcd1n=0000; else bcd1n=bcd1n-1; end if; end if; end if;end process; q1=bcd1n;process(bcd1n) begin j2=0; if(bcd1n=0) then j2=1;end if;end process;end t5_arc;2.2.2、仿真图形: 图2-3 5s倒计时流程图2.3、35秒倒数计时计数器模块2.3.1、源程序:library ieee;use ieee.std_logic_1164.all;use ieee.s
8、td_logic_unsigned.all;entity chenliang35s is port(clk:in std_logic; cr:in std_logic; en1:in std_logic; j1:out std_logic; q1:out std_logic_vector(3 downto 0); y10:out std_logic_vector(3 downto 0);end chenliang35s; 图2-4 35s倒计时模块architecture t35_arc of chenliang35s is signal bcd1n: std_logic_vector(3 d
9、ownto 0); signal vcd10n: std_logic_vector(3 downto 0);begin process(clk,cr) begin if(cr=0) then bcd1n=0101; elsif(en1=1)then if(clkevent and clk=1) then if(bcd1n=0 and vcd10n/=0) then bcd1n=1001; elsif (bcd1n=0 and vcd10n=0)then bcd1n=0000; else bcd1n=bcd1n-1; end if; end if; end if;end process; q1=
10、bcd1n; y10=vcd10n;process(clk,cr)begin if(cr=0) then vcd10n=0011; elsif(en1=1)then if(clkevent and clk=1) then if (bcd1n=0)then if(vcd10n=0)then vcd10n=0000; else vcd10n=vcd10n-1; end if; end if; end if;end if;end process;process(bcd1n,vcd10n) begin j1=0; if(bcd1n=0and vcd10n=0) then j1=1; end if;en
11、d process;end t35_arc;2.3.2、仿真图形:2.4、25秒倒计时计数器模块2.4.1、源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity chenliang25s is port(clk:in std_logic; cr:in std_logic; en3:in std_logic; j3:out std_logic; q1:out std_logic_vector(3 downto 0); y10:out std_logic_vector(3 downto
12、 0);end chenliang25s; 图2-5 25秒倒计时模块architecture t25_arc of chenliang25s is signal bcd1n: std_logic_vector(3 downto 0); signal vcd10n: std_logic_vector(3 downto 0);begin process(clk,cr) begin if(cr=0) then bcd1n=0101; elsif(en3=1)then if(clkevent and clk=1) then if(bcd1n=0 and vcd10n/=0) then bcd1n=1
13、001; elsif (bcd1n=0 and vcd10n=0)then bcd1n=0000; else bcd1n=bcd1n-1; end if; end if; end if;end process; q1=bcd1n; y10=vcd10n;process(clk,cr)begin if(cr=0) then vcd10n=0010; elsif(en3=1)then if(clkevent and clk=1) then if (bcd1n=0)then if(vcd10n=0)then vcd10n=0000; else vcd10n=vcd10n-1; end if; end
14、 if; end if;end if;end process;process(bcd1n,vcd10n) begin j3=0; if(bcd1n=0and vcd10n=0) then j3=1; end if;end process;end t25_arc;2.4.2、仿真波形:2.5、40秒倒计时计数器模块2.5.1、源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity chenliang40s is port(clk:in std_logic; cr:in std_logi
15、c; 图2-6 40秒倒计时模块 en4:in std_logic; j4:out std_logic; q1:out std_logic_vector(3 downto 0); y10:out std_logic_vector(3 downto 0);end chenliang40s;architecture t40_arc of chenliang40s is signal bcd1n: std_logic_vector(3 downto 0); signal vcd10n: std_logic_vector(3 downto 0);begin process(clk,cr) begin
16、if(cr=0) then bcd1n=0000; elsif(en4=1)then if(clkevent and clk=1) then if(bcd1n=0 and vcd10n/=0) then bcd1n=1001; elsif (bcd1n=0 and vcd10n=0)then bcd1n=0000; else bcd1n=bcd1n-1; end if; end if; end if;end process; q1=bcd1n; y10=vcd10n;process(clk,cr)begin if(cr=0) the vcd10n=0100; elsif(en4=1)then
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 课程设计 基于 EDA 交通灯 设计
链接地址:https://www.31doc.com/p-3292372.html