最新交通灯控制系统EDA实验报告.docx
- 文档编号:27312183
- 上传时间:2023-06-29
- 格式:DOCX
- 页数:10
- 大小:16.68KB
最新交通灯控制系统EDA实验报告.docx
《最新交通灯控制系统EDA实验报告.docx》由会员分享,可在线阅读,更多相关《最新交通灯控制系统EDA实验报告.docx(10页珍藏版)》请在冰豆网上搜索。
最新交通灯控制系统EDA实验报告
?
交通灯控制系统EDA实验报告2021
姓名:
学号:
一、课题名称用状态机设计的交通信号控制系统。
二、实验目的利用所学习的EDA相关知识,完成对交通灯控制系统的设计并实现,提高对所学知识的理解和利用熟练程度。
三、设计任务设计一个十字路口交通控制系统,要求如下:
a.东西〔用A表示〕、南北〔用B表示〕方向均有绿灯、黄灯、红灯指示,持续时间分别是40秒、五秒和45秒,交通灯运行的切换示意图与时间关系如下。
交通控制系统运行切换示意图
更方向灯光时间关系
b.系统设有时钟,以倒计时的方式显示每一路允许通行的时间。
c.当东西或南北两路中任意一路出现特殊状况时,系统可由交警手动控制立即进入特殊运行状态,即红灯全亮,始终停止计时,东西、南北两路所有车辆禁止通行;当特殊状况结束后,系统恢复工作,继续正常运行。
四、实验过程a.VHDL设计流程
b.交通控制系统顶层原理图如下,它主要由50MHz分频器〔devide50M〕、控制器〔control〕、45秒倒计时计数器〔m45〕、7字段译码器〔SEG7〕组成。
1)控制器的设计控制器的逻辑符号如以下图。
其中CLK为时钟输入信号;HOLD为紧急制动信号;ARED、AGREEN、AYELLOW分别为东西方向的红灯、绿灯、黄灯指示的输出信号;BRED、BGREEN、BYELLOW分别为南北方向的红灯、绿灯、黄灯指示的输出信号。
控制器的VHDL描述文件control.vhd如下:
libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;
entitycontrolis
port(clk,hold:
instd_logic;
ared,agreen,ayellow,bred,bgreen,byellow:
outstd_logic);endcontrol;
architecturebehaviorofcontrolis
typestate_typeis(s0,s1,s2,s3,s4);
signalcurrent_state,next_state:
state_type;
signalcounter:
std_logic_vector(6downto0);
beginsynch:
processbegin
waituntilclk'eventandclk='1';
ifhold='0'then
--当紧急制动信号有效时,计数器停止计数
counter<=counter;
else
ifcounter<89then
counter<=counter+1;
else
counter<=(others=>'0');
endif;
endif;
endprocess;
process
--待机状态begin
waituntilclk'eventandclk='1';
current_state<=next_state;endprocess;
state_trans:
process(current_state)begin
casecurrent_stateiswhens0=>
ifhold='0'then
next_state<=s4;
else
ifcounter<39then
next_state<=s0;
else
next_state<=s1;
endif;
endif;whens1=>
ifhold='0'then
next_state<=s4;
else
ifcounter<44then
next_state<=s1;
else
next_state<=s2;
endif;
endif;whens2=>
ifhold='0'then
next_state<=s4;
else
ifcounter<84then
next_state<=s2;
else
next_state<=s3;
endif;
endif;whens3=>
ifhold='0'then
next_state<=s4;
else
ifcounter<89then
next_state<=s3;
else
next_state<=s0;
endif;
endif;whens4=>
ifhold='0'then
next_state<=s4;
else
ifcounter<39then
next_state<=s0;
elsifcounter<44then
next_state<=s1;
elsifcounter<84then
next_state<=s2;
elsifcounter<89then
next_state<=s3;
endif;
endif;endcase;endprocess;
output:
process(current_state)
--每种状态下两个路口红绿灯的状态描述begincasecurrent_stateiswhens0=>
ared<='0';
agreen<='1';
ayellow<='0';
bred<='1';
bgreen<='0';
byellow<='0';whens1=>
ared<='0';
agreen<='0';
ayellow<='1';
bred<='1';
bgreen<='0';
byellow<='0';whens2=>
ared<='1';
agreen<='0';
ayellow<='0';
bred<='0';
bgreen<='1';
byellow<='0';whens3=>
ared<='1';
agreen<='0';
ayellow<='0';
bred<='0';
bgreen<='0';
byellow<='1';whens4=>
ared<='1';
agreen<='0';
ayellow<='0';
bred<='1';
bgreen<='0';
byellow<='0';endcase;endprocess;endbehavior;
2)倒计时计数器M45的设计倒计时计数器M45的逻辑符号如图。
其中CLK、EN、CR分别是时钟、计数使能和清零端,QL[3..0]、QH[3..0]、OC分别是BCD码的个位、十位和进位输出。
VHDL描述文件m45.vhd如下:
libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitym45isport(
CLK
:
instd_logic;
EN
:
instd_logic;
CR
:
instd_logic;
QL,QH:
outstd_logic_vector(3downto0);
OC
:
outstd_logic
);endm45;
architecturebehaveofm45is
signalcouL,couH:
std_logic_vector(3downto0);begin
process(CR,CLK,EN)
begin
ifCR='0'then
--异步清零
couL<=“0000“;
couH<=“0000“;
elsifclk'eventandclk='1'then
ifEN='1'then
if(couL=0andcouH=0)then
--减法计到00后,重新置数44
couL<=“0100“;
couH<=“0100“;
elsifcouL=0then
--否那么个位计到0时置为9,十位减1
couL<=“1001“;
couH<=couH-1;
else
couL<=couL-1;
--否那么个位减1
endif;
endif;
endif;
endprocess;
process(couL,couH)begin
if(couL=0andcouH=0)then
OC<='1';
--减到00时有借位输出
else
OC<='0';
endif;endprocess;
QL<=couL;
QH<=couH;endbehave;
3)7字段译码器电路的设计7字段译码器的功能是将8421BCD码译成7个信号,用以启动7段数码管显示相应的十进制数码,逻辑符号如图。
dat[3..0]是8421BCD码的输入,a、b、c、d、e、f、g是驱动数码管显示的7个输出信号〔低电平有效〕。
VHDL描述文件seg7.vhd如下:
libraryieee;useieee.std_logic_1164.all;
entityseg7isport(dat:
instd_logic_vector(3downto0);
a,b,c,d,e,f,g:
outstd_logic);
endseg7;
architecturearcofseg7issignaltmp:
std_logic_vector(6downto0);begin
process(dat)
begincasedatis
when“0000“=>tmp<=“0000001“;
--输入0000时,显示0
when“0001“=>tmp<=“1001111“;
--输入00001时,显示1
when“0010“=>tmp<=“0010010“;
when“0011“=>tmp<=“0000110“;
when“0100“=>tmp<=“1001100“;
when“0101“=>tmp<=“0100100“;
when“0110“=>tmp<=“0100000“;
when“0111“=>tmp<=“0001111“;
when“1000“=>tmp<=“0000000“;
when“1001“=>tmp<=“0000100“;
--显示9
when“1010“=>tmp<=“0001000“;
--显示A
when“1011“=>tmp<=“1100000“;
when“1100“=>tmp<=“0110001“;
when“1101“=>tmp<=“1000010“;
when“1110“=>tmp<=“0110000“;
when“1111“=>tmp<=“0111000“;endcase;endprocess;a<=tmp(6);b<=tmp(5);c<=tmp(4);d<=tmp(3);e<=tmp
(2);f<=tmp
(1);g<=tmp(0);endarc;
4)50MHz分频器的设计逻辑符号如图,目的是将输入信号转化为1HZ输出。
clk为信号输入端,clk_out为信号输出端。
VHDL描述文件devide50M.vhd如下:
libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitydevide50Misport(
clk
:
instd_logic;
clk_out:
outstd_logic
);enddevide50m;
architecturearc_devide50Mofdevide50Mis
signalcount:
std_logic_vector(25downto0);begin
process
begin
waituntilclk'eventandclk='1';
if(count<50000000)then
count<=count+1;
clk_out<='0';
else
count<=(others=>'0');
clk_out<='1';
endif;
endprocess;endarchitecturearc_devide50M;
c.管脚设计因为使用的是CycloneIII_EP3C16F484C6型号的电路板,因此管脚连接如下:
CycloneIII_EP3C16F484C6型号的电路板
管脚连接图
五、实验结果
波形仿真结果
六、实验心得通过这次设计,进一步加深了对VHDL语言的了解,让我对它有了更加浓厚的兴趣。
在文件编写的过程中,我遇到了不少问题,包括最开始的无从下手到各元件之间的连接,引脚的设定,但最终还是克服了这些困难。
建议以后的课程中将上机操作与课程理论教学相结合,这样也许就能够更好的帮助我们学习EDA。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 最新 交通灯 控制系统 EDA 实验 报告