eda课程实训设计交通信号灯设计实现doc.docx

上传人:b****8 文档编号:9357076 上传时间:2023-02-04 格式:DOCX 页数:19 大小:45.97KB
下载 相关 举报
eda课程实训设计交通信号灯设计实现doc.docx_第1页
第1页 / 共19页
eda课程实训设计交通信号灯设计实现doc.docx_第2页
第2页 / 共19页
eda课程实训设计交通信号灯设计实现doc.docx_第3页
第3页 / 共19页
eda课程实训设计交通信号灯设计实现doc.docx_第4页
第4页 / 共19页
eda课程实训设计交通信号灯设计实现doc.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

eda课程实训设计交通信号灯设计实现doc.docx

《eda课程实训设计交通信号灯设计实现doc.docx》由会员分享,可在线阅读,更多相关《eda课程实训设计交通信号灯设计实现doc.docx(19页珍藏版)》请在冰豆网上搜索。

eda课程实训设计交通信号灯设计实现doc.docx

eda课程实训设计交通信号灯设计实现doc

交通灯的设计与实现

一、实训目的

提高学生动手编程能力和对EDA可编程逻辑器件课程在实际生活中的应用的能力。

2、实训内容及要求

在EDA实验箱上完成十字路口交通灯的设计与实现。

要求将实验箱上的8个LED灯中的6个表示东西方向和南北方向的红黄绿交通灯。

同时在数码管上显示等待时间,并在数秒后进行红绿灯的转换,可增加扩展功能。

3、实训软硬件简介

1.QuartusII8.0

QuartusII8.0是著名可编程逻辑器件生产商Altera的综合性开发软件,在21世纪推出,可以在XP,linux,unix上使用,已取代MAX+PLUSⅡ,它提供了一种与结构无关的设计与环境,使设计者能方便地进行设计输入、快速处理和器件编程。

其便于其支持的硬件描述语言有VHDL、Verilog等,解决了原理图与HDL混合输入设计的问题。

编译仿真检测无误后,便可以下载信息通过编程器下载至目标器件中了。

2.EDA综合实验箱

综合实验箱可分为实验主板和可编程逻辑器件核心两部分,可编程逻辑器件核心板可以按需更换,以满足不同要求。

实验箱主要具有以下几个特点:

★实验箱电路动态可重组:

可按需配置成不同连接,以满足不同实验项目的需要

★可独立支持MCS—51单片机实验:

具有仿真功能,不需要额外配备昂贵的仿真器。

★可独立完成可编程逻辑器件实验:

可按需更换不同芯片模板,满足不同实验需要;

★提供了扩展接口:

让学生可以设计自己的电路连接到试验箱;

★灵活支撑综合性、创造性实验:

有利于训练学生综合创新能力。

综合实验箱采用模式化结构,可以通过不同的模式选择是进行单片机实验还是可编程实验。

通过主控电路选择左侧的单片机或者是下侧的可编程器件,选择需要的外围资源。

主要硬件资源由三个部分构成:

单片机资源、可编程逻辑器件资源、以及一些常用外设资源。

4、实训设计思想

1.设计效果

将实训要求和实际生活中的交通信号灯状态相结合,本系统设计实现数码管实时显示东西和南北两个方向的交通信号灯的通行和等待的剩余时间,在实验箱的LED灯中选取6个灯分别代表两个方向的红绿黄灯同时与数码管显示的时间相对应,为了防止出现交通灯出现临时性错误,设计一个复位键,以能够及时恢复至正常状态。

因深夜时车辆较少,故而设计一个按键在深夜时将交通灯全部变为黄灯闪烁,提醒车辆减速行驶。

2.程序代码设计思想

经过分析,交通信号灯在正常情况下分为6个状态,同时增加两种特殊情况下出现的两种状态;本系统运用状态机,将系统频率clk通过分频器分频,实现了LED灯的闪烁和数码管的显示功能,同时增加了两个额外特殊情况处理功能,成功模拟了现实生活中的交通信号灯的运作状况。

(1)分频设计

因数码管和LED灯的显示频率不同,故需要对系统clk进行分频,分频器实现的是将高频时钟信号转换成低频的时钟信号,用于触发控制器、计数器和扫描显示电路。

