基于FPGA的自动交通灯控制系统设计 模拟交通灯控制系统

基于FPGA的交通灯控制系统

华东交通大学电子信息工程2009-1陈磊

一:设计目标

l设计一个交通信号灯控制器,由一条主干道和一条支干道汇合成十字路口,在每个入口处设置红、绿、黄三色信号灯,红灯亮禁止通行,绿灯亮允许通行,黄灯亮则给行驶中的车辆有时间停在禁行线外。

l用红、绿、黄发光二极管作信号灯,用传感器或逻辑开关作检测车辆是否到来的信号。

l主干道处于常允许通行的状态,支干道有车来时才允许通行。主干道亮绿灯时,支干道亮红灯;支干道亮绿灯时,主干道亮红灯。

l主、支干道均有车时,两者交替允许通行,主干道每次放行45秒,支干道每次放行25秒,设立45秒、25秒计时、显示电路。

l在每次由绿灯亮到红灯亮的转换过程中,要亮4秒黄灯作为过渡,使行驶中的车辆有时间停到禁行线外,设立4秒计时、显示电路。

二:设计方案

设计语言采用VHDL语言,采用自上而下的设计方法,软件环境是Altera公司的QuartusII5.1英文版。

硬件环境是EDA实验室的EDA综合实验箱。实验板上搭载CycloneEP1C6Q240的FPGA器件,该器件有57个IO口。

三:设计过程

l交通灯原理分析

1)主支道路分4种行车状况,无无、无有、有无、有有,此信号从传感器输出信号得到,作为系统的输入,在本系统中用拨片开关模拟状态输入。

2)主支道路有4种亮灯情况:,主绿支红、主黄支红、支绿主红、支黄主红。

3)只要支路无车通行,则一直为主绿支红状态,只有支路有车通过才会进入支绿主红状态。

4)系统可以根据行车情况智能进入相应亮灯情况,提高了十字路口的通车效率。

5)用6个发光二极管作为主道路绿黄红三灯显示输出和支道路绿黄红三灯显示输出;用4个数码管分别作为主支道路倒计时显示输出。

l总体设计框图

根据系统要求可知:

输入信号为系统时钟、主支道路行车情况模拟输入。

输出信号为主支道路红绿黄显示信号、倒计时显示。

整体框图如下:

内部模块设计分析:

Ø分频模块:

  由于系统采用动态显示,所以系统输入频率较高,这里我们采用1kHz的时钟信号,又由于需要倒计时数字显示,内部需要计数模块,所以系统需要一个分频模块将1kHz的频率分为1Hz频率的信号以供计数状态转换模块作为时钟信号。所以,需要一个分频模块。

Ø状态转换及二极管显示模块:

由原理分析可知系统在4种亮灯状态之间切换,所以需要设计一个状态转换控制模块,而倒计时显示则来自内部的计数,所以将计数模块需要分频模块输出的分频时钟信号,所以状态转换模块内部包含了计数模块,又因为二极管模拟红绿灯显示是和亮灯状态紧密相关的,所以在系统中不单独设置模块二极管显示模块,而是整合在状态转换控制模块内部。而分频模块的输出直接作用于状态转换模块,不单独设置较小模块,故在状态转换模块内部包含3个子模块,分别为分频模块、状态转换控制模块、二极管现实模块。最后因为数码管动态显示模块需要根据亮灯状态决定输出,所以本模块还需增加状态输出信号。框图如下:

u状态循环模块重点分析:

该部分是整个电路的核心部分,所以重点讲述该部分的设计过程:

由前面原理分析可知亮灯状态共4种情况,因此考虑用状态机来实现,如下:

状态图如下所示,这是实现智能亮灯的关键:

Ø数码管动态显示模块:

  由于此模块采用了数码管的动态显示原理,所以代码量较多,所以单独分为一个模块,又因为动态显示倒计时间是与亮灯状态紧密相关的,所以必须从状态控制模块获取相关的状态输入,故在之前的模块中必须稍作修改,引出状态输出信号,以供本模块使用。又因为动态显示需要较高的时钟频率,所以本模块的时钟信号采用系统输入信号,而非分频后的时钟。模块框图如下:

Ø综合各个模块,整体模块 如下:

下面给出项目工程完成之后生成的RTL图:

对比之后知道两者是吻合的,说明项目结果和预期的完全一样。

四:模块设计及仿真

l顶层文件的设计

由于内部采用了两个子模块,所以采用例化语句,设计顶层文件,代码如下:

系统模块及两子模块端口声明分别为:

系统模块:

ENTITYTRAFFIC_LIGHT_CONTROLIS

PORT( CLK : IN STD_LOGIC;

PASS_STATE : IN STD_LOGIC_VECTOR(1DOWNTO0);

AGREEN : OUT STD_LOGIC;

AYELLOW : OUT STD_LOGIC;

ARED : OUT STD_LOGIC;

BGREEN : OUT STD_LOGIC;

BYELLOW : OUT STD_LOGIC;

BRED : OUT STD_LOGIC;

SEL : OUT STD_LOGIC_VECTOR(1DOWNTO0);

LED7S : OUT STD_LOGIC_VECTOR(6DOWNTO0)

);

ENDENTITYTRAFFIC_LIGHT_CONTROL;

状态控制模块:

COMPONENTSTATE_CONTROL

PORT ( CLK1 : IN STD_LOGIC;

PASS_STATE_IN : IN STD_LOGIC_VECTOR(1DOWNTO0);

LGTA_RED : OUT STD_LOGIC; LGTA_GREEN : OUT STD_LOGIC;

LGTA_YELLOW : OUT STD_LOGIC;

LGTB_RED : OUT STD_LOGIC;

LGTB_GREEN : OUT STD_LOGIC;

LGTB_YELLOW : OUT STD_LOGIC;

CNTOUT : OUT STD_LOGIC_VECTOR(5DOWNTO0);

STATEOUT : OUT STD_LOGIC_VECTOR(1DOWNTO0)

);

ENDCOMPONENT;

数码管动态显示模块:

COMPONENTDISPLAY

PORT( CLK2 : IN STD_LOGIC;

CNTIN : IN STD_LOGIC_VECTOR(5DOWNTO0);

STATEIN : IN STD_LOGIC_VECTOR(1DOWNTO0);

LED7SOUT : OUT STD_LOGIC_VECTOR(6DOWNTO0);

SELOUT : OUT STD_LOGIC_VECTOR(1DOWNTO0));

ENDCOMPONENT;

例化语句:

SIGNALMSTATE: STD_LOGIC_VECTOR(1DOWNTO0);

SIGNAL MCNT : STD_LOGIC_VECTOR(5DOWNTO0);

BEGIN

U1: STATE_CONTROL PORT MAP

(CLK1=>CLK,PASS_STATE_IN=>PASS_STATE,LGTB_RED=>BRED,LGTB_GREEN=>BGREEN,LGTB_YELLOW=>BYELLOW,LGTA_RED=>ARED,LGTA_GREEN=>AGREEN,LGTA_YELLOW=>AYELLOW,CNTOUT=>MCNT,STATEOUT=>MSTATE);

