欢迎来到天天文库
浏览记录
ID:39548800
大小:274.00 KB
页数:4页
时间:2019-07-06
《EDA实验交通灯设计》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;useieee.std_logic_unsigned.all;ENTITYlightISPORT(rst,fastclk:INSTD_LOGIC;light_a_green,light_a_red,light_a_yellow:OUTSTD_LOGIC;light_b_green,light_b_red,light_b_yellow:OUTSTD_LOGIC;duanma:outstd_logic_vector(7downto0
2、);weixuan:outstd_logic_vector(2downto0));ENDENTITYlight;ARCHITECTUREbehaveOFlightISTYPEstatesIS(s0,s1,s2,s3,s4);SIGNALcs:states:=s0;SIGNALcount:INTEGERRANGE0TO18;signaltime_a,time_b:integerrange0to9;signalflag:bit;signalclk:std_logic;signaldvdcnt:integerr
3、ange0to50;BEGINdivid:process(fastclk)beginiffastclk'eventandfastclk='1'thenifdvdcnt=49thendvdcnt<=0;clk<=notclk;--100dividelsedvdcnt<=dvdcnt+1;endif;endif;endprocessdivid;COM:PROCESS(cs)BEGINCASEcsISWHENs0=>light_a_green<='0';light_a_red<='1';light_a_yell
4、ow<='0';light_b_green<='0';light_b_red<='1';light_b_yellow<='0';WHENs1=>light_a_green<='0';light_a_red<='1';light_a_yellow<='0';light_b_green<='1';light_b_red<='0';light_b_yellow<='0';WHENs2=>light_a_green<='0';light_a_red<='1';light_a_yellow<='0';light_b
5、_green<='0';light_b_red<='0';light_b_yellow<='1';WHENs3=>light_a_green<='1';light_a_red<='0';light_a_yellow<='0';light_b_green<='0';light_b_red<='1';light_b_yellow<='0';WHENs4=>light_a_green<='0';light_a_red<='0';light_a_yellow<='1';light_b_green<='0';lig
6、ht_b_red<='1';light_b_yellow<='0';WHENOTHERS=>null;ENDCASE;ENDPROCESSCOM;REG:PROCESS(rst,clk)BEGINifrst='1'thencs<=s0;count<=0;elsIFclk'EVENTANDclk='1'THENIFcount=18THENcount<=1;ELSEcount<=count+1;endif;CASEcountISWHEN01=>time_a<=9;time_b<=6;cs<=s1;WHEN02
7、=>time_a<=8;time_b<=5;WHEN03=>time_a<=7;time_b<=4;WHEN04=>time_a<=6;time_b<=3;WHEN05=>time_a<=5;time_b<=2;WHEN06=>time_a<=4;time_b<=1;WHEN07=>time_a<=3;time_b<=3;cs<=s2;WHEN08=>time_a<=2;time_b<=2;WHEN09=>time_a<=1;time_b<=1;WHEN10=>time_a<=6;time_b<=9;cs
8、<=s3;WHEN11=>time_a<=5;time_b<=8;WHEN12=>time_a<=4;time_b<=7;WHEN13=>time_a<=3;time_b<=6;WHEN14=>time_a<=2;time_b<=5;WHEN15=>time_a<=1;time_b<=4;WHEN16=>time_a<=3;time_b<=3;cs<=s4;WHEN17=>time_a<=2;time_b<=2;WHEN18=
此文档下载收益归作者所有