数字电路-交通灯控制器-实验报告 本文关键词:交通灯,控制器,数字电路,实验,报告
数字电路-交通灯控制器-实验报告 本文简介:isoneofthepracticalformofvalues.Theso-calledvaluesreferstotheobjectivethingsareofnovalueandthevalueoffundamentalperspective.Differentvalues,peoplesbeh
数字电路-交通灯控制器-实验报告 本文内容:
is
one
of
the
practical
form
of
values.
The
so-called
values
refers
to
the
objective
things
are
of
no
value
and
the
value
of
fundamental
perspective.
Different
values,people
s
behaviour,attitudes,ways
are
different.
People-oriented
focus
on
human
value
and
reality,we
need
the
broadest
masses
as
values.
Adhere
to
people-oriented
values,is
to
make
the
economy
more
development,improve
democracy,cultural
prosperity,and
live
a
happier;
is
deeply
concerned
that
human
development
and
human
values,development
of
social
and
human
development
of
rational
unified,insisted
in
the
material
civilization,political
civilization
and
spiritual
civilization
in
the
overall
advancement
of
Socialist
civilization
to
a
higher
level.
Also
want
to
see
that
person
s
value
is
not
only
meet
your
needs,also
is
to
meet
the
needs
of
others
and
the
community.
Adhere
to
people-oriented,to
strongly
advocate
every
community
member,serve
others,beneficial
to
the
community
of
people.
The
so-called
Outlook,attitude
is
on
the
record,including
who,how
to
create
a
record
of
achievements,how
to
evaluate
performance,and
so
on.
What
values,what
kind
of
Outlook.
Adhere
to
people-oriented
Outlook,is
on
the
premise
of
respecting
the
interests
and
power
of
people,creating
a
popular,warm
hearts,steady
heart
performance,creating
“serve
for
one
officer,the
benefit
of“achievements,and
overall
construction
of
well-off
society
and
promoting
the
all-round
development
of
people
s
performance.
Achievement
evaluation
in
both
economic
accomplishments,take
another
look
at
the
effectiveness
of
social
progress;
changes
in
both
urban
and
rural
change;
both
hard
environment
to
strengthen
and
take
another
look
at
the
soft
environment
improvement
momentum
of
development
at
present,depending
on
the
potential
for
sustainable
development.
Leave
people
to
talk
about
“values“are
worthless
and
leave
people
to
talk
about
“Outlook“is
not
what
the
performance.
4.
people
responded
to
the
starting
point
of
the
question,and
replied
to
questions
point.
Man
is
the
sum
of
social
relationships.
We
cannot
leave
the
chichuanyongdu,housing,tourism
and
entertainment,entertaining,and
even
certain
political,economic,cultural
and
social
environment,and
so
on.
Due
to
human
needs,all
walks
of
life
will
come
into
being.
People
create
for
their
survival,and
continue
enjoying
the
results
of
the
construction.
Colorful
in
the
transformation
of
the
people
of
the
world,community
vitality
in
the
creation
of
man.
Therefore,any
work
we
do,the
starting
point
is
human,what
are
people.
Us
speed
up
development,the
core
of
which
is
to
meet
the
needs
of
people,including
survival
needs,emotional
needs
and
self-actualization
needs.
It
should
be
noted
that
people
are
not
machines,not
the
slave
of
an
object,not
to
be
controlled.
People
have
their
own
personality,has
its
own
personality,has
its
own
dignity.
Person
in
need
of
care,you
need
to
understand,need
to
meet.
It
is
said
that
in
the
“agricultural
society,people
plant“;
in
“industrial
society,man
is
an
animal“;
“the
information
society,return数字系统与逻辑设计实验-----课题三:交通灯控制器
课题三:交通灯控制器
课题三:交通灯控制器
一.设计课题的任务要求
(一)、实验目的
1.
熟练掌握
VHDL
语言和QuartusII
软件的使用;
2.
理解状态机的工作原理和设计方法;
3.
掌握利用
EDA
工具进行自顶向下的电子系统设计方法;
(二)、相关知识
本实验要利用
CPLD
设计实现一个十字路口的交通灯控制系统,与其他控制系统一样,本系统划分为控制器和受控电路两部分。控制器使整个系统按设定的工作方式交替指挥车辆及行人的通行,并接收受控部分的反馈信号,决定其状态转换方向及输出信号,控制整个系统的工作过程。
路口交通灯控制系统的有东西路和南北路交通灯
R(红)、Y(黄)、G(绿)三色,所有灯均为高电平点亮。设置20s
的通行时间和5s
转换时间的变模定时电路,用数码管显示剩余时间。提供系统正常工作/复位和紧急情况两种工作模式。
(三)、实验任务
1.基本任务:
设计制作一个用于十字路口的交通灯控制器。
1).
南北和东西方向各有一组绿、黄、红灯用于指挥交通,绿灯、黄灯和红灯的持续时间分别为20
秒、5
秒和25
秒;
2).
当有特殊情况(如消防车、救护车等)时,两个方向均为红灯亮,计时停止,当特殊情况结束后,控制器恢复原来状态,继续正常运行;
3).
用两组数码管,以倒计时方式显示两个方向允许通行或禁止通行的时间;
2.提高要求:
1).
增加左、右转弯显示控制功能;
2).
紧急状况时增加声光警告功能;
3).
自拟其它功能。
二.系统设计(包括设计思路、总体框图、分块设计)
(一)设计思路
1.总体设计----输入部分:
1)
CLK时钟频率输入,可由实验板上直接提供,为准确确定时间长度,选择High挡的1MHz高频信号。
2)
紧急状态按键拨码开关EMERGENCY,当将其置为高电平,表示紧急情况发生,两个方向均为红灯亮,计时停止,蜂鸣器蜂鸣;当置其为低电平,信号灯和计时器恢复原来状态,正常工作。
3)
复位拨码开关RESET,当将其置为高电平,表示复位,工作停止,全部回到初始状态;当置其为低电平,重新开始工作。
2.总体设计----输出部分:
1)
东西方向和南北方向各使用4个LED显示,LIGHT1,LIGHT2,红黄绿各代表红黄绿灯,剩下两个红灯分别表示限制两个方向的禁止左转。
2)
东西方向和南北方向计时均为2位数,共需要4个LED七段数码管显示。由于为共阴极控制,输出一个CAT_TEMP信号控制选择数码管显示,NUM信号输出显示的内容。
3)
增加一个BELL输出,控制紧急状态下的蜂鸣器。
(二)总体框图
1.输入输出示意图
CLK
LIGHT1
EMERGENCY
LIGHT2
RESET
BELL
NUM
CAT——TEMP
CLK
开关1
数码管显示输出
数码管共阴极控制
东西向
交通灯
南北向
交通灯
蜂鸣器
开关2
2.模块示意图
控制器
紧急请求
系统复位
BELL
控制器
南北灯(包括禁止左转灯)
东西灯(包括禁止左转灯)
复位
紧急请求
分频器
时钟
时间计数器
译码器
时间倒计时显示
警铃
3.流程图
YES
南北绿,东西红
东西禁止左转灯亮
是否绿灯时间到20s?
对黄灯开始计时
南北黄,东西红
东西禁止左转灯亮
是否黄灯时间到5s?
对绿灯开始计时
南北红,东西绿
南北禁止左转灯亮
是否绿灯时间到20s?
对黄灯开始计时
南北红,东西黄
南北禁止左转灯亮
是否黄灯时间到5s?
对绿灯开始计时
YES
YES
YES
NO
NO
NO
NO
启动/复位
任何/当前正常运行状态
警报开关
是否打开?
全部亮红灯+警铃
YES
NO
4.RTL图
5.状态转移列表(状态机)
红绿灯显示状态
状态
S0
南北绿灯亮,东西红灯亮,东西禁止左转
S1
南北黄灯亮,东西红灯亮,东西禁止左转
S2
南北红灯亮,东西绿灯亮,南北禁止左转
S3
南北红灯亮,东西黄灯亮,南北禁止左转
S4
南北东西红灯都亮,南北东西都禁止左右转
(三)分块设计
-------在VHDL设计中,采用自顶向下的设计思路。
1.顶层模块中,根据硬件设计,设置如下端口:
u
外部时钟信号:CLK
u
紧急状态按键:EMERGENCY
u
南北方向状态灯:LIGHT1
u
东西方向状态灯:LIGHT2
u
蜂鸣器控制:BELL
u
数码管显示信号:NUM
u
数码管共阴极控制:CAT_TEMP
2.在底层中,把不同功能分模块设计。
u
FREQUENCY模块,由于外部时钟信号CLK的频率为50MHz,而实际需要的内部计时时钟频率为1Hz,需要一个分频电路。
输入端口:CLK外部时钟信号
输出端口:CLK_OUT分频后信号
u
COUNTER模块,由于整个过程的显示周期为50秒,即50个状态,所以该模块为计数器模块,计数周期为50,输入为1Hz的外部时钟,并加入紧急信号和复位信号,当输入紧急信号,计数停止,当输入复位信号,计数置1.通过该计数器的计数输出信号来控制LIGHT模块和COUNTDOWN模块的状态。
输入端口:CLK时钟信号,EMERGENCY紧急信号,RESET复位信号
输出端口:COUNTER计数状态信号,BELL报警信号
u
COUNTDOWN模块,倒计时显示模块,通过输入的COUNTER和CLK来控制数码管共阴极和7段数码管数字显示控制。
输入接口:CLK时钟信号,COUNT计数器信号
输出接口:CAT_TEMP共阴极控制,NUMIN数字输出
u
SHOW模块,接收数字信号,进行7位数码管显示译码输出。
输入接口:NUMIN输入信号
输出接口:NUM译码输出
u
LIGHT信号灯控制模块,使用状态机,双进程控制5个状态
输入接口:COUNT计数器信号,EMERGENCY紧急状态控制
输出接口:LIGHT1,LIGHT2信号灯输出
三.仿真波形及波形分析
仿真波形-------由于时钟为50MHz,故在仿真时为了波形图更易读,将分频器设为20分频
1.状态周期为1~50,在每个状态内,数码管共阴极进行扫描,且扫描同时数码管显示进行循环变化
2.周期状态,在1~20,21~25,26~45,46~50进行红绿灯显示变化
3.一整个周期状态1~50,在1~20,21~25,26~45,46~50进行红绿灯显示变化
4.多个周期循环
5.紧急状态和复位状态
四.源程序(注释)
l
TRAFFIC.vhd----主程序
LIBRARY
IEEE;
USE
IEEE.STD_LOGIC_1164.ALL;
USE
IEEE.STD_LOGIC_UNSIGNED.ALL;
USE
IEEE.STD_LOGIC_ARITH.ALL;
ENTITY
TRAFFIC
IS
PORT(
CLK,RESET,EMERGENCY:IN
STD_LOGIC;----输入时钟信号,复位信号,紧急信号
LIGHT1,LIGHT2:OUT
STD_LOGIC_VECTOR(3
DOWNTO
0);----输出东西南北向两个红信号
NUM:OUT
STD_LOGIC_VECTOR(6
DOWNTO
0);----输出7端数码管选通信号
CAT_TEMP:OUT
STD_LOGIC_VECTOR(5
DOWNTO
0);----输出7端数码管共阴极信号
BELL:OUT
STD_LOGIC;----输出警铃信号
NUMIN:OUT
STD_LOGIC_VECTOR(3
DOWNTO
0);----输出信号(用十进制在波形图显示数字)
COUNTERS:OUT
STD_LOGIC_VECTOR
(5
DOWNTO
0)----输出信号(用十进制在波形图中显示周期状态)
);
END
TRAFFIC;
ARCHITECTURE
TRAFFICSHOW
OF
TRAFFIC
IS
SIGNAL
TEMPCLK:STD_LOGIC;
SIGNAL
TEMPCOUNT:STD_LOGIC_VECTOR(5
DOWNTO
0);
SIGNAL
TEMPNUM:STD_LOGIC_VECTOR(3
DOWNTO
0);
COMPONENT
FREQUENCY
IS----组合FREQUENCY模块,以下同
PORT(
CLK:IN
STD_LOGIC;
CLK_OUT:OUT
STD_LOGIC
);
END
COMPONENT;
COMPONENT
COUNTER
IS
PORT(
CLK:IN
STD_LOGIC;
RESET:IN
STD_LOGIC;
EMERGENCY:IN
STD_LOGIC;
COUNTER:OUT
STD_LOGIC_VECTOR
(5
DOWNTO
0);
BELL:OUT
STD_LOGIC;
COUNTERS:OUT
STD_LOGIC_VECTOR
(5
DOWNTO
0)
);
END
COMPONENT;
COMPONENT
LIGHT
IS
PORT(
EMERGENCY:IN
STD_LOGIC;
COUNT:IN
STD_LOGIC_VECTOR(5
DOWNTO
0);
LIGHT1,LIGHT2:OUT
STD_LOGIC_VECTOR(3
DOWNTO
0)
);
END
COMPONENT;
COMPONENT
COUNTDOWN
IS
PORT(
COUNT:IN
STD_LOGIC_VECTOR(5
DOWNTO
0);
CLK:IN
STD_LOGIC;
NUMIN:OUT
STD_LOGIC_VECTOR(3
DOWNTO
0);
CAT_TEMP:OUT
STD_LOGIC_VECTOR(5
DOWNTO
0);
NUMIN1:OUT
STD_LOGIC_VECTOR
(3
DOWNTO
0)
);
END
COMPONENT;
COMPONENT
SHOW
IS
PORT(
NUM_IN:IN
STD_LOGIC_VECTOR(3
DOWNTO
0);
NUM:OUT
STD_LOGIC_VECTOR(6
DOWNTO
0)
);
END
COMPONENT;
BEGIN----将各个模块接口连接起来
U1:FREQUENCY
PORT
MAP
(CLK=>CLK,CLK_OUT=>TEMPCLK);
U2:COUNTER
PORT
MAP
(BELL=>BELL,CLK=>TEMPCLK,RESET=>RESET,EMERGENCY=>EMERGENCY,COUNTER=>TEMPCOUNT,COUNTERS=>COUNTERS);
U3:LIGHT
PORT
MAP
(EMERGENCY=>EMERGENCY,COUNT=>TEMPCOUNT,LIGHT1=>LIGHT1,LIGHT2=>LIGHT2);
U4:COUNTDOWN
PORT
MAP
(NUMIN1=>TEMPNUM,CAT_TEMP=>CAT_TEMP,COUNT=>TEMPCOUNT,CLK=>CLK,NUMIN=>NUMIN);
U5:SHOW
PORT
MAP
(NUM_IN=>TEMPNUM,NUM=>NUM);
END
TRAFFICSHOW;
l
FREQUENCY.vhd----分频器模块,1Hz
LIBRARY
IEEE;
USE
IEEE.STD_LOGIC_1164.ALL;
USE
IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY
FREQUENCY
IS
PORT(
CLK:IN
STD_LOGIC;
CLK_OUT:OUT
STD_LOGIC
);
END
FREQUENCY;
ARCHITECTURE
FREQ
OF
FREQUENCY
IS
SIGNAL
TEMP:INTEGER
RANGE
0
TO
4999999;----设置分频999999,则为1Hz
BEGIN
PROCESS(CLK)
BEGIN
IF(CLK
EVENT
AND
CLK=
1
)THEN
IF(TEMP=4999999)THEN
TEMP
STATE
STATE
STATE
STATELIGHT1LIGHT1LIGHT1LIGHT1LIGHT1CASE
TEMP
IS----在每个状态内部设置数码管扫描过程,由于COUNTER和----扫描时钟不同
----则可在数码管上同时显示4个数字,以状态1
----(COUNTER=1)为例
----显示“1924”,并在共阴极上扫描,以下同
----共标记50种状态
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_INCASE
TEMP
IS
WHEN
0=>NUM_INNUM_INNUM_INNUM_IN<=“0001“;CAT<=“111110“;
END
CASE;