EDA课程设计交通灯.docx

上传人:牧羊曲112 文档编号:3156198 上传时间:2023-03-11 格式:DOCX 页数:17 大小:43.70KB
返回 下载 相关 举报
EDA课程设计交通灯.docx_第1页
第1页 / 共17页
EDA课程设计交通灯.docx_第2页
第2页 / 共17页
EDA课程设计交通灯.docx_第3页
第3页 / 共17页
EDA课程设计交通灯.docx_第4页
第4页 / 共17页
EDA课程设计交通灯.docx_第5页
第5页 / 共17页
亲,该文档总共17页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《EDA课程设计交通灯.docx》由会员分享,可在线阅读,更多相关《EDA课程设计交通灯.docx(17页珍藏版)》请在三一办公上搜索。

1、EDA课程设计交通灯 交通信号灯控制电路设计 一、概述 城市道路交叉口是城市道路网络的基本节点,也是网络交通流的瓶颈。目前,大部分无控制交叉口都存在高峰小时车流混乱、车速缓慢、延误情况严重、事故多发、通行能力和服务水平低下等问题。特别是随着城市车流量的快速增长,城市无控制道路交叉口的交通压力越来越大。因此,做好基于EDA技术平台的交叉口信号控制设计是缓解交通阻塞、提高城市道路交叉口车辆通行效率的有效方法。交通信号控制的目的是为城市道路交叉口(或交通网络)提供安全可靠和有效的交通流,通常最为常用的原则是车辆在交叉口的通过量最大或车辆在交叉口的延误最小。 交通信号灯控制电路是显示主干道和支干道交替

2、放行时间并用试验箱左上角的彩灯来代替信号灯的一种实际电路。设计一个基于FPGA的红绿灯交通信号控制器。假设某个十字路口是由一条主干道和一条次干道汇合而成,在每个方向设置红绿黄三种信号灯,红灯亮禁止通行,绿灯亮允许通行。黄灯亮允许行驶中车辆有时间停靠到禁止线以外。 本课程的基本原理是在合适的时钟信号的控制下,使主干道与支道的红黄绿灯循环显示,用VHDL语言编辑文本程序,按设计要求连接好线以后,进行波形仿真,仿真结果正确后下载程序并对试验箱进行调试,使其最终的显示结果符合设计要求。 红黄绿 支红 干黄 绿道 主干道二、方案设计与论证 在硬件时钟电路的基础上,采用分频器,输出一个1S的时钟信号,在时

3、钟信号的控制下,实现主干道和支干道红绿灯交替显示。 红绿灯交通灯控制器层次设计: EDA技术的基本设计方法有电路级设计方法和系统级设计方法。电路级设计方法已经不能适应新的形势,本系统采用的是系统级层次设计方法,对整个系统进行方案设计和功能划分,系统的关键电路用一片FPGA芯片实现,首先用VHDL语言编写各个功能模块程序,最后通过综合器和适配器生成最终的目标器件,然后用顶层原理图将各功能模块连接起来。下面给出各模块的VHDL设计过程和仿真结果。 1、 系统时序发生电路clk_gen的VHDL设计 在红绿灯交通信号控制系统中,大多数的情况是通过自动控制的方式指挥交通的。因此,为了避免意外事件的发生

4、,电路必须给一个稳定的时钟才能让系统正常运作。第 - 1 - 页 共 14 页 但为了配合高峰时段,防止交通拥挤,有时也必须使用手动控制,即让交警能够顺利地指挥交通。Clk_gen电路最主要的功能就是产生一些额外的输出信号,并将其用做后续几个电路的使能控制与同步信号处理。 该电路的核心部分就是分频电路,通过对外接信号发生器提供1kHz的时钟信号进行1000分频,得到一个周期为1秒的输出使能信号ena_lhz和flash_lhz;4分频后得到红绿灯信号译码电路所需的频率为250Hz的显示使能信号ena_scan。 architecture one of fenpingqi is signal c

5、ounter:integer range 0 to 4999999; Begin process (CLR,CLK) Begin if(CLK=1 and CLKevent) then if CLR=1 then counter=0; elsif counter =4999999 then counter=0; q=not q; else counter=counter+1; end if; end if; end process; end one; 2、 开关控制部分的ASM图 i、j、k、分别代表开关状态;1表示开关闭合,为高电平;0表示开关断开为低电平。当开关处于不同的状态时,分别给变量

6、G不同的值,用来实现控制通行时间。 X=i&j&k X=001 y G=29 X=010 y G=39 X=100 y G=49 G=0 第 - 2 - 页 共 14 页 x=i&j&k; cnt:process (clk) variable s:integer range 0 to 49; variable g:integer range 0 to 49; variable nclr,en:bit; Begin if x=001then g:=29; elsif x=010then g:=39; elsif x=100then g:=49; else g:=0; end if; 3、 信号灯

