dx交通灯课程设计报告(EDA)

更新时间:2024-03-14 05:07:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

数字电路课程设计报告

JIANGSU TEACHERS UNIVERSITY OF TECHNOLOGY

交 通 灯 设 计

学 院 名 称: 东方学院 专 业: 电子信息工程 班 级: 0 9 电 子 B

第 1 页 共 28 页

数字电路课程设计报告

数字电路课程设计报告

姓 名: 窦 湘 学 号: 09816104 指导教师姓名: 樊寅逸

2010 年 4 月

目 录

序言······················································3 第

求·········································4 1.1

务························································4 1.

2

求························································4

第二章 电路工作原理及方案设计·····························4 第三章 单元电路设计与仿真·································6 3.1

图······················································6

第 2 页 共 28 页

数字电路课程设计报告

3.2 各模块的原理及其程

序············································6 3.2.1

仿

图········································6 3.2.2

仿

图········································7 3.2.3

仿

图········································9 3.2.4

仿

图········································10 3.2.5

仿

图········································11

第四章 系统设计··········································12 4.1

计···················································12 4.2

仿

图··············································13

第五章 总结··············································13 参考文献·················································14 附录·····················································14

第 3 页 共 28 页

数字电路课程设计报告

序言

CPLD(Complex Programmable Logic Device)是Complex PLD的简称,一种较PLD为复杂的逻辑元件。CPLD是一种用户根据各自需要而自行构造逻辑功能的数字集成电路。其基本设计方法是借助集成开发软件平台,用原理图、硬件描述语言等方法,生成相应的目标文件,通过下载电缆(“在系统”编程)将代码传送到目标芯片中,实现设计的数字系统。

20世纪70年代,最早的可编程逻辑器件--PLD诞生了。其输出结构是可编程的逻辑宏单元,因为它的硬件结构设计可由软件完成,因而它的设计比纯硬件的数字电路具有很强的灵活性,但其过于简单的结构也使它们只能实现规模较小的电路。为弥补PLD只能设计小规模电路这一缺陷,20世纪80年代中期,推出了复杂可编程逻辑器件--CPLD。目前应用已深入网络、仪器仪表、汽车电子、数控机床、航天测控设备等方面。

它具有编程灵活、集成度高、设计开发周期短、适用范围宽、开发工具先进、设计制造成本低、对设计者的硬件经验要求低、标准产品无需测试、保密性强、价格大众化等特点,可实现较大规模的电路设计,因此被广泛应用于产品的原型设计和产品生产(一般在10,000件以下)之中。几乎所有应用中小规模通用数字集成电路的场合均可应用CPLD器件。CPLD器件已成为电子产品不可缺少的组成部分,它的设计和应用成为电子工程师必备的一种技能。

随着基于CPLD的EDA技术的发展和应用领域的扩大与深入,EDA

第 4 页 共 28 页

数字电路课程设计报告

技术在电子信息、通信、自动控制用计算机等领域的重要性日益突出。作为一个学电子信息专业的学生,我们必须不断地了解更多的新产品信息,这就更加要求我们对EDA有个全面的认识。本程序设计的是交通灯的设计。采用EDA作为开发工具,VHDL语言为硬件描述语言,quartusII作为程序运行平台,所开发的程序通过调试运行、波形仿真验证,初步实现了设计目标

在一个交通繁忙的十字路口,没有交通灯来控制来往车辆和行人的通行,假设也没有交警,那会发生什么事情呢?后果是难以想象的,可能会陷入一片混乱,甚至瘫痪。当然我们每个人都不希望这样。我们作为社会的一员,每人都有责任为它的更加先进和快捷做出力所能及的事情。我们设计的这个信号控制系统可以通过交通灯控制东西方向车道和南北方向车道两条交叉道路上的车辆交替运行,每次通行时间都可以根据实际情况预设,用以减少交通事故的发生概率。并且经过些次实验使得我们对电子技术课程内容的理解和掌握有了更深一层的认识,也学会使用半导体元件和集成电路,掌握电子电路的基本分析方法和设计方法,进一步提高分析解决实际问题的综合能力,也为将来的就业或继续深造做好准备。

