欢迎来到天天文库
浏览记录
ID:38264870
大小:12.28 KB
页数:6页
时间:2019-06-07
《EDA课程设计 交通灯控制器》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entityEDA1isport(clk,en:instd_logic;lampa,lampb:outstd_logic_vector(3downto0);acount,bcount:outstd_logic_vector(7downto0));endEDA1;architectureaofEDA1issignalnuma,numb:st
2、d_logic_vector(7downto0);signaltempa,tempb:std_logic;signalstatea,stateb:std_logic_vector(2downto0);signalared,bred,agreen,bgreen,ayellow,byellow,aleft,bleft:std_logic_vector(7downto0);beginacount<=numa;bcount<=numb;x1:process(en)beginifen='0'thenared<="01010101";ayel
3、low<="00000101";agreen<="01000000";aleft<="00010101";bred<="01100101";byellow<="00000101";bgreen<="00110000";bleft<="00010101";endif;endprocess;x2:process(clk,en)beginifclk='1'andclk'eventthenifen='1'theniftempa='0'thentempa<='1';casestateaiswhen"000"=>numa<=agreen;la
4、mpa<="0010";statea<="001";when"001"=>numa<=ayellow;lampa<="0100";statea<="010";when"010"=>numa<=aleft;lampa<="0001";statea<="011";when"011"=>numa<=ayellow;lampa<="0100";statea<="100";when"100"=>numa<=ared;lampa<="1000";statea<="000";whenothers=>lampa<="1000";endcase;e
5、lseif(numa>1)thenifnuma(3downto0)=0thennuma(3downto0)<="1001";numa(7downto4)<=numa(7downto4)-1;elsenuma(3downto0)<=numa(3downto0)-1;endif;elseifnuma=1thentempa<='0';numa<=numa-1;endif;endif;endif;elselampa<="1000";statea<="000";tempa<='0';endif;endif;endprocessx2;x3:p
6、rocess(clk,en)beginifclk='1'andclk'eventthenifen='1'theniftempb='0'thentempb<='1';casestatebiswhen"000"=>numb<=bred;lampb<="1000";stateb<="001";when"001"=>numb<=bgreen;lampb<="0010";stateb<="010";when"010"=>numb<=byellow;lampb<="0100";stateb<="011";when"011"=>numb<=bl
7、eft;lampb<="0001";stateb<="100";when"100"=>numb<=byellow;lampb<="0100";stateb<="000";whenothers=>lampb<="1000";endcase;elseif(numb>1)thenifnumb(3downto0)=0thennumb(3downto0)<="1001";numb(7downto4)<=numb(7downto4)-1;elsenumb(3downto0)<=numb(3downto0)-1;endif;elseifnumb
8、=1thentempb<='0';numb<=numb-1;endif;endif;endif;elselampb<="1000";stateb<="000";tempb<='0';endif;endif;endprocessx3;enda;lib
此文档下载收益归作者所有