vhdl实现交通灯

vhdl实现交通灯

ID:40574334

大小:37.00 KB

页数:4页

时间:2019-08-04

vhdl实现交通灯_第1页
vhdl实现交通灯_第2页
vhdl实现交通灯_第3页
vhdl实现交通灯_第4页
资源描述:

《vhdl实现交通灯》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、LED.、数码管交通灯libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_unsigned.all;entityjiaotongdengisport(clk:instd_logic;rst:instd_logic;en_led:outstd_logic_vector(3downto0);en_seg:outstd_logic_vector(1downto0);data_led:outstd_logic_vector(2downto0);dat

2、a_seg:outstd_logic_vector(7downto0));endjiaotongdeng;architecturebehavofjiaotongdengissignalsaomiao:integerrange0to1;signaltim:integerrange0to59;signalred_tim:integerrange0to59;signalgreen_tim:integerrange0to40;signaltim_ge:integerrange0to9;signaltim_shi:integerrange0to5;signalcnt_

3、led:integerrange0to2:=0;signalyew_tim:integerrange0to20;signaltmp:integerrange0to2;beginen_led<="0000";p1:process(clk)variablecnt:integerrange0to7999999;beginifclk'eventandclk='1'thenifcnt=7999999thencnt:=0;ifcnt_led=0thenifred_tim=0thenred_tim<=10;tmp<=1;ifcnt_led=2thencnt_led<=0;

4、elsecnt_led<=cnt_led+1;endif;elsered_tim<=red_tim-1;endif;elsifcnt_led=1thenifyew_tim=0thenyew_tim<=20;tmp<=2;ifcnt_led=2thencnt_led<=0;elsecnt_led<=cnt_led+1;endif;elseyew_tim<=yew_tim-1;endif;elsifcnt_led=2thenifgreen_tim=0thengreen_tim<=40;tmp<=0;ifcnt_led=2thencnt_led<=0;elsecn

5、t_led<=cnt_led+1;endif;elsegreen_tim<=green_tim-1;endif;endif;elsecnt:=cnt+1;endif;endif;endprocess;p2:process(clk,rst)-variablecnn1:integerrange0to7999;beginifrst='0'thencnn1:=0;elsifclk'eventandclk='1'thenifcnn1=7999thencnn1:=0;ifsaomiao=1thensaomiao<=0;elsesaomiao<=saomiao+1;end

6、if;elsecnn1:=cnn1+1;endif;endif;endprocess;p3:process(saomiao,tim)variabletim_tmp:integerrange0to59;begintim_tmp:=conv_integer(tim);casetim_tmpiswhen50to59=>tim_shi<=5;tim_ge<=tim_tmp-50;--0when40to49=>tim_shi<=4;tim_ge<=tim_tmp-40;when30to39=>tim_shi<=3;tim_ge<=tim_tmp-30;when20to

7、29=>tim_shi<=2;tim_ge<=tim_tmp-20;when10to19=>tim_shi<=1;tim_ge<=tim_tmp-10;whenothers=>tim_shi<=0;tim_ge<=tim_tmp;endcase;endprocess;p4:process(clk,saomiao)functionb_to_seg7(bcd8421:integerrange0to9)returnstd_logic_vectorisvariableseg7:std_logic_vector(7downto0);begincasebcd8421is

8、when0=>seg7:="00000011";wh

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。