第一章 设计任务与要求

1.1 设计任务

设计一个基于FPGA的十字路口交通控制器,分为手动操作、自

第 5 页 共 28 页

数字电路课程设计报告

动操作和复位系统,假设南北方向和东西方向,两个方向分别设置红灯、绿灯、黄灯和左拐四盏灯,每个方向设置一组倒计时显示器,用以指挥车辆和行人有序的通行。红灯亮表示左转和直行车辆禁行;绿灯亮表示直行车辆可以通行;黄灯亮表示左转或直行车辆即将禁行;左拐灯亮表示左转车辆可以通行;倒计时显示器用来显示允许通行或禁止通行的时间 。

1.2 设计要求

1 在十字路口南北和东西两个方向各设一组红灯、绿灯、黄灯和左拐灯。显示顺序:绿灯→ 黄灯→ 红灯→ 左拐→ 黄灯→ 红灯。在南北和东西两个方向各设一组倒计时显示器。

2 自动控制:设置一组数码管,以倒计时的方式显示允许通行或禁止通行的时间,南北方向为主干道,左拐、绿灯、黄灯和红灯显示时间分别是20s、20s、5s和20s。东西方向为次干道,左拐、绿灯、黄灯和红灯显示时间分别为15s、15s、5s和25s。

3 手动控制:按按钮依次执行以上显示状态,绿灯→ 黄灯→ 红灯→ 左拐→ 黄灯→ 红灯,倒计时显示为“0”。

4 系统设有总复位开关,可在任意时间内对系统进行复位。 5 通过开关按钮切换交通灯的工作状态。

第二章 电路工作原理及方案设计

第 6 页 共 28 页

数字电路课程设计报告

交通灯的显示状态: 绿 黄 红

红 总体框图:

Cond Resetd Con1d 计数值 左拐 黄 红

绿

左拐

计数器 控制器 发光二极管 倒计时数字显示 七段数码管 Clkd 分频电路 分位电路 译码电路

在VHDL设计描述中,采用自顶向下的设计思路,该思路,首先要描述顶层的接口,上面的描述已经规定了交通灯控制的输入输出信号:输入信号:复位开关信号reset;外部时钟信号clk。LED七段显示数码管的输出信号count1(6 downto 0),count2(6 downto 0),count3(6 downto 0),count4(6 downto 0);在自顶向下的VHDL设计描述中,通常把整个设计的系统划分为几个模块,然后采用结构描

第 7 页 共 28 页

数字电路课程设计报告

述方式对整个系统进行描述。根据实验设计的结构功能,来确定使用哪些模块以及这些模块之间的关系。通过上面的分析,不难得知可以把交通灯控制系统划分为4个模块:时钟分频模块,计数模块,控制模块,分位译码模块。

分频电路:把555多谐振荡器发出的较高频率脉冲用分频电路的到较第频率的时钟信号,本电路通过三次10分平分别得到10Hz、1Hz的时钟信号。

控制器电路:根据计数器的计数值控制发光二极管的亮、灭,以及输出倒计时数值给七段译码管的分位译码电路。当检测到手动控制信号(Con=’1’)时,执行手动控制;

计数器电路:这里需要的计数器的计数范围为0~89。计到89后,下一个时钟沿升为1时,开始下一轮计数,此外当系统复位信号(Reset=’1’)使计数器异步清‘0’。手动信号(Con=’1’)使系统清‘0’。

分位译码电路:因为控制器输出的倒计时数值可能是1位或者2位十进制数,所以在七段数码管的译码电路前要加上分位电路(即将其分为2个1位的十进制数,如20分为2和0,7分为0和7)。七段数码管的译码电路根据控制电路的控制信号,驱动交通灯的显示,通过输入二进制数值,输出信号点亮二极管,我们用的是共阳极数码管,因此译码电路输出逻辑数值‘0’点亮二极管,译码电路输出逻辑数值‘1’熄灭二极管。