U2: DISPLAY PORT MAP

(CLK2=>CLK,CNTIN=>MCNT,STATEIN=>MSTATE,LED7SOUT=>LED7S,SELOUT=>SEL);

l状态转换控制及红绿灯显示模块

分频模块:

代码:

PROCESS(CLK1)

VARIABLETEMP1:INTEGERRANGE0TO500:=0;

BEGIN

IFCLK1'EVENTANDCLK1='0'THEN

TEMP1:=TEMP1+1;

IFTEMP1=500THEN

FOUT1<=NOTFOUT1;

TEMP1:=0;

ENDIF;

ENDIF;

ENDPROCESS;

仿真波形:clock设为1us,gridsize设为1ms,endtime设为200ms

计数模块:

代码:

IFFOUT1'EVENTANDFOUT1='0'THEN

IF(CNT_EN='1')THEN---计数使能为高则允许计数,否则说明计数溢出

CNT<=CNT+1;

ELSE

CNT<="000001"; ---计数溢出,赋初值

ENDIF;

仿真波形:clock设为1us,gridsize设为1ms,endtime设为200ms

状态控制模块:

由于状态模块代码较多,在最后给出全部代码。这里只给出一部分。

代码:

CASESTATEIS

WHENST0=>

IF(CNT=GREENA_CNT)THEN---根据计数转换状态

CASEPASS_STATE_INIS

WHEN"00"=>STATE<=ST0;

WHEN"01"=>STATE<=ST3;

WHEN"10"=>STATE<=ST0;

WHEN"11"=>STATE<=ST3;

WHENOTHERS=>NULL;

ENDCASE;

ELSE

STATE<=ST0;

ENDIF;

PROCESS(STATE)

BEGIN

CASESTATEIS

WHENST0=>---模拟红绿灯显示

LGTA_GREEN<='1';

LGTA_YELLOW<='0';

LGTA_RED<='0';

LGTB_GREEN<='0';

LGTB_YELLOW<='0';

LGTB_RED<='1';

CNT_EN<='1';

STATEOUT<="00"; ---传递亮灯状态给下一模块

IF(CNT=GREENA_CNT)THENCNT_EN<='0';ENDIF;

仿真波形:clock设为1us,gridsize设为1us,endtime为200us。

l数码管动态显示模块

位选信号循环模块:

代码:

PROCESS(CLK2)

VARIABLEBITSEL:STD_LOGIC_VECTOR(1DOWNTO0);

BEGIN

IFCLK2'EVENTANDCLK2='0'THEN

CASEBITSELIS

WHEN"00"=>BITSEL:="01";SELOUT<="01";

WHEN"01"=>BITSEL:="10";SELOUT<="10";

WHEN"10"=>BITSEL:="11";SELOUT<="11";

WHEN"11"=>BITSEL:="00";SELOUT<="00";

WHENOTHERS=>NULL;

ENDCASE;

ENDIF;

仿真波形:clock为1us,gridsize为1ms,endtime为200ms(已放大)

动态显示段选信号输出:(一小部分代码)

代码:

CASESTATEINIS

WHEN"00"=>---主绿支红状态

CASEBITSELIS

WHEN"00"=>---主绿支红状态点亮支干道个位数字CASECNTINIS

WHEN"000000"=>LED7SOUT<="0111111";---0050

WHEN"000001"=>LED7SOUT<="1101111";---0149

WHEN"000010"=>LED7SOUT<="1111111";

WHEN"000011"=>LED7SOUT<="0000111";

WHEN"000100"=>LED7SOUT<="1111101";

WHEN"000101"=>LED7SOUT<="1101101";

WHEN"000110"=>LED7SOUT<="1100110";---0644

WHEN"000111"=>LED7SOUT<="1001111";

WHEN"001000"=>LED7SOUT<="1011011";

WHEN"001001"=>LED7SOUT<="0000110";

WHEN"001010"=>LED7SOUT<="0111111";

WHEN"001011"=>LED7SOUT<="1101111";---1139

WHEN"001100"=>LED7SOUT<="1111111";

WHEN"001101"=>LED7SOUT<="0000111";

WHEN"001110"=>LED7SOUT<="1111101";

WHEN"001111"=>LED7SOUT<="1101101";

WHEN"010000"=>LED7SOUT<="1100110";---1634

WHEN"010001"=>LED7SOUT<="1001111";

WHEN"010010"=>LED7SOUT<="1011011";

WHEN"010011"=>LED7SOUT<="0000110";

WHEN"010100"=>LED7SOUT<="0111111";

WHEN"010101"=>LED7SOUT<="1101111";---2129

WHEN"010110"=>LED7SOUT<="1111111";

WHEN"010111"=>LED7SOUT<="0000111";

WHEN"011000"=>LED7SOUT<="1111101";

WHEN"011001"=>LED7SOUT<="1101101";

WHEN"011010"=>LED7SOUT<="1100110";---2624

WHEN"011011"=>LED7SOUT<="1001111";

WHEN"011100"=>LED7SOUT<="1011011";

WHEN"011101"=>LED7SOUT<="0000110";

WHEN"011110"=>LED7SOUT<="0111111";

WHEN"011111"=>LED7SOUT<="1101111";---3119

WHEN"100000"=>LED7SOUT<="1111111";

WHEN"100001"=>LED7SOUT<="0000111";

WHEN"100010"=>LED7SOUT<="1111101";

WHEN"100011"=>LED7SOUT<="1101101";

WHEN"100100"=>LED7SOUT<="1100110";---3614

WHEN"100101"=>LED7SOUT<="1001111";

WHEN"100110"=>LED7SOUT<="1011011";

WHEN"100111"=>LED7SOUT<="0000110";

WHEN"101000"=>LED7SOUT<="0111111";

WHEN"101001"=>LED7SOUT<="1101111";---4109

WHEN"101010"=>LED7SOUT<="1111111";

WHEN"101011"=>LED7SOUT<="0000111";

WHEN"101100"=>LED7SOUT<="1111101";

WHEN"101101"=>LED7SOUT<="1101101";---4505

WHENOTHERS=>NULL;

ENDCASE;

仿真波形:clock为1us,gridsize为1ms,endtime为200ms(已放大)

经过最终整合之后仿真波形如图:

l管脚绑定

五:硬件调试

程序下载之后在实验板按预期运行,完全符合设计要求,省去了不少调试所需的时间,这完全得益于前期的仔细规划和设计,最终得出满意的结果,也是想象之中的。

下面是实际的拍摄的效果图,左边2个数码管为主道路倒计时,右边2个数码管为支道路倒计时,左边3个二极管分别为模拟主道路的绿黄红灯,右边3个二极管分别为模拟支道路的绿黄红灯。

硬件调试录制的视频地址为:http://video.sina.com.cn/v/b/68500795-1639374987.html

更多波形仿真截图专辑:http://photo.blog.sina.com.cn/category/u/1639374987/s/410738