该分频器实现的是一千分频,将一千赫兹的时钟信号分频成一赫兹的时钟信号。

图1分频器部分原理图

(2)状态机设计

根据要实现的功能及各状态之间的转换经分析,正常状态下交通信号灯可以分为4个状态分别为表一中的S1、S2、S3、S4,在出现特殊情况或者在深夜时,状态转移分别是S5、S6,各状态之间持续时间详见表一,状态转移图详见图2.。

表1交通信号各灯状态详细表

交通灯

东西方向

南北方向

持续

时间

状态

红(led7)

黄(led6)

绿(led5)

红(led2)

黄(led1)

绿(led0)

S1

1

0

0

0

0

1

12

S2

1

0

0

0

1

0

4

S3

0

0

1

1

0

0

12

S4

0

1

0

1

0

0

4

S5

1

0

0

1

0

0

/

S6

0

1

0

0

1

0

/

(3)显示模块设计

串行连接,即每个数码管对应的引脚都连接在一起,通过控制公共端为高电平控制相应数码管的亮,灭(共阴极数码管的公共端为高电平时,LED不亮;共阳极的公共端为低电平时,LED不亮)

5、实训步骤及仿真结果

1.实训步骤

·设计输入:

使用原理图、硬件描述语言(VHDL、AHDL、VerilogHDL)等设计文件对待设计的功能做设计图。

·综合:

将硬件描述语言翻译成由逻辑门、触发器、寄存器等组成的电路结构。

·布局布线:

利用综合后的网表文件,将逻辑和时序要求映射到目标器件中,进行目标器件逻辑资源的分配、布线、互联等。

·仿真:

利用软件,验证设计的正确性。

仿真分为功能仿真和时序仿真,功能仿真仅验证逻辑功能,不包含时延信息。

·时序分析:

观察和报告时序信息,并可进行时序约束。

主要参数有:

建立时间(tsu)、保持时间(th)、时钟至输出延时(tco)、引脚至引脚延时(tpd)、最大时钟频率(fmax)等.

·编程和配置:

设计流程的最后一步,将软件产生的配置文件下载到目标器件中,进行硬件的实现和验证。

2.时序仿真

 

3.硬件仿真

在完成设计输入及成功编译、仿真后经编译无错后,设置pins锁定引脚,(详见管脚分配表2),经过硬件检验,可以实现如下功能:

1)在交通信号灯开始工作前,等待系统指令。

2)按下key0键,系统切换至正常工作,交通信号灯在正常的顺序下开始闪烁,同时数码管可以实时显示剩余等待时间。

3)按下key1键,系统切换至红灯状态,目的为了在交通事故出现后及时进行事故处理。

4)按下key2键,系统切换至深夜工作状态,全部亮黄灯提醒,过往车辆慢速行驶。

表2管脚分配表

原理图

Mode5

EP3C10E144

原理图

Mode5

EP3C10E144

PIO0

CLK1

PIN38

PIO26

SEG3

PIN74

/

SW0

PIN86

PIO27

SEG4

PIN75

PIO15

LED0

PIN60

PIO28

SEG5

PIN76

PIO16

LED1

PIN64

PIO29

SEG6

PIN77

PIO17

LED2

PIN65

PIO30

SEG7

PIN79

PIO18

LED3

PIN66

PIO31

DIG0

PIN80

PIO19

LED4

PIN67

PIO32

DIG1

PIN83

PIO20

LED5

PIN68

PIO33

DIG2

PIN84

PIO21

LED6

PIN69

PIO34

DIG3

PIN85

PIO22

LED7

PIN70

PIO35

DIG4

PIN4

PIO23

SEG0

PIN71

PIO36

DIG5

PIN3

PIO24

SEG1

PIN72

PIO37

DIG6

PIN2

PIO25

SEG2

PIN73

PIO38

DIG7

PIN1

6、实训总结

在这次EDA实训中,我们充分运用了上学期学习的知识,将分频器和状态机等知识融入其中,实现了更加智能化的交通灯系统设计,程序代码更易扩展。

通过一个星期的实训,我们对于交通灯的控制原理有了清晰的了解,进一步加深了EDA程序设计的熟练程度。

对QuartusII8.0仿真工具使用更加得心应手。

