欢迎来到天天文库
浏览记录
ID:40657445
大小:12.97 KB
页数:5页
时间:2019-08-05
《基于VHDL语言成功交通灯源程序》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitycount2isport(clk:instd_logic;output:outstd_logic_vector(2downto0));end;architectureshiofcount2issignalA:std_logic_vector(2downto0);beginprocess(clk)beginifclk'eventandclk='1'thenifA="001"thenA<="000";
2、elseA<=A+1;endif;endif;endprocess;output<=A;end;libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitydengisport(clk:instd_logic;rst:instd_logic;qgl:outstd_logic_vector(3downto0);qgh:outstd_logic_vector(3downto0);q:outstd_logic_vector(11downto0));end;arc
3、hitectureoneofdengissignalnumber2:std_logic_vector(7downto0):="01011001";signalgl:std_logic_vector(3downto0);signalgh:std_logic_vector(3downto0);typestate_stis(s1,s2,s3,s4);signalstate:state_st;beginprocess(rst,clk)beginifrst='1'thenstate<=s1;number2<="01011001";q<="100001100
4、001";elsifrising_edge(clk)thencasestateiswhens1=>gl<=number2(3downto0);gh<=number2(7downto4);ifnumber2="00000000"thenstate<=s2;q<="010001010001";number2<="00000011";elsestate<=s1;ifgl="0001"thennumber2<=number2-"00000111";elsenumber2<=number2-1;endif;endif;whens2=>gl<=number2
5、(3downto0);gh<=number2(7downto4);ifnumber2="00000000"thenstate<=s3;q<="001100001100";number2<="00101001";elsestate<=s2;number2<=number2-1;endif;whens3=>gl<=number2(3downto0);gh<=number2(7downto4);ifnumber2="00000000"thenstate<=s4;q<="001010001010";number2<="00000011";elsestat
6、e<=s3;ifgl="0001"thennumber2<=number2-"00000111";elsenumber2<=number2-1;endif;endif;whens4=>gl<=number2(3downto0);gh<=number2(7downto4);ifnumber2="00000000"thenstate<=s1;q<="100001100001";number2<="01011001";elsestate<=s4;number2<=number2-1;endif;whenothers=>state<=s1;endcase
7、;endif;endprocess;qgl<=gl;qgh<=gh;end;libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityfenpingisport(clock:instd_logic;Q:outstd_logic);end;architecturefenpinoffenpingissignalfull:std_logic;beginprocess(clock)variablecount:integerrange0to200;beginifc
8、lock'eventandclock='1'thenifcount=200thencount:=1;full<=notfull;else
此文档下载收益归作者所有