六:结论

本文利用硬件描述语言VHDL编程,借助Ahera公司的QuartusII软件进行了编译及仿真测试,通过FPGA芯片实现了一个实用的交通灯控制系统。设计由于采用了EDA技术,使用自上而下的设计方法,使设计过程清晰明了,简单易学。

七:参考文献

[1]潘松,黄继业,EDA技术与VHDL[M].清华大学出版社,2009

[2]刘欲晓,方强,黄宛宁等,EDA技术与VHDL电路开发应用实践[M].电子工业出版社2009:127-132

八:总结与体会

  在本学期学校给我们开设了EDA与VHDL这门课程,让我们更了解FPGA技术,知道如何去通过FPGA这门课程去设计电子系统,通过这次的课程设计,最直接的感触就是加强了与理论的联系,深化了理论知识,不仅如此,且听我娓娓道来。

  学期学习阶段,我们的步骤是学习基本的原理比如VHDL语言,状态机,然后就是实现基本的电路比如加法器、分频电路、显示模块等等,这些其实都是为后来构建系统做打好基础,也就是我们在学习阶段其实就是准备好了砖和瓦,等到真正做实际项目的时候就是砌墙的时候了,我很庆幸自己在硬件调试上是一次成功,完全符合系统要求,程序下载之后完全按预期的效果运行,这些都是想象之中的,正式因为前期对题目要求的仔细分析功能要求,然后一步一步,将系统自顶向下,分好各个模块,然后分别实现,各个击破,最终合成为一个整体,在整个过程中花了大约3天的时间,这三天的时间就是在实现各个模块,观察其仿真波形,当每一个仿真波形都达到了预期的效果之后我知道,离成功不远了,仿真过程中大量的截图记录了整个系统的实现过程。

在整个实现过程中,最耗时间的就是代码的编写与编译,因为这是一门新学的得语言,是一种硬件描述语言,和编程语言不一样,所以特性上也不一样,所以在代码的编写与调试过程中也占了大半的时间,当然带来的收获也是颇丰富的,不仅加深了对VHDL语言的理解,而且代码编写能力也得到了提高,不的不感谢这次课程设计给我带来各种收获。

再谈谈对altera公司qurtusII软件的使用收获,对该软件的使用主要是代码的编写与编译,以及波形的仿真,通过这次课程设计,由于进行了大量的波形仿真工作,大部分时间都是用来看仿真的波形,所以对波形的认识更加熟悉了,想当初看到一排波形高高低低,根本就不知道什么意思,但是实际做项目的时候,由于整个全局都掌控在自己手里,所以对波形的任何一个细节都了解的清清楚楚,所以通过这个项目让自己对波形的认识更进了一层认识,因而收获又体现在这一方面。

这次实验中又有些遗憾的内容,由于整个项目是基于实验室的开发板,所以对硬件的线路上的设计并不太清楚,只是知道大概,因为我们的实验成品只需建立在该开发板上,所以在底层的实现并没有涉及觉得有些遗憾,因为真正的项目是需要从最底层做起,直至整个项目成品完成,期待下一次的机会!

最后在结束处感谢两周以来对我们进行悉心指导的任课教师付老师,是他给我们画龙点睛,在我们遭遇瓶颈的时候帮助我们渡过难关,才有了最后的成功,谢谢老师!

源代码:

一:

顶层文件:

------------------------作者信息-------------------------
-- 华东交通大学 电气电子工程学院
-- 电子信息工程2009-1 陈磊
------------------------文件信息-------------------------
--文件名: TRAFFIC_LIGHT_CONTROL.VHD
--完成日期: 2011.12.22
--最后版本: 1.0
--描述: 自动交通控制系统顶层文件
---------------------------------------------------------

LIBRARY IEEE; ---自动交通灯控制系统顶层描述
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;

----------------------------------------------------------------------------------------------------------------------------------------------

ENTITY TRAFFIC_LIGHT_CONTROL IS
PORT ( CLK : IN STD_LOGIC; ---1kHz信号时钟输入
PASS_STATE : IN STD_LOGIC_VECTOR(1 DOWNTO 0);---主支通道的通车情况,低位为支通道高位为主通道,0为无车1为有车
AGREEN : OUT STD_LOGIC; ---主通道绿灯控制信号
AYELLOW : OUT STD_LOGIC; ---主通道黄灯控制信号
ARED : OUT STD_LOGIC; ---主通道红灯控制信号
BGREEN : OUT STD_LOGIC; ---主通道绿灯控制信号
BYELLOW : OUT STD_LOGIC; ---主通道黄灯控制信号
BRED : OUT STD_LOGIC; ---主通道红灯控制信号
SEL : OUT STD_LOGIC_VECTOR(1 DOWNTO 0); ---输出数码管位选信号
LED7S : OUT STD_LOGIC_VECTOR(6 DOWNTO 0) ---输出数码管段选信号
);
END ENTITY TRAFFIC_LIGHT_CONTROL;

----------------------------------------------------------------------------------------------------------------------------------------------

ARCHITECTURE LAZY OF TRAFFIC_LIGHT_CONTROL IS

--------------------------------------调用状态控制模块----------------------------------------------

COMPONENT STATE_CONTROL
PORT ( CLK1 : IN STD_LOGIC; ---1kHz时钟信号输入
PASS_STATE_IN : IN STD_LOGIC_VECTOR(1 DOWNTO 0);---主支通道的通车情况,低位为支通道高位为主通道,0为无车1为有车
LGTA_RED : OUT STD_LOGIC; ---主通道红灯控制信号
LGTA_GREEN : OUT STD_LOGIC; ---主通道绿灯控制信号
LGTA_YELLOW : OUT STD_LOGIC; ---主通道黄灯控制信号
LGTB_RED : OUT STD_LOGIC; ---支通道红灯控制信号
LGTB_GREEN : OUT STD_LOGIC; ---支通道绿灯控制信号
LGTB_YELLOW : OUT STD_LOGIC; ---支通道黄灯控制信号
CNTOUT : OUT STD_LOGIC_VECTOR(5 DOWNTO 0); ---已计数时间输出
STATEOUT : OUT STD_LOGIC_VECTOR(1 DOWNTO 0) ---状态输出,传递给数码显示模块
);
END COMPONENT;

-------------------------------------调用数码管显示模块---------------------------------------------

COMPONENT DISPLAY
PORT ( CLK2 : IN STD_LOGIC; ---1kHz时钟信号输入
CNTIN : IN STD_LOGIC_VECTOR(5 DOWNTO 0); ---亮灯已过时间输入
STATEIN : IN STD_LOGIC_VECTOR(1 DOWNTO 0); ---状态输入
LED7SOUT : OUT STD_LOGIC_VECTOR(6 DOWNTO 0); ---数码管段选信号输出
SELOUT : OUT STD_LOGIC_VECTOR(1 DOWNTO 0) ---数码管位选信号输出
);
END COMPONENT;

----------------------------------------元件例化-----------------------------------------------------

