EDA 实验报告书
姓名
学号 实验时间
实验十 十字路口交通管理器设计
1.掌握 EDA 的层次化设计方法;
2.了解用 VHDL 语言设计的思想;
3.了解整个数字系统的设计方法;
4.培养学生综合应用数字电路中所学到的理论知识去独立完成设计课题的能力;
5.通过查阅手册和文献资料,培养学生独立分析和解决实际问题的能力;
设计一个十字路口交通管理器,该管理器控制十字路口甲、乙两条道路的红黄绿三色灯,指挥
车辆和行人安全通过,交通管理器示意图如图所示,图中 R1、Y1、G1 是甲道红、黄、绿灯;
R2、Y2、G2 是乙道红、黄、绿灯。
课题名称
实验目的
设计要求
设计思路
该交通管理器由控制器和受其控制的 3 个定时器以及六个交通灯组成,图中 3 个定时器分别确
定甲道和乙道通行时间 t1、t3 以及公共的停车(黄灯亮)时间 t2。这三个定时器采用以秒信
号为时钟的计数器来实现,C1、C2、C3 分别是这些定时器的工作使能信号,即当 C1、C2 或
C3 为 1 时,相应的定时器开始计数,W1、W2 和 W3 为定时计数器的指示信号,计数器在计
数过程中,相应的指示信号为 0,计数结束时为 1。
设计原理
图及源程
序
(甲道通行定时器程序)
library ieee;
use ieee.std_logic_1164.all;
entity t3 is
port(clk:in std_logic;
enable:in std_logic;
c:out std_logic);
end t3;
architecture behave of t3 is
begin
process(clk)
variable cnt: integer range 46 downto 0;
begin
if(clk'event and clk='1')then
if enable='1'and cnt<46 then
cnt:=cnt+1;
else
cnt:=0;
end if;
end if;
if cnt=46 then
c<='1';
else
c<='0';
end if;
end process;
end behave;
(乙道通行定时器程序)
library ieee;
use ieee.std_logic_1164.all;
entity t1 is
port(clk:in std_logic;
enable:in std_logic;
c:out std_logic);
end t1;
architecture behave of t1 is
begin
process(clk)
variable cnt: integer range 50 downto 0;
begin
if(clk'event and clk='1')then
if enable='1'and cnt<50 then
cnt:=cnt+1;
else
cnt:=0;
end if;
end if;
if cnt=50 then
c<='1';
else
c<='0';
end if;
end process;
end behave;
(公共停车定时器程序)
library ieee;
use ieee.std_logic_1164.all;
entity t2 is
port(clk:in std_logic;
enable:in std_logic;
c:out std_logic);
end t2;
architecture behave of t2 is
begin
process(clk)
variable cnt: integer range 5 downto 0;
begin
if(clk'event and clk='1')then
if enable='1'and cnt<5 then
cnt:=cnt+1;
else
cnt:=0;
end if;
end if;
if cnt=5 then
c<='1';
else
c<='0';
end if;
end process;
end behave;
(交通管理控制器程序)
library ieee;
use ieee.std_logic_1164.all;
entity kzq is
port(clk:in std_logic;
c1,c2,c3:out std_logic;
w1,w2,w3:in std_logic;
r1,r2:out std_logic;
y1,y2:out std_logic;
g1,g2:out std_logic;
reset:in std_logic);
end kzq;
architecture behave of kzq is
type state_space is(s0,s1,s2,s3);
signal state:state_space;
begin
process(clk)
begin
if reset='1'then
state<=s0;
elsif(clk'event and clk='1')then
case state is
when s0=>if w1='1'then
state<=s1;
end if;
when s1=>if w2='1'then
state<=s2;
end if;
when s2=>if w3='1'then
state<=s3;
end if;
when s3=>if w2='1'then
state<=s0;
end if;
end case;
end if;
end process;
c1<='1'when state=s0 else'0';
c2<='1'when state=s1 or state=s3 else'0';
c3<='1'when state=s2 else'0';
r1<='1'when state=s1 or state=s0 else'0';
y1<='1'when state=s3 else'0';
g1<='1'when state=s2 else'0';
r2<='1'when state=s2 or state=s3 else'0';
y2<='1'when state=s1
g2<='1'when state=s0
end behave;
else'0';
else'0';
(控制器仿真波形)
仿真波形
图
(控制器下载结果)
实验结果
(控制器延时分析)
问题讨论
教师评分
操作成绩 报告成绩
教师签名
日 期