这次实训,我们分工明确,积极配合,体现了团队协作的精神,圆满完成了实训任务。

附录

(十字路口交通灯程序代码)

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

useieee.std_logic_arith.all;

entityjtdis

port(clock:

instd_logic;

reset,reset1,reset2:

instd_logic;

seg_out:

outstd_logic_vector(7downto0);

q_out:

outstd_logic_vector(7downto0);

w:

outstd_logic_vector(7downto0)

);

end;

architecturebhvofjtdis

componentqhz_any

port(clk:

instd_logic;

Q:

outstd_logic

);

endcomponent;

componentqhz_any1

port(clk:

instd_logic;

Q:

outstd_logic

);

endcomponent;

componentjsq0123

port(clk:

instd_logic;

Q:

outstd_logic_vector(1downto0));

endcomponent;

componentmux21a

port(s:

instd_logic_vector(1downto0);

a,b,c,d:

instd_logic_vector(7downto0);

y:

outstd_logic_vector(7downto0);

w1:

outstd_logic_vector(7downto0)

);

endcomponent;

componenttraffic

port(clk:

instd_logic;

rst,rst1,rst2:

instd_logic;

times:

outintegerrange0to100;

q:

outstd_logic_vector(7downto0);

shi0,shi1:

outstd_logic_vector(7downto0);

ge0,ge1:

outstd_logic_vector(7downto0)

);

endcomponent;

signalm1:

std_logic;

signalm2:

std_logic;

signalm3:

integerrange0to100;

signalm4:

std_logic_vector(7downto0);

signalm5:

std_logic_vector(7downto0);

signalm6:

std_logic_vector(1downto0);

signalm7:

std_logic_vector(7downto0);

signalm8:

std_logic_vector(7downto0);

begin

u1:

qhz_anyportmap(clk=>clock,Q=>m1);

u2:

qhz_any1portmap(clk=>clock,Q=>m2);

u3:

jsq0123portmap(clk=>m2,Q=>m6);

u4:

trafficportmap(clk=>m1,q=>q_out,rst=>reset,rst1=>reset1,rst2=>reset2,ge0=>m4,shi0=>m5,ge1=>m7,shi1=>m8);

u5:

mux21aportmap(a=>m4,b=>m5,c=>m7,d=>m8,y=>seg_out,s=>m6,w1=>w);

endbhv;

-------------miaofenpin-----------

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityqhz_anyis

generic(n:

integer:

=20000);

port(clk:

instd_logic;

Q:

outstd_logic);

endqhz_any;

architecturebhvofqhz_anyis

begin

process(clk)

variablecout:

integer:

=0;

begin

ifclk'eventandclk='1'then

ifcout<(n/2)then

Q<='1';cout:

=cout+1;

elsifcout<(n-1)then

Q<='0';cout:

=cout+1;

elsecout:

=0;

endif;

endif;

endprocess;

endbhv;

-------------jishuqi0123-----------

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityjsq0123is

port(clk:

instd_logic;

Q:

outstd_logic_vector(1downto0));

endjsq0123;

architecturebhvofjsq0123is

signalcqi:

std_logic_vector(1downto0);

begin

process(clk)

begin

ifclk'eventandclk='1'then

cqi<=cqi+1;

endif;

endprocess;

Q<=cqi;

endbhv;

----------------scanfenpin-----------

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityqhz_any1is

generic(n:

integer:

=20);

port(clk:

instd_logic;

Q:

outstd_logic);

endqhz_any1;

architecturebhvofqhz_any1is

begin

process(clk)

variablecout:

integer:

=0;

begin

ifclk'eventandclk='1'then

ifcout<(n/2)then

Q<='1';cout:

=cout+1;

elsifcout<(n-1)then

Q<='0';cout:

=cout+1;

elsecout:

=0;

endif;

endif;

endprocess;

endbhv;

--------------------traffic-------------

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

entitytrafficis

port(clk:

instd_logic;

rst,rst1,rst2:

instd_logic;

times:

outintegerrange0to100;

q:

outstd_logic_vector(7downto0);

shi0,ge0,ge1,shi1:

outstd_logic_vector(7downto0));

endtraffic;

architecturebhvoftrafficis