SIGNAL MSTATE : STD_LOGIC_VECTOR(1 DOWNTO 0); ---中间信号传递通车状态
SIGNAL MCNT : STD_LOGIC_VECTOR(5 DOWNTO 0); ---中间信号传递亮灯已计数时间

BEGIN ---例化语句
U1: STATE_CONTROL PORT MAP (CLK1=>CLK,PASS_STATE_IN=>PASS_STATE,LGTB_RED=>BRED, LGTB_GREEN=>BGREEN,LGTB_YELLOW=>BYELLOW, LGTA_RED=>ARED,LGTA_GREEN=>AGREEN,LGTA_YELLOW=>AYELLOW, CNTOUT=>MCNT,STATEOUT=>MSTATE);
U2: DISPLAY PORT MAP(CLK2=>CLK,CNTIN=>MCNT,STATEIN=>MSTATE,LED7SOUT=>LED7S,SELOUT=>SEL);

END ARCHITECTURE LAZY;

----------------------------------------------------------------------------------------------------------------------------------------------

二:状态控制模块

--------------------作者信息----------------------
-- 华东交通大学 电气电子工程学院
-- 电子信息工程2009-1 陈磊
--------------------文件信息----------------------
--文件名: STATE_CONTROL.VHD
--完成日期: 2011.12.22
--最后版本: 1.0
--描述: 自动交通控制系统状态转换控制模块
--------------------------------------------------

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;

---------------------------------------------分频及状态控制模块----------------------------------------------------------

ENTITY STATE_CONTROL IS
GENERIC ( GREENA_CNT:INTEGER:=45; ---主通道绿灯亮的时间45s
YELLOWA_CNT:INTEGER:=4; ---主通道黄灯亮的时间4s
GREENB_CNT:INTEGER:=25; ---支通道绿灯亮的时间25s
YELLOWB_CNT:INTEGER:=4 ---支通道黄灯亮的时间4s
);
PORT ( CLK1 : IN STD_LOGIC; ---1kHz时钟信号输入
PASS_STATE_IN : IN STD_LOGIC_VECTOR(1 DOWNTO 0);---主支通道的通车情况,低位为支通道高位为主通道,0为无车1为有车
LGTA_RED : OUT STD_LOGIC; ---主通道红灯控制信号
LGTA_GREEN : OUT STD_LOGIC; ---主通道绿灯控制信号
LGTA_YELLOW : OUT STD_LOGIC; ---主通道黄灯控制信号
LGTB_RED : OUT STD_LOGIC; ---支通道红灯控制信号
LGTB_GREEN : OUT STD_LOGIC; ---支通道绿灯控制信号
LGTB_YELLOW : OUT STD_LOGIC; ---支通道黄灯控制信号
CNTOUT : OUT STD_LOGIC_VECTOR(5 DOWNTO 0); ---已计数时间输出
STATEOUT : OUT STD_LOGIC_VECTOR(1 DOWNTO 0) ---剩余时间输出显示
);
END ENTITY STATE_CONTROL;

------------------------------------------------------------------------------------------------------------------------

ARCHITECTURE RTL OF STATE_CONTROL IS
TYPE STATES IS (ST0,ST1,ST2,ST3);---4个状态分别为【主绿支红45s、支绿主红25s、支黄主红4s、主黄支红4s】
SIGNAL STATE : STATES:=ST0; ---初始化状态为状态0
SIGNAL CNT_EN : STD_LOGIC:='0'; ---计数使能控制信号,初始不计数
SIGNAL CNT : STD_LOGIC_VECTOR(5 DOWNTO 0):="000001";---因为初始不计数,但已过一个周期,所以初值为1
SIGNAL FOUT1 : STD_LOGIC; --1Hz时钟信号内部输出,作为状态转换控制时钟
BEGIN
----------------------------------------------分频模块---------------------------------------------------------------

PROCESS(CLK1) ---分频模块:输入为1kHz输出为1Hz
VARIABLE TEMP1 :INTEGER RANGE 0 TO 500:=0;
BEGIN
IF CLK1'EVENT AND CLK1 = '0' THEN
TEMP1 := TEMP1+1;
IF TEMP1=500 THEN
FOUT1<= NOT FOUT1;---此模块输出分频比为1/1000的信号时钟,供状态控制模块使用
TEMP1:=0;
END IF;
END IF;
END PROCESS;

--------------------------------------------状态循环控制模块--------------------------------------------

PROCESS (FOUT1)
BEGIN
IF FOUT1'EVENT AND FOUT1='0' THEN

--------------------------------------------------------------------------------

IF (CNT_EN='1') THEN ---计数模块
CNT<=CNT+1;
ELSE
CNT<="000001"; ---若溢出则计数使能为0,CNT重新赋值为1
END IF;

--------------------------------------------------------------------------------

CASE STATE IS ---状态循环控制模块
WHEN ST0 =>
IF (CNT=GREENA_CNT) THEN ---主绿支红若计数满45s则根据主支通道的通车情况决定转入下一个状态
CASE PASS_STATE_IN IS
WHEN "00" => STATE<=ST0;
WHEN "01" => STATE<=ST3;
WHEN "10" => STATE<=ST0;
WHEN "11" => STATE<=ST3;
WHEN OTHERS => NULL;
END CASE;
ELSE
STATE<=ST0; ---若计数未满则为原来状态
END IF;
WHEN ST1 =>---支绿主红若计数满25s则根据主支通道的通车情况决定转入下一个状态
IF (CNT=GREENB_CNT) THEN
CASE PASS_STATE_IN IS
WHEN "00" => STATE<=ST0;
WHEN "01" => STATE<=ST1;
WHEN "10" => STATE<=ST2;
WHEN "11" => STATE<=ST2;
WHEN OTHERS => NULL;
END CASE;
ELSE
STATE<=ST1; ---若计数未满则为原来状态
END IF;
WHEN ST2 => ---支黄主红若计数满4s则根据主支通道的通车情况决定转入下一个状态
IF (CNT=YELLOWA_CNT) THEN
CASE PASS_STATE_IN IS
WHEN "10" => STATE<=ST0;
WHEN "11" => STATE<=ST0;
WHEN OTHERS => NULL;
END CASE;
ELSE
STATE<=ST2; ---若计数未满则为原来状态
END IF;
WHEN ST3 => ---主黄支红若计数满4s则根据主支通道的通车情况决定转入下一个状态
IF (CNT=YELLOWA_CNT) THEN
CASE PASS_STATE_IN IS
WHEN "01" => STATE<=ST1;
WHEN "11" => STATE<=ST1;
WHEN OTHERS => NULL;
END CASE;
ELSE
STATE<=ST3; ---若计数未满则为原来状态
END IF;
END CASE;
END IF;
CNTOUT<=CNT;
END PROCESS;

-----------------------------------------------红绿灯显示模块-----------------------------------------