第 8 页 共 28 页

数字电路课程设计报告

第三章 单元电路设计与仿真

3.1 软件原理图

3.2 各模块的原理及其程序

3.2.1 分频模块的设计及仿真图

clk_10clkclk_div10实体:entity clk_10 is

port( clk : in std_logic;

clk_div10 : out std_logic);

instend clk_10;

功能:实现十分频 接口:clk—脉冲输入

第 9 页 共 28 页

数字电路课程设计报告

Clk-div10—十分频后脉冲输出 仿真结果如下:

3.2.2 计数模块的设计及仿真图

实体:entity counter

counterclk0conresetinstcountnum[6..0]is

port( clk0:in std_logic; con:in std_logic; reset:in std_logic;

countnum:buffer integer range 0 to 89);

end counter;

功能:实现0到89的计数 clk0—脉冲输入 con—手动控制信号 reset—复位信号

第 10 页 共 28 页

数字电路课程设计报告

countnum—计数输出

仿真波形如下:

第 11 页 共 28 页

数字电路课程设计报告

3.2.3 控制模块的设计及仿真图

controllerclk1con1con2countnum[6..0]numa[4..0]numb[4..0]ragayaga1rbgbybgb1实体:entity controller is Port ( clk1 : in std_logic;

con1 : in std_logic; con2 : in std_logic;

countnum : in integer range 0 to 89; numa,numb : out integer range 0 to 25; ra,ga,ya,ga1 : out std_logic;

inst rb,gb,yb,gb1: out std_logic); end controller;

功能:控制发光二极管的亮、灭,以及输出倒计时数值给七段译码管的分位译码电路。 clk1—脉冲信号输入 con1—手动控制信号

第 12 页 共 28 页

数字电路课程设计报告

con2—状态控制信号 countnum—计数输入

numa,numb—两个方向的倒计时数值输出 ra,ga,ya,ga1,rb,gb,yb,gb1—发光二极管输出

仿真波形如下:

第 13 页 共 28 页

数字电路课程设计报告

3.2.4 分位模块的设计与仿真图

fenweinumin[4..0]numa[3..0]numb[3..0]实体:entity fenwei is

port ( numin:in integer range 0 to 25;

inst numa,numb:out integer range 0

to 9 );

end fenwei;

功能:把倒计时的数值分成2个1位的十进制数。 numin:倒计时数值输入

numa,numb—将数值分为2个1位的十进制输出

仿真波形如下:

3.2.5 译码模块的设计及仿真图

第 14 页 共 28 页

数字电路课程设计报告

clk2:in std_logic;

bb: in std_logic_vector(3

yimaclk2yabb[3..0]ybycydyeyfyginst

实体:entity display is port( 仿真波形如下:

downto 0);

ya:out std_logic; yb:out std_logic; yc:out std_logic; yd:out std_logic; ye:out std_logic; yf:out std_logic; yg:out std_logic);

end display;

功能:根据控制电路的控制信号,驱动交通灯的显示, 通过输入二进制数值,输出信号点亮二极管。 bb[3..0]--BCD码输入 clk2—脉冲输入

ya,yb,yc,yd,ye,yf,yg—七段数码管显示输出

第 15 页 共 28 页

数字电路课程设计报告

第四章 系统设计

4.1 顶层文件的设计

dingcengclkdresetdcondcon1dcount1[6..0]count2[6..0]count3[6..0]count4[6..0]redagreenayellowagreena1redbgreenbyellowbgreenb1

entity dingceng is

port(clkd,resetd,cond,con1d:in std_logic; count1:out std_logic_vector(6 downto 0); count2:out std_logic_vector(6 downto 0); count3:out std_logic_vector(6 downto 0); count4:out std_logic_vector(6 downto 0); reda,greena,yellowa,greena1:

out

inststd_logic;

redb,greenb,yellowb,greenb1: out std_logic); end entity dingceng;

