课程设计EDA.docx
- 文档编号:18110636
- 上传时间:2023-08-13
- 格式:DOCX
- 页数:12
- 大小:169.58KB
课程设计EDA.docx
《课程设计EDA.docx》由会员分享,可在线阅读,更多相关《课程设计EDA.docx(12页珍藏版)》请在冰点文库上搜索。
课程设计EDA
EDA课程设计
实验报告
姓名:
sisi
学号:
2010210222
班级:
0222222
一.实验题目:
普通交通灯系统设计
二.实验目的
掌握电子设计自动化(EDA)的基本方法和相关软件(Quartus)的操作,了解程序开发的过程和细节,能够熟练的运用硬件描述语言(VHDL)进行图形设计和VHDL设计。
三.实验要求
(1).用红、绿、黄三色发光二极管作信号灯。
主干道为东西向,有红、绿、黄三个灯;支干道为南北向,也有红、绿、黄三个灯。
红灯亮禁止通行;绿灯亮允许通行;黄灯亮则给行驶中的车辆有时间停靠到禁行线之外。
(2).由于主干道车辆较多而支干道车辆较少,所以主干道绿灯时间较长。
当主干道允许通行亮绿灯时,支干道亮红灯。
而支干道允许通行亮绿灯时,主干道亮红灯,两者交替重复。
主干道每次放行50秒,支干道每次放行30秒。
在每次由亮绿灯变成亮红灯的转换过程中间,需要亮5秒的黄灯作为过渡,以使行驶中的车辆有时间停靠到禁行线以外。
(3).能实现正常的、即时显示功能。
用DE2上的四个七段数码管作为倒计时显示器。
分别显示东西、南北方向的红灯、绿灯、黄灯时间。
四.实验内容
1.设计方案:
(1).时钟信号周期设为1秒。
(2).用计数器(control)对时钟信号进行计时来达到对主干道、支干道的红黄绿信号灯亮灭时间的控制。
经计算可知,主干道和支干道的红黄绿灯的变化以90秒为周期规律变化,因为始终周期设为1S,所以,计数器(control)的计数最大值设为90。
(3).主干道、支干道的红黄绿信号灯分别用red0,yellow0,green0(主)和red1,yellow1,green1(干)输出信号来控制其亮灭。
(4).主干道和支干道分别用两位数码管来动态显示各色信号灯亮的时间的倒计时间。
2.实验源代码
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitysimiaois
port(
clk:
instd_logic;
zc:
instd_logic_vector(1downto0);
main_shi_display1:
outstd_logic_vector(6downto0);--xianshinageshu
main_ge_display1:
outstd_logic_vector(6downto0);
minor_shi_display:
outstd_logic_vector(6downto0);
minor_ge_display:
outstd_logic_vector(6downto0);
dig:
outstd_logic_vector(7downto0);--nageshumaguanxianshi
left0:
outstd_logic;
left1:
outstd_logic;
red0:
outstd_logic;
green0:
outstd_logic;
yellow0:
outstd_logic;
red1:
outstd_logic;
green1:
outstd_logic;
yellow1:
outstd_logic
);
endentitysimiao;
architecturebehvofsimaois
signalc:
std_logic_vector(20downto0);
signalcontrol:
integerrange100downto0;
signalclkr:
std_logic;
begin
dig<="00111111";
timer:
process(clk)--fenpinmokuai
begin
ifclk'eventandclk='1'then
c<=c+1;
if(c=250000)then
clkr<=notclkr;
endif;
endif;
endprocesstimer;
ti:
process(clkr)
begin
ifclkr'eventandclkr='1'then
ifcontrol<96then
control<=control+1;
else
control<=0;
endif;
endif;
endprocessti;
main:
process(control,zc)
variablen:
integerrange10000downto0;
begin
n:
=n+1;
ifzc=3then
casecontrolis
when0to50=>green0<='0';red0<='1';yellow0<='1';left0<='1';
green1<='1';red1<='0';yellow1<='1';left1<='1';
when51to55=>green0<='1';red0<='1';yellow0<='0';left0<='1';
green1<='1';red1<='0';yellow1<='1';left1<='1';
when56to65=>green0<='1';red0<='1';yellow0<='1';left0<='0';
green1<='1';red1<='1';yellow1<='1';left1<='0';
when66to90=>green0<='1';red0<='0';yellow0<='1';left0<='1';
green1<='0';red1<='1';yellow1<='1';left1<='1';
when91to95=>green0<='1';red0<='0';yellow0<='1';left0<='1';
green1<='1';red1<='1';yellow1<='0';left1<='1';
whenothers=>null;
endcase;
elseifzc=2then
ifn>50then
green0<='0';red0<='1';yellow0<='1';left0<='1';
green1<='1';red1<='0';yellow1<='1';left1<='1';
else
green0<='1';red0<='1';yellow0<='0';left0<='1';
green1<='1';red1<='0';yellow1<='1';left1<='1';
endif;
elseifzc=1then
ifn>50then
green0<='1';red0<='0';yellow0<='1';left0<='1';
green1<='0';red1<='1';yellow1<='1';left1<='1';
else
green0<='1';red0<='1';yellow0<='0';left0<='1';
green1<='1';red1<='0';yellow1<='1';left1<='1';
endif;
else
green0<='0';red0<='1';yellow0<='1';left0<='1';
green1<='1';red1<='0';yellow1<='1';left1<='1';
endif;
endif;
endif;
endprocessmain;
main_disp:
process(control)
variablecount:
integerrange90downto0;
variableTH:
integerrange9downto0;
variableTL:
integerrange9downto0;
begin
casecontrolis
when0=>count:
=50;
when51=>count:
=5;
when56=>count:
=10;
when66=>count:
=35;
whenothers=>null;
endcase;
TH:
=count/10;
TL:
=countrem10;
caseTHis
when0=>main_shi_display1<="1111110";
when1=>main_shi_display1<="0110000";
when2=>main_shi_display1<="1101101";
when3=>main_shi_display1<="1111001";
when4=>main_shi_display1<="0110011";
when5=>main_shi_display1<="1011011";
when6=>main_shi_display1<="1011111";
when7=>main_shi_display1<="1110000";
when8=>main_shi_display1<="1111111";
when9=>main_shi_display1<="1110011";
whenothers=>null;
endcase;
caseTLis
when0=>main_ge_display1<="1111110";
when1=>main_ge_display1<="0110000";
when2=>main_ge_display1<="1101101";
when3=>main_ge_display1<="1111001";
when4=>main_ge_display1<="0110011";
when5=>main_ge_display1<="1011011";
when6=>main_ge_display1<="1011111";
when7=>main_ge_display1<="1110000";
when8=>main_ge_display1<="1111111";
when9=>main_ge_display1<="1110011";
whenothers=>null;
endcase;
count:
=count-1;
endprocessmain_disp;
minor_disp:
process(control)
variablecount:
integerrange90downto0;
variableTH:
integerrange9downto0;
variableTL:
integerrange9downto0;
begin
casecontrolis
when0=>count:
=55;
when56=>count:
=10;
when66=>count:
=25;
when91=>count:
=5;
whenothers=>null;
endcase;
TH:
=count/10;
TL:
=countrem10;
caseTHis
when0=>minor_shi_display<="0111111";
when1=>minor_shi_display<="0000110";
when2=>minor_shi_display<="1011011";
when3=>minor_shi_display<="1001111";
when4=>minor_shi_display<="1100110";
when5=>minor_shi_display<="1101101";
when6=>minor_shi_display<="1111101";
when7=>minor_shi_display<="0000111";
when8=>minor_shi_display<="1111111";
when9=>minor_shi_display<="1100111";
whenothers=>null;
endcase;
caseTLis
when0=>minor_ge_display<="0111111";
when1=>minor_ge_display<="0000110";
when2=>minor_ge_display<="1011011";
when3=>minor_ge_display<="1001111";
when4=>minor_ge_display<="1100110";
when5=>minor_ge_display<="1101101";
when6=>minor_ge_display<="1111101";
when7=>minor_ge_display<="0000111";
when8=>minor_ge_display<="1111111";
when9=>minor_ge_display<="1100111";
whenothers=>null;
endcase;
count:
=count-1;
endprocessminor_disp;
endarchitecture;
3.原理图
4.实验仿真
说明:
(1).因为主干道和支干道的红黄绿灯是以90秒为周期变化,所以,可以用一个周期内的特殊时间段来表述交通灯的变化规律。
(2).因为在时钟的第一个上升沿(即0.5S)开始计时,所以在仿真结果中表征交通灯亮灭的时间段应为仿真时间减去0.5S。
(3).试验中主干道和支干道分别用到了数码管来计时,以下仿真中
并没有将其呈现。
1.主干道:
在同一时刻,每个干道只能有一个信号灯亮,所以可以用以下时间段来表征:
0至50S,绿灯亮;50至55S,黄灯亮;55至90S,红灯亮。
(1).50.5S,主干道由绿灯亮变为黄灯亮
(2).55.5S时,主干道由黄灯亮变为红灯亮
(3).90.5S时,主干道由红灯亮变为绿灯亮
2.支干道:
0至55S时,红灯亮;55至85S时,绿灯亮;85至90S时,黄灯亮。
(1).55.5S时,支干道由红灯亮变为绿灯亮
(2).85.5S时,支干道由绿灯亮变为黄灯亮
(3).90.5S时,支干道由黄灯亮变为红灯亮
最后呈现以下整个仿真图
五.心得体会
1.在确定做哪个实验过程中花费了很多时间,开始做了电梯发现做不出来,找不出程序的错误,于是换成交通灯。
2.在编程的时候应该着重之一时序。
在编程过程中,忽略了时序的关联问题,导致实际运行结果和我想象的结果不一致。
3.做不出来需要虚心请教他人,很多问题自己不明白只要问问他人就能迅速解出,然后记住,变成自己的知识。
4.程序太过繁杂,需要进一步进行优化。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 课程设计 EDA