PROCESS (STATE)
BEGIN
CASE STATE IS
WHEN ST0 => ---状态0时主绿支红
LGTA_GREEN<='1';
LGTA_YELLOW<='0';
LGTA_RED<='0';
LGTB_GREEN<='0';
LGTB_YELLOW<='0';
LGTB_RED<='1';
CNT_EN<='1';
STATEOUT<="00"; ---将当前状态传递给数码管显示模块,以供后续使用
IF (CNT=GREENA_CNT) THEN CNT_EN<='0'; END IF;
WHEN ST1 => ---状态1时支绿主红
LGTA_GREEN<='0';
LGTA_YELLOW<='0';
LGTA_RED<='1';
LGTB_GREEN<='1';
LGTB_YELLOW<='0';
LGTB_RED<='0';
CNT_EN<='1';
STATEOUT<="01"; ---将当前状态传递给数码管显示模块,以供后续使用
IF (CNT=GREENB_CNT) THEN CNT_EN<='0'; END IF;
WHEN ST2 => ---状态2时主绿支红
LGTA_GREEN<='0';
LGTA_YELLOW<='0';
LGTA_RED<='1';
LGTB_GREEN<='0';
LGTB_YELLOW<='1';
LGTB_RED<='0';
CNT_EN<='1';
STATEOUT<="10"; ---将当前状态传递给数码管显示模块,以供后续使用
IF (CNT=YELLOWB_CNT) THEN CNT_EN<='0'; END IF;
WHEN ST3 => ---状态3时主黄支红
LGTA_GREEN<='0';
LGTA_YELLOW<='1';
LGTA_RED<='0';
LGTB_GREEN<='0';
LGTB_YELLOW<='0';
LGTB_RED<='1';
CNT_EN<='1';
STATEOUT<="11"; ---将当前状态传递给数码管显示模块,以供后续使用
IF (CNT=YELLOWA_CNT) THEN CNT_EN<='0'; END IF;
END CASE;
END PROCESS;
END RTL;

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

三:动态显示模块


--------------------作者信息----------------------
-- 华东交通大学 电气电子工程学院
-- 电子信息工程2009-1 陈磊
--------------------文件信息----------------------
--文件名: DISPALY.VHD
--完成日期: 2011.12.22
--最后版本: 1.0
--描述: 自动交通控制系统倒计时动态显示模块
--------------------------------------------------

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;

-------------------------------------------数码管动态显示显示模块----------------------------------------------------

ENTITY DISPLAY IS
PORT ( CLK2 : IN STD_LOGIC; ---时钟输入
CNTIN : IN STD_LOGIC_VECTOR(5 DOWNTO 0); ---已计数输入,来自状态控制模块
STATEIN : IN STD_LOGIC_VECTOR(1 DOWNTO 0); ---状态输入,来自状态控制模块
LED7SOUT : OUT STD_LOGIC_VECTOR(6 DOWNTO 0); ---数码管段选信号输出
SELOUT : OUT STD_LOGIC_VECTOR(1 DOWNTO 0) ---数码管位选信号输出
);
END ENTITY DISPLAY;

---------------------------------------------------------------------------------------------------------------------

ARCHITECTURE ONE OF DISPLAY IS

基于FPGA的自动交通灯控制系统设计 模拟交通灯控制系统
BEGIN

PROCESS(CLK2)
VARIABLE BITSEL : STD_LOGIC_VECTOR(1 DOWNTO 0);
BEGIN

-----------------------------位选信号循环模块-----------------------------------------------

IF CLK2'EVENT AND CLK2='0' THEN
CASE BITSEL IS
WHEN "00" => BITSEL:="01";SELOUT<="01";
WHEN "01" => BITSEL:="10";SELOUT<="10";
WHEN "10" => BITSEL:="11";SELOUT<="11";
WHEN "11" => BITSEL:="00";SELOUT<="00";
WHEN OTHERS => NULL;
END CASE;
END IF;

-------------------------动态显示模块------------------------------------------------

