已阅读5页,还剩13页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
交通信号控制器的vhdl的设计1. 设计任务 模拟十字路口交通信号灯的工作过程,利用实验板上的两组红、黄、绿led作为交通信号灯,设计一个交通信号灯控制器,示意图如图1-1所示。要求:(1) 交通灯从绿变红时,有4秒黄灯亮的间隔时间;(2) 交通灯红变绿是直接进行的,没有间隔时间;(3) 主干道上的绿灯时间为40秒,支干道的绿灯时间为20秒;(4) 在任意时间,显示每个状态到该状态结束所需的时间。 支干道 主干道 图1-1 路口交通管理示意图表1-1 交通信号灯的4种状态abcd主干道交通灯绿(40秒)黄(4秒)红(20秒)红(4秒)支干道交通灯红红绿黄2.设计要求 采用vhdl语言编写程序,并在quartusii工具平台中进行开发,下载到eda实验箱进行验证。 编写设计报告,要求包括方案选择、程序清单、调试过程、测试结果及心得体会。3.设计方案状态寄存器秒脉冲信号发生器计数器clk 时间显示数据输出 次态发生器信号灯输出信号 信号灯输出 图3-1 交通信号灯控制器程序原理框图进程将clk信号分频后产生1秒信号,然后构成两个带有预置数功能的十进制计数器,并产生允许十位计数器计数的控制信号。状态寄存器实现状态转换和产生状态转换的控制信号,下个模块产生次态信号和信号灯输出信号,以及每一个状态的时间值。经过五个模块的处理,使时间计数、红绿灯显示能够正常运行。程序原理图如图3-1所示。 4.各模块具体设计4.1顶层文件的设计 顶层文件的原理图可以依据系统的框图进行,由控制模块jtd_ctrl、计时模块jtd_time、译码驱动模块jtd_light、显示模块jtd_dis和分频模块jtd_fqu五部分组成,其顶层原理图文件如图3-1所示。图4-1交通灯顶层文件原理图顶层模块的程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity traffic isport( clk1k,clr:in std_logic; m:in std_logic_vector(2 downto 0); led:out std_logic_vector(6 downto 0); sel:out std_logic_vector(2 downto 0); abl:out std_logic_vector(7 downto 0) );end traffic;architecture behave of traffic iscomponent jtd_fqu is -分频器元件的例化port( clk1k:in std_logic; clk:out std_logic );end component;component jtd_dis is -数码显示的元件例化port( clk1k,clk,clr:in std_logic; m:in std_logic_vector(2 downto 0); at,bt:in std_logic_vector(7 downto 0); led:out std_logic_vector(6 downto 0); sel:out std_logic_vector(2 downto 0) );end component;component jtd_light is -译码驱动的元件例化port( clr:in std_logic; m,s:in std_logic_vector(2 downto 0); abl:out std_logic_vector(7 downto 0) );end component;component jtd_time is -计时元件的例化port( clk,clr:in std_logic; m,s:in std_logic_vector(2 downto 0); at,bt:out std_logic_vector(7 downto 0) );end component;component jtd_ctrl is -控制模块的元件例化port( clk,clr:in std_logic; at,bt:in std_logic_vector(7 downto 0); m:in std_logic_vector(2 downto 0); s:out std_logic_vector(2 downto 0) );end component;signal clk:std_logic;signal at:std_logic_vector(7 downto 0);signal bt:std_logic_vector(7 downto 0);signal s:std_logic_vector(2 downto 0);begin u1:jtd_fqu port map( -名字关联方式赋值 clk1k=clk1k, clk=clk );u2:jtd_time port map( clr=clr, at=at, bt=bt, clk=clk, m=m, s=s );u3:jtd_ctrl port map( m=m, s=s, clk=clk, clr=clr, at=at, bt=bt );u4:jtd_dis port map( clk1k=clk1k, clk=clk, clr=clr, at=at, bt=bt, led=led, sel=sel, m=m );u5:jtd_light port map( clr=clr, s=s, abl=abl, m=m );end behave;4.2 控制模块jtd_ctrl的设计 控制的模块根据外部输入信号m2m0和计时模块jtd_time的输入信号,产生系统的状态机,控制其他部分协调工作。控制模块的源文件程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity jtd_ctrl isport( clk,clr:in std_logic; m:in std_logic_vector(2 downto 0); -用m来表示系统的8种工作状态 at,bt:in std_logic_vector(7 downto 0); s:out std_logic_vector(2 downto 0) ); end jtd_ctrl; architecture jtd_1 of jtd_ctrl is signal q:std_logic_vector(2 downto 0); begin process(clr,clk,m,at,bt) begin if clr=1then q=000; -清0处理 elsif(clkevent and clk=1)then -时钟上升沿信号一来,m控制系统的8种状态 if m=000then q=001; end if; if m=001then q=011; end if; if m=010then q=101; end if; if m=011then q=100then if(at=x01)or(bt=x01)then q=q+1; else q=q; end if; end if; end if; end process; s=q; -m的控制端转向控制口s end jtd_1;该模块的时序仿真和功能仿真波形图如图4-2图4-2功能仿真4.3 计时模块jtd_time的设计计时模块用来设定a和b两个方向计时器的初值,并为显示模块jtd_dis提供倒计时时间。当正常计时开始后,需要进行定时计数操作,由于东西和南北两个方向上的时间显示器是由两个led七段显示数码管组成的,因此需要产生两个2位的计时信息:2个十位信号,2个个位信号,这个定时计数操作可以由一个定时计数器来完成,又因为交通灯的状态变化是在计时为0的情况下才能进行的,因此需要一个计时电路来产生使能信号,因此定时计数的功能就是用来产生2个2位计时信息和使能信号。计时模块的源文件程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity jtd_time isport( clk,clr:in std_logic; m,s:in std_logic_vector(2 downto 0); at,bt:out std_logic_vector(7 downto 0) );end jtd_time;architecture jtd_2 of jtd_time is signal at1,bt1:std_logic_vector(7 downto 0);signal art,agt,alt,abyt:std_logic_vector(7 downto 0); signal brt,bgt,blt:std_logic_vector(7 downto 0);begin art=x55; -art=“01010101”a方向红灯亮 agt=x40; -agt=“01000000”a方向绿灯亮 alt=x15; -alt=“00010101”灯间歇闪烁 abyt=x05;-abyt=“00000101”ab两方向黄灯亮 brt=x65;-brt=“01100101”b方向红灯亮 bgt=x30;-bgt=“00110000”b方向绿灯亮 blt=x15;-blt=“00010101”b方向灯闪烁 process(clr,clk,m,s) begin if clr=1then at1=x01;bt1=x01; elsif (clkevent and clk=1)then if m=000then at1=x01;bt1=x51;-m=0时,a方向的计时器计时,b方向的红灯亮 end if; if m=001then at1=x01;bt1=x06;-m=1时,a方向的计时器计时,b方向绿灯亮 end if; if m=010then at1=x41;bt1=x01;-b方向的计时器计时,a方向的黄灯亮 end if; if m=011then at1=x06;bt1=100then if(at1=x01)or(bt1=x01)then case s is when000=at1=alt;bt1at1at1at1at1=art;bt1bt1bt1bt1at1=at1;bt1=bt1; end case; end if; if at1/=x01then if at1(3 downto 0)=0000then at1(3 downto 0)=1001;-第四位数码管显示 at1(7 downto 4)=at1(7 downto 4)-1;高四位数码管减一显示 else at1(3 downto 0)=at1(3 downto 0)-1;低四位数码管减一显示 at1(7 downto 4)=at1(7 downto 4);高四位数码管显示不变 end if; end if; if bt1=x01then if bt1(3 downto 0)=0000then bt1(3 downto 0)=1001;-b方向计数器低四位数码管显示9 bt1(7 downto 4)=bt1(7 downto 4)-1;-b方向计数器高四位数码管减一计数 else bt1(3 downto 0)=bt1(3 downto 0)-1;-b方向计数器低四位数码管减一计数 bt1(7 downto 4)=bt1(7 downto 4); end if; end if; end if; end if;end process; at=at1; bt=bt1;end jtd_2; 该模块是为节省资源而设的,实验中有四个led七段数码管显示计数,点亮一个led需电流550ma,同时点亮4个led,cpld可能无法负荷这样的电流驱动,而且功率太大,散热也是问题。同时这么做也容易造成电路被烧毁,因此需要逐个循环点亮。又为使显示结果持续不致闪烁抖动,只需每个扫描频率超过人眼视觉暂留频率24hz以上,就能达到。选择1khz作为时钟,分到4个数码管,每个数码管50hz(大于24hz),故不会有闪烁。 该模块的功能仿真波形图如图4-4所示图4-4功能仿真4.4 译码驱动模块jtd_light的设计译码驱动模块根据控制信号,驱动交通灯的显示。该模块的源程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity jtd_light isport( clr:in std_logic; m,s:in std_logic_vector(2 downto 0); abl:out std_logic_vector(7 downto 0) );end jtd_light;architecture jtd_3 of jtd_light is signal lt:std_logic_vector(7 downto 0);begin process(clr,s,m)begin if clr=1then lt=00000000; -清0时系统状态全部处于关闭状态 else if m=000then lt=10000001; end if; if m=001then lt=00100001; end if; if m=010then lt=00011000; end if; if m=011then lt=100then case s is -八种情况下的状况显示 when000=ltltltltltltltltlt=lt; end case; end if; end if; end process;abl=lt;end jtd_3;该模块的功能仿真波形图如图4-5:图4-5功能仿真4.5 显示模块jtd_dis的设计 显示模块用来显示倒计时时间和系统的工作状态。其输出用来驱动六位数码管,其中四位用于显示倒计时时间,两位显示工作状态,采用动态扫描显示。该模块的源程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity jtd_dis isport( clk1k,clk,clr:in std_logic; m:in std_logic_vector(2 downto 0); at,bt:in std_logic_vector(7 downto 0); led:out std_logic_vector(6 downto 0); sel:out std_logic_vector(2 downto 0) );end jtd_dis;architecture jtd_4 of jtd_dis is signal ou,stl,sth,mm:std_logic_vector(3 downto 0); signal dis,ds:std_logic_vector(7 downto 0); signal sl:std_logic_vector(2 downto 0);begin mm=0&m; sth=xa; process(clr,clk1k) begin if clr=1then sl=000; elsif(clk1kevent and clk1k=1)then if sl=101then sl=000; -清0 else slououououo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年护理查房制度培训课件
- 2026年注册安全工程师考试《安全生产法》专项训练卷
- 2026年一级造价工程师考试《土建工程计量》专项训练试卷
- 2026年会计专业技术资格考试初级会计实务专项训练试卷(附答案)
- 2026年房地产估价师考试《房地产估价原理与方法》培训试卷
- 湖南省A 佳教育2025-2026学年高二上学期11月期中地理试题(含答案)
- 22必修第三册 第十二章 电能 能量守恒定律 第1-2节同步练习
- 2026年思想道德修养试题及参考答案
- 天津市2026届九年级中考模拟冲刺数学试卷(含解析)
- 2026年广东省北师大版初中物理上册第3章单元测试卷
- 《计算机制图-AutoCAD2020》课件(共六个模块)
- 2025 年小升初广州市初一新生分班考试语文试卷(带答案解析)-(人教版)
- 2025年语言文字规范化知识测试题及答案
- 2025年食品安全管理人员专业知识考核试题A卷附答案
- 呼吸训练器使用指南
- 年轻医生临床思维培养
- 《易制毒化学品企业档案》
- JG/T 336-2011混凝土结构修复用聚合物水泥砂浆
- 网络安全业务竞赛题库ctf
- 《公路桥梁伸缩装置设计指南》
- 危大工程(深基坑、高边坡、高支模)施工流程及安全注意事项
评论
0/150
提交评论