signalcnt0,cnt1:

integerrange0to100;

signall10,l20,l11,l21:

integerrange0to9;

typestate_valueis(s1,s2,s3,s4,s5,s6);

signalstate:

state_value;

begin

process(clk,rst,rst1,rst2)

begin

ifrst='0'then

state<=s1;--S,NtravelE,Wstop

cnt0<=11;

cnt1<=7;

q<="10000001";

elsifrst1='0'then

state<=s5;

cnt1<=00;

cnt0<=00;

q<="10001000";

elsifrst2='0'then

state<=s6;

cnt1<=00;

cnt0<=00;

q<="01000010";

elsifrising_edge(clk)then

casestateis

whens1=>--s1

ifcnt1=0then

state<=s2;

q<="10000010";

cnt0<=3;

cnt1<=3;

else

state<=s1;

cnt0<=cnt0-1;

cnt1<=cnt1-1;

endif;

whens2=>--s2

ifcnt1=0then

state<=s3;

q<="00100100";

cnt1<=11;

cnt0<=7;

else

state<=s2;

cnt1<=cnt1-1;

cnt0<=cnt0-1;

endif;

whens3=>--s3

ifcnt1=4then

state<=s4;

q<="01000100";

cnt0<=3;

cnt1<=3;

else

state<=s3;

cnt1<=cnt1-1;

cnt0<=cnt0-1;

endif;

whens4=>--s4

ifcnt1=0then

state<=s1;

cnt0<=11;

cnt1<=7;

q<="10000001";

else

state<=s4;

cnt0<=cnt0-1;

cnt1<=cnt1-1;

endif;

whens5=>--s4

state<=s5;

cnt0<=00;

cnt1<=00;

whens6=>--s4

state<=s6;

cnt0<=00;

cnt1<=00;

endcase;

--endif;

endif;

endprocess;

l10<=cnt0/10;l20<=cnt0rem10;----JISUANSHIWEI;GEWEI

l11<=cnt1/10;l21<=cnt1rem10;----JISUANSHIWEI;GEWEI

process(l10)

begin

casel10is-------XIANSHISHIWEI

when0=>shi0<="00111111";--0

when1=>shi0<="00000110";--1

when2=>shi0<="01011011";--2

when3=>shi0<="01001111";--3

when4=>shi0<="01100110";--4

when5=>shi0<="01101101";--5

when6=>shi0<="01111101";--6

when7=>shi0<="00000111";--7

when8=>shi0<="01111111";--8

when9=>shi0<="01101111";--9

endcase;

endprocess;

process(l20)

begin

casel20is--------XIANSHIGEWEI

when0=>ge0<="00111111";--0

when1=>ge0<="00000110";--1

when2=>ge0<="01011011";--2

when3=>ge0<="01001111";--3

when4=>ge0<="01100110";--4

when5=>ge0<="01101101";--5

when6=>ge0<="01111101";--6

when7=>ge0<="00000111";--7

when8=>ge0<="01111111";--8

when9=>ge0<="01101111";--9

endcase;

endprocess;

process(l11)

begin

casel11is-------XIANSHISHIWEI

when0=>shi1<="00111111";--0

when1=>shi1<="00000110";--1

when2=>shi1<="01011011";--2

when3=>shi1<="01001111";--3

when4=>shi1<="01100110";--4

when5=>shi1<="01101101";--5

when6=>shi1<="01111101";--6

when7=>shi1<="00000111";--7

when8=>shi1<="01111111";--8

when9=>shi1<="01101111";--9

endcase;

endprocess;

process(l21)

begin

casel21is--------XIANSHIGEWEI

when0=>ge1<="00111111";--0

when1=>ge1<="00000110";--1

when2=>ge1<="01011011";--2

when3=>ge1<="01001111";--3

when4=>ge1<="01100110";--4

when5=>ge1<="01101101";--5

when6=>ge1<="01111101";--6

when7=>ge1<="00000111";--7

when8=>ge1<="01111111";--8

when9=>ge1<="01101111";--9

endcase;

endprocess;

endbhv;

---------------------------2xuan1-----------

libraryieee;

useieee.std_logic_1164.all;

entitymux

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

当前位置:首页 > 幼儿教育 > 育儿理论经验

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1