CASE STATEIN IS
WHEN "00" => ---主绿支红状态 OK
CASE BITSEL IS
WHEN "00" => ---主绿支红状态 点亮支干道个位数字 OK
CASE CNTIN IS
WHEN "000000" => LED7SOUT <="0111111"; ---00 50
WHEN "000001" => LED7SOUT <="1101111"; ---01 49
WHEN "000010" => LED7SOUT <="1111111";
WHEN "000011" => LED7SOUT <="0000111";
WHEN "000100" => LED7SOUT <="1111101";
WHEN "000101" => LED7SOUT <="1101101";
WHEN "000110" => LED7SOUT <="1100110"; ---06 44
WHEN "000111" => LED7SOUT <="1001111";
WHEN "001000" => LED7SOUT <="1011011";
WHEN "001001" => LED7SOUT <="0000110";
WHEN "001010" => LED7SOUT <="0111111";
WHEN "001011" => LED7SOUT <="1101111"; ---11 39
WHEN "001100" => LED7SOUT <="1111111";
WHEN "001101" => LED7SOUT <="0000111";
WHEN "001110" => LED7SOUT <="1111101";
WHEN "001111" => LED7SOUT <="1101101";
WHEN "010000" => LED7SOUT <="1100110"; ---16 34
WHEN "010001" => LED7SOUT <="1001111";
WHEN "010010" => LED7SOUT <="1011011";
WHEN "010011" => LED7SOUT <="0000110";
WHEN "010100" => LED7SOUT <="0111111";
WHEN "010101" => LED7SOUT <="1101111"; ---21 29
WHEN "010110" => LED7SOUT <="1111111";
WHEN "010111" => LED7SOUT <="0000111";
WHEN "011000" => LED7SOUT <="1111101";
WHEN "011001" => LED7SOUT <="1101101";
WHEN "011010" => LED7SOUT <="1100110"; ---26 24
WHEN "011011" => LED7SOUT <="1001111";
WHEN "011100" => LED7SOUT <="1011011";
WHEN "011101" => LED7SOUT <="0000110";
WHEN "011110" => LED7SOUT <="0111111";
WHEN "011111" => LED7SOUT <="1101111"; ---31 19
WHEN "100000" => LED7SOUT <="1111111";
WHEN "100001" => LED7SOUT <="0000111";
WHEN "100010" => LED7SOUT <="1111101";
WHEN "100011" => LED7SOUT <="1101101";
WHEN "100100" => LED7SOUT <="1100110"; ---36 14
WHEN "100101" => LED7SOUT <="1001111";
WHEN "100110" => LED7SOUT <="1011011";
WHEN "100111" => LED7SOUT <="0000110";
WHEN "101000" => LED7SOUT <="0111111";
WHEN "101001" => LED7SOUT <="1101111"; ---41 09
WHEN "101010" => LED7SOUT <="1111111";
WHEN "101011" => LED7SOUT <="0000111";
WHEN "101100" => LED7SOUT <="1111101";
WHEN "101101" => LED7SOUT <="1101101"; ---45 05
WHEN OTHERS => NULL;
END CASE;
WHEN "01" => ---主绿支红状态 点亮支干道十位数字 OK
CASE CNTIN IS
WHEN "000000" => LED7SOUT <="1101101"; ---00 50
WHEN "000001" => LED7SOUT <="1100110"; ---01 49
WHEN "000010" => LED7SOUT <="1100110";
WHEN "000011" => LED7SOUT <="1100110";
WHEN "000100" => LED7SOUT <="1100110";
WHEN "000101" => LED7SOUT <="1100110"; ---05 45
WHEN "000110" => LED7SOUT <="1100110";
WHEN "000111" => LED7SOUT <="1100110";
WHEN "001000" => LED7SOUT <="1100110";
WHEN "001001" => LED7SOUT <="1100110";
WHEN "001010" => LED7SOUT <="1100110"; ---10 40
WHEN "001011" => LED7SOUT <="1001111";
WHEN "001100" => LED7SOUT <="1001111";
WHEN "001101" => LED7SOUT <="1001111";
WHEN "001110" => LED7SOUT <="1001111";
WHEN "001111" => LED7SOUT <="1001111"; ---15 35
WHEN "010000" => LED7SOUT <="1001111";
WHEN "010001" => LED7SOUT <="1001111";
WHEN "010010" => LED7SOUT <="1001111";
WHEN "010011" => LED7SOUT <="1001111";
WHEN "010100" => LED7SOUT <="1001111"; ---20 30
WHEN "010101" => LED7SOUT <="1011011";
WHEN "010110" => LED7SOUT <="1011011";
WHEN "010111" => LED7SOUT <="1011011";
WHEN "011000" => LED7SOUT <="1011011";
WHEN "011001" => LED7SOUT <="1011011"; ---25 25
WHEN "011010" => LED7SOUT <="1011011";
WHEN "011011" => LED7SOUT <="1011011";
WHEN "011100" => LED7SOUT <="1011011";
WHEN "011101" => LED7SOUT <="1011011";
WHEN "011110" => LED7SOUT <="1011011"; ---30 20
WHEN "011111" => LED7SOUT <="0000110";
WHEN "100000" => LED7SOUT <="0000110";
WHEN "100001" => LED7SOUT <="0000110";
WHEN "100010" => LED7SOUT <="0000110";
WHEN "100011" => LED7SOUT <="0000110"; ---35 15
WHEN "100100" => LED7SOUT <="0000110";
WHEN "100101" => LED7SOUT <="0000110";
WHEN "100110" => LED7SOUT <="0000110";
WHEN "100111" => LED7SOUT <="0000110";
WHEN "101000" => LED7SOUT <="0000110"; ---40 10
WHEN "101001" => LED7SOUT <="0111111";
WHEN "101010" => LED7SOUT <="0111111";
WHEN "101011" => LED7SOUT <="0111111";
WHEN "101100" => LED7SOUT <="0111111";
WHEN "101101" => LED7SOUT <="0111111"; ---45 05
WHEN OTHERS => NULL;
END CASE;
WHEN "10" => ---主绿支红状态 点亮主干道个位数字 OK
CASE CNTIN IS
WHEN "000000" => LED7SOUT <="1111101"; ---00 46
WHEN "000001" => LED7SOUT <="1101101"; ---01 45
WHEN "000010" => LED7SOUT <="1100110";
WHEN "000011" => LED7SOUT <="1001111";
WHEN "000100" => LED7SOUT <="1011011";
WHEN "000101" => LED7SOUT <="0000110";
WHEN "000110" => LED7SOUT <="0111111"; ---06 40
WHEN "000111" => LED7SOUT <="1101111";
WHEN "001000" => LED7SOUT <="1111111";
WHEN "001001" => LED7SOUT <="0000111";
WHEN "001010" => LED7SOUT <="1111101";
WHEN "001011" => LED7SOUT <="1101101"; ---11 35
WHEN "001100" => LED7SOUT <="1100110";
WHEN "001101" => LED7SOUT <="1001111";
WHEN "001110" => LED7SOUT <="1011011";
WHEN "001111" => LED7SOUT <="0000110";
WHEN "010000" => LED7SOUT <="0111111"; ---16 30
WHEN "010001" => LED7SOUT <="1101111";
WHEN "010010" => LED7SOUT <="1111111";
WHEN "010011" => LED7SOUT <="0000111";
WHEN "010100" => LED7SOUT <="1111101";
WHEN "010101" => LED7SOUT <="1101101"; ---21 25
WHEN "010110" => LED7SOUT <="1100110";
WHEN "010111" => LED7SOUT <="1001111";
WHEN "011000" => LED7SOUT <="1011011";
WHEN "011001" => LED7SOUT <="0000110";
WHEN "011010" => LED7SOUT <="0111111"; ---26 20
WHEN "011011" => LED7SOUT <="1101111";
WHEN "011100" => LED7SOUT <="1111111";
WHEN "011101" => LED7SOUT <="0000111";
WHEN "011110" => LED7SOUT <="1111101";
WHEN "011111" => LED7SOUT <="1101101"; ---31 15
WHEN "100000" => LED7SOUT <="1100110";
WHEN "100001" => LED7SOUT <="1001111";
WHEN "100010" => LED7SOUT <="1011011";
WHEN "100011" => LED7SOUT <="0000110";
WHEN "100100" => LED7SOUT <="0111111"; ---35 10
WHEN "100101" => LED7SOUT <="1101111";
WHEN "100110" => LED7SOUT <="1111111";
WHEN "100111" => LED7SOUT <="0000111";
WHEN "101000" => LED7SOUT <="1111101";
WHEN "101001" => LED7SOUT <="1101101";
WHEN "101010" => LED7SOUT <="1100110";
WHEN "101011" => LED7SOUT <="1001111";
WHEN "101100" => LED7SOUT <="1011011";
WHEN "101101" => LED7SOUT <="0000110"; ---45 01
WHEN OTHERS => NULL;
END CASE;
WHEN "11" => ---主绿支红状态 点亮主干道十位数字 OK
CASE CNTIN IS
WHEN "000000" => LED7SOUT <="1100110"; ---00 46
WHEN "000001" => LED7SOUT <="1100110";
WHEN "000010" => LED7SOUT <="1100110";
WHEN "000011" => LED7SOUT <="1100110";
WHEN "000100" => LED7SOUT <="1100110";
WHEN "000101" => LED7SOUT <="1100110"; ---05 41
WHEN "000110" => LED7SOUT <="1100110";
WHEN "000111" => LED7SOUT <="1001111";
WHEN "001000" => LED7SOUT <="1001111";
WHEN "001001" => LED7SOUT <="1001111";
WHEN "001010" => LED7SOUT <="1001111"; ---10 36
WHEN "001011" => LED7SOUT <="1001111";
WHEN "001100" => LED7SOUT <="1001111";
WHEN "001101" => LED7SOUT <="1001111";
WHEN "001110" => LED7SOUT <="1001111";
WHEN "001111" => LED7SOUT <="1001111"; ---15 31
WHEN "010000" => LED7SOUT <="1001111";
WHEN "010001" => LED7SOUT <="1011011";
WHEN "010010" => LED7SOUT <="1011011";
WHEN "010011" => LED7SOUT <="1011011";
WHEN "010100" => LED7SOUT <="1011011"; ---20 26
WHEN "010101" => LED7SOUT <="1011011";
WHEN "010110" => LED7SOUT <="1011011";
WHEN "010111" => LED7SOUT <="1011011";
WHEN "011000" => LED7SOUT <="1011011";
WHEN "011001" => LED7SOUT <="1011011"; ---25 21
WHEN "011010" => LED7SOUT <="1011011";
WHEN "011011" => LED7SOUT <="0000110";
WHEN "011100" => LED7SOUT <="0000110";
WHEN "011101" => LED7SOUT <="0000110";
WHEN "011110" => LED7SOUT <="0000110"; ---30 16
WHEN "011111" => LED7SOUT <="0000110";
WHEN "100000" => LED7SOUT <="0000110";
WHEN "100001" => LED7SOUT <="0000110";
WHEN "100010" => LED7SOUT <="0000110";
WHEN "100011" => LED7SOUT <="0000110"; ---35 11
WHEN "100100" => LED7SOUT <="0000110"; ---36 10
WHEN "100101" => LED7SOUT <="0111111";
WHEN "100110" => LED7SOUT <="0111111";
WHEN "100111" => LED7SOUT <="0111111";
WHEN "101000" => LED7SOUT <="0111111";
WHEN "101001" => LED7SOUT <="0111111";
WHEN "101010" => LED7SOUT <="0111111";
WHEN "101011" => LED7SOUT <="0111111";
WHEN "101100" => LED7SOUT <="0111111";
WHEN "101101" => LED7SOUT <="0111111"; ---45 01
WHEN OTHERS => NULL;
END CASE;
WHEN OTHERS => NULL;
END CASE;

