CPLD课程设计交通灯程序_第1页
CPLD课程设计交通灯程序_第2页
CPLD课程设计交通灯程序_第3页
CPLD课程设计交通灯程序_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; ENTITY jiaotongdeng IS PORT( clk_in:in std_logic; -4MHz rst:in std_logic;-复位信号 light:out std_logic_vector(7 downto 0); -RYG_main,RYG_gene spk:out std_logic; LED7S0:out STD_LOGIC_VECTOR(6 downto 0); LED7S1:out STD_LOGIC_VECTO

2、R(6 downto 0); LED7S2:out STD_LOGIC_VECTOR(6 downto 0); LED7S4:out STD_LOGIC_VECTOR(6 downto 0) ); END jiaotongdeng; ARCHITECTURE ARC OF jiaotongdeng IS type states is(green_red,yellow_red,red_green,red_yellow); signal state:states:=green_red; signal nextstate:states; signal data0:integer range 0 to

3、 9; signal data1:integer range 0 to 9; signal data2:integer range 0 to 9; signal data3:integer range 0 to 9; signal clock_buffer:std_logic; signal count_time:integer range 0 to ; signal clk:std_logic; signal sec0:integer range 0 to 9; signal sec1:integer range 0 to 3; signal sec2:integer range 0 to

4、9; signal sec3:integer range 0 to 3; BEGIN spk=0; frequent:process(clk_in) begin if clk_inevent and clk_in=1 then if count_time= then count_time=0; clock_buffer=not clock_buffer; else count_time=count_time+1; end if; end if; clklight=; nextstate=yellow_red; data0=5; data1=0; data2=5; data3light=; ne

5、xtstate=red_green; data0=4; data1=2; data2=9; data3light=; nextstate=red_yellow; data0=5; data1=0; data2=5; data3light=; nextstate=green_red; data0=9; data1=3; data2=4; data3=3; end case; end process; time:process(rst,clk) -记时状态 begin if rst=0 then -复位 sec0=9;sec1=3;sec2=4;sec3=3; elsif rising_edge(

6、clk) then if(sec0=0 AND sec1=0) or (sec2=0 AND sec3=0)then state=nextstate; sec0=data0; sec1=data1; sec2=data2; sec3=data3; else if sec2=0 then sec2=9; sec3=sec3-1; else sec2=sec2-1; end if; if sec0=0 then sec0=9; sec1=sec1-1; else sec0 LED7S0 LED7S0 LED7S0 LED7S0 LED7S0 LED7S0 LED7S0 LED7S0 LED7S0 LED7S0 LED7S3 LED7S3 LED7S3 LED7S3 LED7S2 LED7S2 LED7S2 LED7S2 LED7S2 LED

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论