clkd—脉冲输入 resetd—复位信号

第 16 页 共 28 页

数字电路课程设计报告

con—手动控制信号 con1d—状态控制信号

count1,count2,count3,count4—七段数码管显示

reda,greena,yellowa,greena1,redb,greenb,yellowb,greenb1—发光二极管输出

4.2 整体电路波形图

第五章 总结

课程设计对学生而言是其对所学课程内容掌握情况的一次自我验证,从而有着极其重要的意义。通过课程设计能提高学生对所学知识的综合应用能力,能全面检查并掌握所学内容,本学期我们进行了数字电路课程设计,老师命题,六人一大组,两人一小组进行设计(包

第 17 页 共 28 页

数字电路课程设计报告

括设计总体方案、硬件电路、软件设计、焊接、调试等工作)。趣味性强,同时也可以学到很多东西。我们做的是交通灯控制器的设计。

在这学期的课程设计中,在收获知识的同时,还收获了阅历,收获了成熟,在此过程中,我们通过查找大量资料,请教老师,以及不懈的努力,不仅培养了独立思考、动手操作的能力,在各种其它能力上也都有了提高。更重要的是,我们学会了很多学习的方法。而这是日后最实用的,真的是受益匪浅。要面对社会的挑战,只有不断的学习、实践,再学习、再实践。

通过这个程序设计让我学会一种新的语言,对数字系统结构也有了更进一步的了解和认识,对我以后的学习有很大的帮助。希望其他人在看再做类似设计时有所借鉴。

通过几天的课程设计,我对数据库软件EDA技术、VHDL、等系列知识都有了一定的了解。使用EDA技术开发页面的能力也有了很大提高。

另外,我还学到了一个人的力量毕竟有限,但是团队的力量势不可挡,我们不能只靠自己,遇到不会的要多多求助同学,

这次课程设计虽然结束了,也留下了很多遗憾,因为由于时间的紧缺和许多课业的繁忙,并没有做到最好,但是,最起码我们没有放弃,它是我们的骄傲!相信以后我们会以更加积极地态度对待我们的学习、对待我们的生活。我们的激情永远不会结束,相反,我们会更加努力,努力的去弥补自己的缺点,发展自己的优点,去充实自己,只有在了解了自己的长短之后,我们会更加珍惜拥有的,更加努力的

第 18 页 共 28 页

数字电路课程设计报告

去完善它,增进它。只有不断的测试自己,挑战自己,才能拥有更多的成功和快乐!快乐至上,享受过程,而不是结果!认真对待每一个实验,珍惜每一分一秒,学到最多的知识和方法,锻炼自己的能力,这个是我们在实时测量技术试验上学到的最重要的东西,也是以后都将受益匪浅的!

参考文献

1、《VHDL与数字电路设计》.卢毅, 赖杰. 科学出版社 2、《VHDL 程序设计》(第二版). 曾繁泰等. 清华大学出版社 3、《VHDL入门与应用》陈雪松, 滕立中 .人民邮电出版社 4、《EDA技术与VHDL》(第二版).潘松,黄继业. 清华大学出版社 5、《数字电路技术基础》(第二版). 阎石 .高等教育出版社

附录 总程序

library ieee;

use ieee.std_logic_1164.all; use

ieee.std_logic_unsigned.all; entity dingceng is port(clkd,resetd,cond,con1d:

in std_logic; count1:out

std_logic_vector(6 downto 0); count2:out

std_logic_vector(6 downto 0); count3:out

第 19 页 共 28 页

数字电路课程设计报告

std_logic_vector(6 downto 0); count4:out

std_logic_vector(6 downto 0); reda,greena,yellowa,greena1: out std_logic;

redb,greenb,yellowb,greenb1: out std_logic); end entity dingceng;

architecture one of dingceng is

component clk_10 port(clk:in std_logic; clk_div10 : out std_logic); end component; component counter port