-------------------------------------------------------------------------

WHEN "01" => ---支绿主红状态 OK
CASE BITSEL IS
WHEN "00" => ---支绿主红状态 点亮支干道个位数字 OK
CASE CNTIN IS
WHEN "000001" => LED7SOUT <="1101101"; ---01 25
WHEN "000010" => LED7SOUT <="1100110";
WHEN "000011" => LED7SOUT <="1001111";
WHEN "000100" => LED7SOUT <="1011011";
WHEN "000101" => LED7SOUT <="0000110";
WHEN "000110" => LED7SOUT <="0111111"; ---06 20
WHEN "000111" => LED7SOUT <="1101111";
WHEN "001000" => LED7SOUT <="1111111";
WHEN "001001" => LED7SOUT <="0000111";
WHEN "001010" => LED7SOUT <="1111101";
WHEN "001011" => LED7SOUT <="1101101"; ---11 15
WHEN "001100" => LED7SOUT <="1100110";
WHEN "001101" => LED7SOUT <="1001111";
WHEN "001110" => LED7SOUT <="1011011";
WHEN "001111" => LED7SOUT <="0000110";
WHEN "010000" => LED7SOUT <="0111111"; ---16 10
WHEN "010001" => LED7SOUT <="1101111";
WHEN "010010" => LED7SOUT <="1111111";
WHEN "010011" => LED7SOUT <="0000111";
WHEN "010100" => LED7SOUT <="1111101";
WHEN "010101" => LED7SOUT <="1101101"; ---21 05
WHEN "010110" => LED7SOUT <="1100110";
WHEN "010111" => LED7SOUT <="1001111";
WHEN "011000" => LED7SOUT <="1011011";
WHEN "011001" => LED7SOUT <="0000110"; ---25 01
WHEN OTHERS => NULL;
END CASE;
WHEN "01" => ---支绿主红状态 点亮支干道十位数字 OK
CASE CNTIN IS
WHEN "000001" => LED7SOUT <="1011011"; ---01 25
WHEN "000010" => LED7SOUT <="1011011";
WHEN "000011" => LED7SOUT <="1011011";
WHEN "000100" => LED7SOUT <="1011011";
WHEN "000101" => LED7SOUT <="1011011";
WHEN "000110" => LED7SOUT <="1011011"; ---06 20
WHEN "000111" => LED7SOUT <="0000110";
WHEN "001000" => LED7SOUT <="0000110";
WHEN "001001" => LED7SOUT <="0000110";
WHEN "001010" => LED7SOUT <="0000110";
WHEN "001011" => LED7SOUT <="0000110"; ---11 15
WHEN "001100" => LED7SOUT <="0000110";
WHEN "001101" => LED7SOUT <="0000110";
WHEN "001110" => LED7SOUT <="0000110";
WHEN "001111" => LED7SOUT <="0000110";
WHEN "010000" => LED7SOUT <="0000110"; ---16 10
WHEN "010001" => LED7SOUT <="0111111";
WHEN "010010" => LED7SOUT <="0111111";
WHEN "010011" => LED7SOUT <="0111111";
WHEN "010100" => LED7SOUT <="0111111";
WHEN "010101" => LED7SOUT <="0111111"; ---21 05
WHEN "010110" => LED7SOUT <="0111111";
WHEN "010111" => LED7SOUT <="0111111";
WHEN "011000" => LED7SOUT <="0111111";
WHEN "011001" => LED7SOUT <="0111111"; ---25 01
WHEN OTHERS => NULL;
END CASE;
WHEN"10" => ---支绿主红状态 点亮主干道个位数字 OK
CASE CNTIN IS
WHEN "000001" => LED7SOUT <="1101111"; ---01 29
WHEN "000010" => LED7SOUT <="1111111";
WHEN "000011" => LED7SOUT <="0000111";
WHEN "000100" => LED7SOUT <="1111101";
WHEN "000101" => LED7SOUT <="1101101";
WHEN "000110" => LED7SOUT <="1100110"; ---06 24
WHEN "000111" => LED7SOUT <="1001111";
WHEN "001000" => LED7SOUT <="1011011";
WHEN "001001" => LED7SOUT <="0000110";
WHEN "001010" => LED7SOUT <="0111111";
WHEN "001011" => LED7SOUT <="1101111"; ---11 19
WHEN "001100" => LED7SOUT <="1111111";
WHEN "001101" => LED7SOUT <="0000111";
WHEN "001110" => LED7SOUT <="1111101";
WHEN "001111" => LED7SOUT <="1101101";
WHEN "010000" => LED7SOUT <="1100110"; ---16 14
WHEN "010001" => LED7SOUT <="1001111";
WHEN "010010" => LED7SOUT <="1011011";
WHEN "010011" => LED7SOUT <="0000110";
WHEN "010100" => LED7SOUT <="0111111";
WHEN "010101" => LED7SOUT <="1101111"; ---21 09
WHEN "010110" => LED7SOUT <="1111111";
WHEN "010111" => LED7SOUT <="0000111";
WHEN "011000" => LED7SOUT <="1111101";
WHEN "011001" => LED7SOUT <="1101101"; ---25 05
WHEN OTHERS => NULL;
END CASE;
WHEN "11" => ---支绿主红状态 点亮主干道十位数字 OK
CASE CNTIN IS
WHEN "000001" => LED7SOUT <="1011011"; ---01 29
WHEN "000010" => LED7SOUT <="1011011";
WHEN "000011" => LED7SOUT <="1011011";
WHEN "000100" => LED7SOUT <="1011011";
WHEN "000101" => LED7SOUT <="1011011"; ---05 25
WHEN "000110" => LED7SOUT <="1011011";
WHEN "000111" => LED7SOUT <="1011011";
WHEN "001000" => LED7SOUT <="1011011";
WHEN "001001" => LED7SOUT <="1011011";
WHEN "001010" => LED7SOUT <="1011011"; ---10 20
WHEN "001011" => LED7SOUT <="0000110";
WHEN "001100" => LED7SOUT <="0000110";
WHEN "001101" => LED7SOUT <="0000110";
WHEN "001110" => LED7SOUT <="0000110";
WHEN "001111" => LED7SOUT <="0000110"; ---15 15
WHEN "010000" => LED7SOUT <="0000110";
WHEN "010001" => LED7SOUT <="0000110";
WHEN "010010" => LED7SOUT <="0000110";
WHEN "010011" => LED7SOUT <="0000110";
WHEN "010100" => LED7SOUT <="0000110"; ---20 10
WHEN "010101" => LED7SOUT <="0111111";
WHEN "010110" => LED7SOUT <="0111111";
WHEN "010111" => LED7SOUT <="0111111";
WHEN "011000" => LED7SOUT <="0111111";
WHEN "011001" => LED7SOUT <="0111111"; ---25 05
WHEN OTHERS => NULL;
END CASE;
WHEN OTHERS => NULL;
END CASE;