7、转换控制部分的ASM图 Rm、Ym、Gm分别表示主干道红、黄、绿;Rf、Yf、Gf分别表示支道红、黄、绿; S表示灯亮的时间;nclr是计时器的清零端,低电平有清零;en是计时器的使能端,高电平使能。 Gm=1 Rf=1 S=S+1 nclr=1 en=1 y S=3 S=G y Ym=1 Rf=1 nclr=0 en=0 Rm=1 Yf=1 y nclr=0 en=0 y S=G S=S+1 nclr=1 en=1 S=3 Rm=1 Gfrm=0;ym=0;gm=1; rf=1;yf=0;gf=0; if s=g then state =b;nclr:=0;en:=0; Else state

8、rm=0;ym=0;gm=1; if s=g then rf=1;yf=0;gf=0; state =b;nclr:=0;en:=0; Else staterm=0;ym=1;gm=0; if s=3 then rf=1;yf=0;gf=0; state =c;nclr:=0;en:=0; Else staterm=1;ym=0;gm=0; if s=g then rf=0;yf=0;gf=1; state =d;nclr:=0;en:=0; Else staterm=1;ym=0;gm=0; if s=3 then rf=0;yf=1;gf=0; state =a;nclr:=0;en:=0

9、; Else stateclr,CLK=clk,q=Q); u2: kongzhi port map(i=i,j=j,k=k,clk=Q,rm=rm,ym=ym,gm=gm1,rf=rf, yf=yf,gf=gf); u3:count_down port map(RE,CLK,ena_1Hz_1,recount_1,load,S,next_state_1); NEXT_S=next_state_1; end architecture JTD; 第 - 10 - 页 共 14 页 分频器代码 library ieee; use ieee.std_logic_1164.all; use ieee.

10、std_logic_arith.all; use ieee.std_logic_unsigned.all; entity fenpingqi is port (CLR,CLK:in std_logic ; q:buffer std_logic); end fenpingqi; architecture one of fenpingqi is signal counter:integer range 0 to 4999999; Begin process (CLR,CLK) Begin if(CLK=1 and CLKevent) then if CLR=1 then counter=0; el

11、sif counter =4999999 then counter=0; q=not q; else counter=counter+1; end if; end if; end process; end one; 3、交通灯控制器代码 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity kongzhi is port (clk,i,j,k:in std_logic; rm,ym,gm,rf,yf,gf:out std_l

12、ogic); end kongzhi; architecture arc of kongzhi is type state_type is (a,b,c,d); signal state:state_type; signal x:std_logic_vector(2 downto 0); Begin x=i&j&k; cnt:process (clk) variable s:integer range 0 to 49; variable g:integer range 0 to 49; variable nclr,en:bit; Begin 第 - 11 - 页 共 14 页 if x=001

13、then g:=29; elsif x=010then g:=39; elsif xrm=0;ym=0;gm=1; rf=1;yf=0;gf=0; if s=g then state =b;nclr:=0;en:=0; Else staterm=0;ym=1;gm=0; rf=1;yf=0;gf=0; if s=3 then state =c;nclr:=0;en:=0; Else staterm=1;ym=0;gm=0; rf=0;yf=0;gf=1; if s=g then state =d;nclr:=0;en:=0; Else staterm=1;ym=0;gm=0; rf=0;yf=

14、1;gf=0; if s=3 then state =a;nclr:=0;en:=0; Else state=d;nclr:=1;en:=1; end if; end case; end if; end process cnt; end arc; 第 - 12 - 页 共 14 页 4、两位七段译码输出显示代码 LIBRAYR IEEE; USE IEEE.std_logic_1164.all; USE IEEE.std_logic_arith.all; USE IEEE.std_logic_unsigned.all; ENTITY count_down IS port(reset, clk,

15、 ena_1Hz, recount: in std_logic; load: in std_logic_vector(7 downto 0); seg7:out std_logic_vector(15 downto 0); next_state: out std_logic); end; ARCHITECTURE BEHAVIOR of count_down IS signal cnt_ff:std_logic_vector(7 downto 0); begin count:process(clk,reset) begin if (reset=1) then cnt_ff=00000000;

16、seg7=0000000000000000; elsif (clkevent and clk=1) then if ena_1Hz=1 then if (recount=1) then cnt_ff=load-1; else cnt_ffseg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 dow

17、nto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(

18、15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)seg7(15 downto 0)=0011111100111111; end case; end if; end process; next_state = 1 when cnt_ff=1 else 0; end BEHAVIOR; 第 - 14 - 页 共 14 页

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号