(clk0:in std_logic; con:in std_logic; reset:in std_logic;

countnum:buffer

integer range 0 to 89); end component; component controller port

( clk1 : in std_logic; con1 : in std_logic;

con2: in std_logic;

countnum : in integer range 0 to 89; numa,numb

:

out

integer range 0 to 25; ra,ga,ya,ga1: std_logic;

rb,gb,yb,gb1 : out std_logic); end component; component fenwei

port ( numin:in integer range 0 to 25;

numa,numb:out integer range 0 to 9 ); end component;

out

第 20 页 共 28 页

数字电路课程设计报告

component yima

port(clk2:in std_logic; bb: in integer range 0 to 9; ya:out std_logic; yb:out std_logic; yc:out std_logic; yd:out std_logic; ye:out std_logic; yf:out std_logic;

yg:out std_logic); end component;

signal a,b,c:std_logic; signal ww:integer range 0 to 89;

signal yy1,yy2:integer range 0 to 25; signal

tt1,tt2,tt3,tt4:integer range 0 to 9; begin u0:

clk_10

port

map(clk=>clkd,clk_div10=>a); u1:

clk_10

port

map(clk=>clkd,clk_div10=>b); u2:

clk_10

port

map(clk=>b,clk_div10=>c); u3:counter port

map(clk0=>c,con=>cond,reset=>resetd,countnum=>ww); u4:controller port map (clk1=>c,con1=>cond,con2=>con1d,countnum=>ww,numa=>yy1,numb=>yy2,ra=>reda,ga=>greena,ya=>yellowa,ga1=>greena1,rb=>redb,gb=>greenb,yb=>yellowb,gb1=>greenb1);

第 21 页 共 28 页

数字电路课程设计报告

u5:fenwei port t3(2),yd=>count3(3),ye=>count3(4),yf=>count3(5),yg=>count3(6));

map(numin=>yy1,numa=>tt1,numb=>tt2); u6:fenwei

port

map

u10:yima port

(numin=>yy2,numa=>tt3,numb=>tt4); u7:yima port

map(clk2=>b,bb=>tt1,ya=>count1(0),yb=>count1(1),yc=>count1(2),yd=>count1(3),ye=>count1(4),yf=>count1(5),yg=>count1(6)); u8:yima

port

map

map(clk2=>b,bb=>tt4,ya=>count4(0),yb=>count4(1),yc=>count4(2),yd=>count4(3),ye=>count4(4),yf=>count4(5),yg=>count4(6));

end architecture one;

library ieee;

use ieee.std_logic_1164.all; use

ieee.std_logic_arith.all; use

ieee.std_logic_unsigned.all; entity clk_10 is

(clk2=>b,bb=>tt2,ya=>count2(0),yb=>count2(1),yc=>count2(2),yd=>count2(3),ye=>count2(4),yf=>count2(5),yg=>count2(6)); u9:yima

port

