基VHDL语言
交通灯设计
专业班级: 应电班
作 者:
指导老师:
完成时间:
电子信息工程系 应电子技术专业
设计求实现功
1设计相关求
(1)留意走交通灯指示路口选取进行数采集模拟设计智交通灯系统设计十字路口例干道通车指示灯(绿黄红)显示时间次60S4S35S
(2)显示方绿黄红指示状态
(3)两数码进行倒计时显示
(4)发光二极模拟交通灯显示状态颜色灯实现
2设计实现功
(1)遵循流程:
|>|>|>|
| 绿灯 |黄灯| 红灯 |
(2)设计模拟交通灯智系统两数码进行显示红黄绿三种颜色指示灯模拟通车状态
(3)干道通车循环:
绿:35S 黄:4S 红:60S
二 系统分析模块设计
1 系统分析
首先50MHZ晶振产生时钟信号分频电路分离出500HZ2HZ1HZ时钟信号利1HZ时钟进行减法计数利2HZ时钟实现黄灯闪烁利500HZ实现数码动态显示扫描计数值分成十位位通译码电路实现数码显示
交通灯控制部分设计框图:
显示部分设计框图:
2 模块电路设计
(1) 分频模块设计
晶振产生50MHz信号分离出clk_500clk_2hzclk_1hz三种时钟信号
A 100000分频> clk_500
B 500分频(clk_500)> clk_1
C 250分频(clk_500)> clk_2
(2)交通灯模式选择:分四种模式分支路绿灯亮黄灯闪烁红灯亮黄灯闪烁
(3)灯控制模块:
(4)倒计时模块:
(5)显示模块(倒计时显示)
A 四进制计数器产生四种模式
B 2位四路译码控制数码位选
C 16—4选通器次送数(四位)进行显示
D 七段数码译码产生数码段选
(6)输出模块
A 灯状态输出
B 位选信号输出选择中两路(时间数值超100)
C : 段选输出
D 蜂鸣器控制禁止蜂鸣器发出声音
三 顶层电路设计测试仿真
1 顶层电路原理图(已进行引脚配置)
2 测试仿真
首先模块电路进行波形仿真成功编译整顶层设计电路进行引
脚配置
选择JTAG模式生成*sof文件进行载分析查显示结果
四 设计总结
1设计总结
次交通灯设计基VHDL语言程序设计种硬件语言知道课程设计程中仅仅网找资料书中学外面种学学制作程中整项目法独立完成中问少找资料体会做完整项目需流程设计思想真容易然次设计收获颇丰完成项目设计通网络找许相关资料问善长方面知识学扩充视野点点关方面知识解相信错开始
附录:(底层电路设计模块程序)
1分频部分
fenpin104:
library ieee
use ieeestd_logic_1164all
use ieeestd_logic_unsignedall
entity fenpin104 is
port(clk_in in std_logic 时钟信号输入输出端口
clk_outout std_logic)
end fenpin104
architecture a of fenpin104 is
signal countinteger range 0 to 99999计数值10万分频
begin
process(clk_in)
begin
if clk_in'event and clk_in'1' then
if count99999 then 计数值产生进位时清零
count<0
clk_out<'1'
else
count
end if
end if
end process
end a
fenpin500:
library ieee
use ieeestd_logic_1164all
use ieeestd_logic_unsignedall
entity fenpin500 is
port(clk_in in std_logic
clk_outout std_logic)
end fenpin500
architecture a of fenpin500 is
signal countinteger range 0 to 499
begin
process(clk_in)
begin
if clk_in'event and clk_in'1' then
if count499 then
count<0
clk_out<'1'
else
count
end if
end if
end process
end a
fenpin250:
library ieee
use ieeestd_logic_1164all
use ieeestd_logic_unsignedall
entity fenpin250 is
port(clk_in in std_logic
clk_outout std_logic)
end fenpin250
architecture a of fenpin250 is
signal countinteger range 0 to 249
begin
process(clk_in)
begin
if clk_in'event and clk_in'1' then
if count249 then
count<0
clk_out<'1'
else
count
end if
end if
end process
end a
2交通灯控制部分
mode_choice
library ieee
use ieeestd_logic_1164all
use ieeestd_logic_unsignedall
entity mode_choice is
port(clk_1hzin std_logic
mode_outout std_logic_vector(1 downto 0))
end mode_choice
architecture a of mode_choice is
signal countinteger range 0 to 169
begin
process(clk_1hz)
begin
if clk_1hz'event and clk_1hz'1' then 总循环170s计时
if count169 then
count<0
else
count
end if
if count<90 then 1——90s模式0
mode_out<00
elsif count<100 then 91——100s模式1
mode_out<01
elsif count<160 then 101——160s模式2
mode_out<10
else 161——170s模式3
mode_out<11
end if
end process
end a
daojishi
library ieee
use ieeestd_logic_1164all
use ieeestd_logic_unsignedall
entity daojishi is
port(clk_1hz in std_logic
control in std_logic_vector(1 downto 0)
time out std_logic_vector(7 downto 0))
end daojishi
architecture a of daojishi is
signal geshistd_logic_vector(3 downto 0)
begin
process(clk_1hz)
begin
if clk_1hz'event and clk_1hz'1' then
if control00 then 模式0位十位数
if ge0000 then
ge<1001
if shi0000 then
shi<1000
else
shi
else
ge
end if
if control01 then 模式1位十位数
shi<0000
if ge0000 then
ge<1001
else
ge
end if
if control10 then 模式2位十位数
if ge0000 then
ge<1001
if shi0000 then
shi<0101
else
shi
else
ge
end if
if control11 then 模式3位十位数
shi<0000
if ge0000 then
ge<1001
else
ge
end if
end if
time(3 downto 0)
end process
end a
light_control
library ieee
use ieeestd_logic_1164all
entity light_control is
port(clk_2hz in std_logic
control in std_logic_vector(1 downto 0)
r1r2g1g2y1y2out std_logic)
end light_control
architecture a of light_control is
begin
process(control)
begin 四种模式灯显示状态
if control00 then
r1<'0'g1<'1'y1<'0'r2<'1'g2<'0'y2<'0'
elsif control01 then
r1<'0'g1<'0'y1
r1<'1'g1<'0'y1<'0'r2<'0'g2<'1'y2<'0'
else
r1<'0'g1<'0'y1
end process
end a
3 显示部分
cnt4_v
library ieee 四进制计数器
use ieeestd_logic_1164all
use ieeestd_logic_unsignedall
entity cnt4_v is
port(clrenaclkin std_logic
Qout std_logic_vector(1 downto 0)
Coout std_logic)
end cnt4_v
architecture bha of cnt4_v is
signal tempstd_logic_vector(1 downto 0)
begin
process(clrenaclk)
begin
if clk'event and clk'1' then
if clr'0' then
temp < 00
Co< '0'
else
if ena'1' then
if temp3 then
temp<00
Co <'1'
else
temp
end if
end if
end if
end if
end process
Q < temp
end bha
decode2_4V
library ieee 二——四译码
use ieeestd_logic_1164all
entity decode2_4v is
port( X in std_logic_vector(1 downto 0)
Y out std_logic_vector(3 downto 0))
end decode2_4v
architecture beh of decode2_4v is
begin
process(X)
begin
if X00 then
Y < 1110
elsif X01 then
Y < 1101
elsif X10 then
Y < 1011
elsif X11 then
Y < 0111
else
Y < XXXX
end if
end process
end beh
multi16_4_v
LIBRARY IEEE 数选择(16——>4)
USE IEEESTD_LOGIC_1164ALL
ENTITY multi16_4_v IS
PORT( sel IN STD_LOGIC_VECTOR(1 DOWNTO 0)
in1 IN STD_LOGIC_VECTOR(3 DOWNTO 0)
in2 IN STD_LOGIC_VECTOR(3 DOWNTO 0)
in3 IN STD_LOGIC_VECTOR(3 DOWNTO 0)
in4 IN STD_LOGIC_VECTOR(3 DOWNTO 0)
out4_1 OUT STD_LOGIC_VECTOR(3 DOWNTO 0) )
END multi16_4_v
ARCHITECTURE behav OF multi16_4_v IS
BEGIN
PROCESS (in1in2in3in4sel)
BEGIN
CASE sel IS
WHEN 00 > out4_1 < in1
WHEN 01 > out4_1 < in2
WHEN 10 > out4_1 < in3
WHEN 11 > out4_1 < in4
WHEN OTHERS > NULL
END CASE
END PROCESS
END behav
seven_v
library ieee 7段译码
use ieeestd_logic_1164all
entity seven_v is
port( X in std_logic_vector(3 downto 0)
Y out std_logic_vector(7 downto 0))
end seven_v
architecture beh of seven_v is
begin
process(X)
begin
case X is
when 0000 > Y < 11000000
when 0001 > Y < 11111001
when 0010 > Y < 10100100
when 0011 > Y < 10110000
when 0100 > Y < 10011001
when 0101 > Y < 10010010
when 0110 > Y < 10000010
when 0111 > Y < 11111000
when 1000 > Y < 10000000
when 1001 > Y < 10010000
when 1010 > Y < 10001000
when 1011 > Y < 10000011
when 1100 > Y < 11000110
when 1101 > Y < 10100001
when 1110 > Y < 10000110
when 1111 > Y < 10001110
when others > NULL
end case
end process
end beh
文档香网(httpswwwxiangdangnet)户传
《香当网》用户分享的内容,不代表《香当网》观点或立场,请自行判断内容的真实性和可靠性!
该内容是文档的文本内容,更好的格式请下载文档