交通灯控制系统
EDA实验报告
2014
姓名:
学号:
课题名称
状态机设计交通信号控制系统
二 实验目
利学EDA相关知识完成交通灯控制系统设计实现提高学知识理解利熟练程度
三 设计务
设计十字路口交通控制系统求:
a 东西(A表示)南北(B表示)方均绿灯黄灯红灯指示持续时间分40秒五秒45秒交通灯运行切换示意图时间关系
交通控制系统运行切换示意图
更方灯光时间关系
b 系统设时钟倒计时方式显示路允许通行时间
c 东西南北两路中意路出现特殊状况时系统交警手动控制立进入特殊运行状态红灯全亮始终停止计时东西南北两路车辆禁止通行特殊状况结束系统恢复工作继续正常运行
四 实验程
a VHDL设计流程
b 交通控制系统顶层原理图50MHz分频器(devide50M)控制器(control)45秒倒计时计数器(m45)7字段译码器(SEG7)组成
1) 控制器设计
控制器逻辑符号图示中CLK时钟输入信号HOLD紧急制动信号AREDAGREENAYELLOW分东西方红灯绿灯黄灯指示输出信号BREDBGREENBYELLOW分南北方红灯绿灯黄灯指示输出信号
控制器VHDL描述文件controlvhd:
library ieee
use ieeestd_logic_1164all
use ieeestd_logic_unsignedall
entity control is
port(clkholdin std_logic
aredagreenayellowbredbgreenbyellowout std_logic)
end control
architecture behavior of control is
type state_type is (s0s1s2s3s4)
signal current_statenext_statestate_type
signal counter std_logic_vector(6 downto 0)
begin
synchprocess
begin
wait until clk'event and clk'1'
if hold'0' then 紧急制动信号效时计数器停止计数
counter
if counter<89 then
counter
counter<(others>'0')
end if
end if
end process
process 机状态
begin
wait until clk'event and clk'1'
current_state< next_state
end process
state_transprocess(current_state)
begin
case current_state is
when s0>
if hold'0' then
next_state
if counter<39 then
next_state
next_state
end if
when s1>
if hold'0' then
next_state
if counter<44 then
next_state
next_state
end if
when s2>
if hold'0' then
next_state
if counter<84 then
next_state
next_state
end if
when s3
>
if hold'0' then
next_state
if counter<89 then
next_state
next_state
end if
when s4>
if hold'0' then
next_state
if counter<39 then
next_state
next_state
next_state
next_state
end if
end case
end process
outputprocess(current_state) 种状态两路口红绿灯状态描述
begin
case current_state is
when s0>
ared<'0'
agreen<'1'
ayellow<'0'
bred<'1'
bgreen<'0'
byellow<'0'
when s1>
ared<'0'
agreen<'0'
ayellow<'1'
bred<'1'
bgreen<'0'
byellow<'0'
when s2>
ared<'1'
agreen<'0'
ayellow<'0'
bred<'0'
bgreen<'1'
byellow<'0'
when s3>
ared<'1'
agreen<'0'
ayellow<'0'
bred<'0'
bgreen<'0'
byellow<'1'
when s4>
ared<'1'
agreen<'0'
ayellow<'0'
bred<'1'
bgreen<'0'
byellow<'0'
end case
end process
end behavior
2) 倒计时计数器M45设计
倒计时计数器M45逻辑符号图中CLKENCR分时钟计数清零端QL[30]QH[30]OC分BCD码位十位进位输出
VHDL描述文件m45vhd:
library ieee
use ieeestd_logic_1164all
use ieeestd_logic_unsignedall
entity m45 is
port(
CLK in std_logic
EN in std_logic
CR in std_logic
QLQH out std_logic_vector(3 downto 0)
OC out std_logic
)
end m45
architecture behave of m45 is
signal couLcouHstd_logic_vector(3 downto 0)
begin
process(CRCLKEN)
begin
if CR'0' then 异步清零
couL<0000
couH<0000
elsif clk'event and clk'1' then
if EN'1' then
if( couL0 and couH0) then 减法计00重新置数44
couL<0100
couH<0100
elsif couL0 then 否位计0时置9十位减1
couL<1001
couH
couL
end if
end if
end process
process(couLcouH)
begin
if(couL0 and couH0)then
OC<'1' 减00时位输出
else
OC<'0'
end if
end process
QL
3) 7字段译码器电路设计
7字段译码器功8421BCD码译成7信号启动7段数码显示相应十进制数码逻辑符号图dat[30]8421BCD码输入abcdefg驱动数码显示7输出信号(低电效)
VHDL描述文件seg7vhd:
library ieee
use ieeestd_logic_1164all
entity seg7 is
port( dat in std_logic_vector(3 downto 0)
abcdefg out std_logic )
end seg7
architecture arc of seg7 is
signal tmp std_logic_vector(6 downto 0)
begin
process(dat)
begin
case dat is
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
end case
end process
a
4) 50MHz分频器设计
逻辑符号图目输入信号转化1HZ输出clk信号输入端clk_out信号输出端
VHDL描述文件devide50Mvhd:
library ieee
use ieeestd_logic_1164all
use ieeestd_logic_unsignedall
entity devide50M is
port(
clk in std_logic
clk_out out std_logic
)
end devide50m
architecture arc_devide50M of devide50M is
signal count std_logic_vector (25 downto 0)
begin
process
begin
wait until clk'event and clk'1'
if (count<50000000) then
count
else
count<(others >'0')
clk_out<'1'
end if
end process
end architecture arc_devide50M
c 脚设计
Cyclone III_EP3C16F484C6型号电路板脚连接:
Cyclone III_EP3C16F484C6型号电路板
脚连接图
五 实验结果
波形仿真结果
六 实验心
通次设计进步加深VHDL语言解更加浓厚兴趣文件编写程中遇少问题包括开始手元件间连接引脚设定终克服困难建议课程中机操作课程理教学相结合样许够更帮助学EDA
文档香网(httpswwwxiangdangnet)户传
《香当网》用户分享的内容,不代表《香当网》观点或立场,请自行判断内容的真实性和可靠性!
该内容是文档的文本内容,更好的格式请下载文档