port( clk : in std_logic; clk_div10

:

out

map(clk2=>b,bb=>tt3,ya=>count3(0),yb=>count3(1),yc=>coun

第 22 页 共 28 页

数字电路课程设计报告

std_logic); end clk_10;

architecture one of clk_10 is signal clk_temp : std_logic; begin process(clk) variable

counter

:

end one;

library ieee;

use ieee.std_logic_1164.all; entity counter is port

( clk0:in std_logic; con:in std_logic; reset:in std_logic; countnum:buffer range 0 to 89); end counter;

architecture one of counter is begin

process (reset,clk0) begin

if reset='1' then countnum <= 0; elsif

rising_edge( clk0 ) then if con='1' then countnum <= 0;

第 23 页 共 28 页

std_logic_vector(2 downto 0); constant

md

: downto

std_logic_vector(2 0) := \begin

integer

if(clk'event and clk='1') then

if(counter = md)then counter := (others =>'0'); clk_temp <= not clk_temp; end if;

counter := counter + 1 ; end if; end process;

clk_div10 <= clk_temp;

数字电路课程设计报告

else

if countnum=89 then countnum <= 0; else countnum countnum + 1; end if; end if; end if; end process; end one;

library ieee;

use ieee.std_logic_1164.all; use

ieee.std_logic_unsigned.all; entity controller is port

( clk1 : in std_logic;

con1 : in std_logic; con2 : in std_logic; countnum : in integer range

<=

0 to 89;

numa,numb : out integer range 0 to 25; ra,ga,ya,ga1 std_logic; rb,gb,yb,gb1: std_logic); end controller; architecture controller is

signal m : integer range 0 to 7; begin process

( clk1,con1,con2,countnum ) variable

aa:std_logic_vector(7 downto 0); begin

if (clk1'event and clk1 = '1' )then if con1 ='0' then

one

of out

:

out

第 24 页 共 28 页

数字电路课程设计报告

if countnum >= 65then numb<=90-countnum; numa <=90-countnum; if countnum >= 70 then aa := \ else aa := \ numa<= 70-countnum; end if;

elsif countnum >= 45 then numb <= 65-countnum; numa <=65-countnum; if countnum >= 50 then aa := \ else aa := \ numb<= 50-countnum; end if;

elsif countnum >= 20 then numa <= 45-countnum; numb <=45-countnum; if countnum >= 25 then aa := \ else aa := \

numa <= 25-countnum; end if;

elsif countnum >= 0 then numa <= 20-countnum; numb <= 20-countnum; if countnum >= 5 then aa := \ else aa := \ numb <= 5-countnum; end if; end if; else

if con1= '1' then numa <= 0; numb <= 0; if con2 = '1' then if m = 7 then m <= 0; else m <= m + 1; end if;

第 25 页 共 28 页

数字电路课程设计报告

end if; if m = 0 then aa := \ end if; end if; elsif m= 1 then aa := \ elsif m=2 then aa :=\elsif m=3 then aa := \elsif m=4 then aa := \elsif m=5 then aa := \elsif m=6 then aa := \elsif m=7 then aa := \ end if; end if;

ra <= aa(7); ga <= aa(6); ya <= aa(5); ga1 <= aa(4); rb <= aa(3); gb <= aa(2); yb <= aa(1); gb1 <= aa(0); end process; end one;

library ieee;

use ieee.std_logic_1164.all; entity fenwei is

port ( numin:in integer range 0 to 25; numa,numb:out integer range 0 to 9 ); end fenwei;

第 26 页 共 28 页

数字电路课程设计报告

architecture one of fenwei is begin

process( numin )

end one ;

variable numa1,numb1: library ieee; integer range 0 to 9; begin

if numin >= 20 then numa1 :=2; numb1 := numin - 20;

elsif numin >= 10 then

numa1 := 1; numb1 := numin - 10;

else

numa1 := 0 ; numb1 := numin ; end if ; numa <= numa1; numb <= numb1; end process ;

use ieee.std_logic_1164.all; entity display is port(

clk2:in std_logic; bb:

in

std_logic_vector(3 downto 0); ya:out std_logic; yb:out std_logic; yc:out std_logic; yd:out std_logic; ye:out std_logic; yf:out std_logic; yg:out std_logic); end display;

architecture one of display is signal

temp:

std_logic_vector(6 downto 0); begin

第 27 页 共 28 页

数字电路课程设计报告

process(bb) begin case bb is

when \\

when \\

when \\

when \\

when \\

when \\

when \\

when \\

when \\

when \\

when others => temp <= \=> temp <= end case; end process; => temp <= ya<=temp(0); yb<=temp(1); => temp <= yc<=temp(2); yd<=temp(3); => temp <= ye<=temp(4); yf<=temp(5); => temp <= yg<=temp(6); end one; => temp <=

=> temp <= => temp <= => temp <= => temp <=

第 28 页 共 28 页

本文来源:https://www.bwwdw.com/article/qxq8.html

Top