--------------------------------------------------------------------------

WHEN "10" => ---支黄主红状态 OK
CASE BITSEL IS
WHEN "00" => ---支黄主红状态 点亮支干道个位数字
CASE CNTIN IS
WHEN "000001" => LED7SOUT <="1100110";
WHEN "000010" => LED7SOUT <="1001111";
WHEN "000011" => LED7SOUT <="1011011";
WHEN "000100" => LED7SOUT <="0000110";
WHEN OTHERS => NULL;
END CASE;
WHEN "01" => ---支黄主红状态 点亮支干道十位数字
CASE CNTIN IS
WHEN "000001" => LED7SOUT <="0111111";
WHEN "000010" => LED7SOUT <="0111111";
WHEN "000011" => LED7SOUT <="0111111";
WHEN "000100" => LED7SOUT <="0111111";
WHEN OTHERS => NULL;
END CASE;
WHEN "10" => ---支黄主红状态 点亮主干道个位数字
CASE CNTIN IS
WHEN "000001" => LED7SOUT <="1100110";
WHEN "000010" => LED7SOUT <="1001111";
WHEN "000011" => LED7SOUT <="1011011";
WHEN "000100" => LED7SOUT <="0000110";
WHEN OTHERS => NULL;
END CASE;
WHEN "11" => ---支黄主红状态 点亮主干道十位数字
CASE CNTIN IS
WHEN "000001" => LED7SOUT <="0111111";
WHEN "000010" => LED7SOUT <="0111111";
WHEN "000011" => LED7SOUT <="0111111";
WHEN "000100" => LED7SOUT <="0111111";
WHEN OTHERS => NULL;
END CASE;
WHEN OTHERS => NULL;
END CASE;

--------------------------------------------------------------------------

WHEN "11" => ---主黄支红状态 OK
CASE BITSEL IS
WHEN "00" => ---主黄支红状态 点亮支干道个位数字
CASE CNTIN IS
WHEN "000001" => LED7SOUT <="1100110";
WHEN "000010" => LED7SOUT <="1001111";
WHEN "000011" => LED7SOUT <="1011011";
WHEN "000100" => LED7SOUT <="0000110";
WHEN OTHERS => NULL;
END CASE;
WHEN "01" => ---主黄支红状态 点亮支干道十位数字
CASE CNTIN IS
WHEN "000001" => LED7SOUT <="0111111";
WHEN "000010" => LED7SOUT <="0111111";
WHEN "000011" => LED7SOUT <="0111111";
WHEN "000100" => LED7SOUT <="0111111";
WHEN OTHERS => NULL;
END CASE;
WHEN"10" => ---主黄支红状态 点亮主干道个位数字
CASE CNTIN IS
WHEN "000001" => LED7SOUT <="1100110";
WHEN "000010" => LED7SOUT <="1001111";
WHEN "000011" => LED7SOUT <="1011011";
WHEN "000100" => LED7SOUT <="0000110";
WHEN OTHERS => NULL;
END CASE;
WHEN "11"=> ---主黄支红状态 点亮主干道十位数字
CASE CNTIN IS
WHEN "000001" => LED7SOUT <="0111111";
WHEN "000010" => LED7SOUT <="0111111";
WHEN "000011" => LED7SOUT <="0111111";
WHEN "000100" => LED7SOUT <="0111111";
WHEN OTHERS => NULL;
END CASE;
WHEN OTHERS => NULL;
END CASE;

-------------------------------------------------------------------------------------

END CASE;
END PROCESS;
END ONE;

----------------------------------------------------------------------------------------------------------------------

  

爱华网本文地址 » http://www.413yy.cn/a/25101015/241284.html

更多阅读

win7系统如何显示隐藏的文件扩展名 win7系统隐藏的文件夹

win7系统如何显示隐藏的文件扩展名——简介有时候我们需要修改文件的扩展名,但是发现直接修改扩展名后不起作用,那是因为你修改的其实只是文件名,而扩展名在win7系统下默认是隐藏的,需要手动调整为显示文件扩展名。win7系统如何显示隐

怎样开启u盘的自动播放功能 大灯感光自动开启功能

由于病毒或者认为的原因,我们插入优盘的时候不再提示自动播放窗口,怎么样重新开启呢?怎样开启u盘的自动播放功能——步骤/方法怎样开启u盘的自动播放功能 1、首先我们打开开始菜单,找到搜索框。

怎样关闭WIN7系统的自动更新 win10取消系统自动更新

大多数朋友可能会遇上WIN7系统关机时出现自动更新延长关机时间,导致有急事无法快速关机拔电源。下面提供一个解决办法,有效地解决这个问题。怎样关闭WIN7系统的自动更新——工具/原料Win7系统电脑一台怎样关闭WIN7系统的自动更新—

串口通信的分类 基于fpga的串口通信

串口通信的分类串口通信可以分为同步通信和异步通信两类。同步通信是按照软件识别同步字符来实现数据的发送和接收,异步通信是一种利用字符的再同步技术的通信方式。2.1同步通信同步通信是一种连续串行传送数据的通信方式,一次通信

声明:《基于FPGA的自动交通灯控制系统设计 模拟交通灯控制系统》为网友刪除丶我的孤單分享!如侵犯到您的合法权益请联系我们删除