EDA交通灯控制器课程设计.doc_第1页
EDA交通灯控制器课程设计.doc_第2页
EDA交通灯控制器课程设计.doc_第3页
EDA交通灯控制器课程设计.doc_第4页
EDA交通灯控制器课程设计.doc_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

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

文档简介

交通灯控制器课程设计该交通信号控制器控制十字路甲、乙两条道路的红、黄和绿三色灯,指挥车辆和行人安全通行。 功能要求如下:1. 只有在小路上发现汽车时,高速公路上的交通灯才可能变成红灯。2. 当汽车行驶在小路上时,小路的交通灯保持为绿灯,但不能超过给定的时间。(20s)3. 高速公路灯转为绿色后,即使小路上有汽车出现,而高速公路上并无汽车,也将在给定的时间内保持绿灯。(60s)。高速公路通车小路有车 N N YT60s Y5秒黄灯后小路通车 小路有车5s黄灯 NT20s Y N Y设计如下:1hz分频器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity fen_pin1 isport(clk100hz:in std_logic; clk1hz:out std_logic);end fen_pin1;architecture bhv of fen_pin1 issignal qan:std_logic_vector(3 downto 0);signal qbn:std_logic_vector(3 downto 0);signal cin:std_logic;beginprocess(clk100hz)beginif(clk100hzevent and clk100hz=1)thenif qan=1001then qan=0000;cin=1;else qan=qan+1;cin=0;end if;end if;end process;process(clk100hz,cin)beginif(clk100hzevent and clk100hz=1)thenif cin=1 thenif qbn=1001 then qbn=0000;else qbn=qbn+1;end if ;end if ;end if ;end process;process(qan,qbn)beginif (qan=1001and qbn=1001)then clk1hz=1;else clk1hz=0;end if;end process;end bhv;2hz分频器library ieee;use ieee.std_logic_1164.all;entity fen_pin2 isport (clk100hz:in std_logic; clk2hz:out std_logic);end fen_pin2;architecture bhv of fen_pin2 isbeginprocess(clk100hz)variable cnt:integer range 0 to 24;variable tmp:std_logic;beginif(clk100hzevent and clk100hz=1)thenif cnt=24 thencnt:=0;tmp:=not tmp;elsecnt:=cnt+1;end if;end if;clk2hzif a=0then th:=0101; tl:=1001; a:=1; ga=1; ra=0; yaif a=0then th:=0001; tl:=1001; a:=1; ra=1; ya=0; ga=0; elseif not(th=0000and tl=0001)thenif tl=0000thentl:=1001;th:=th-1;elsetl:=tl-1;end if;elseth:=0000;tl:=0000;a:=0;ra=0;gaif a=0then th:=0000; tl:=1001; a:=1; ya=1; ga=0; ra=0; elseif not(th=0000and tl=0001)thenif tl=0000thentl:=1001;th:=th-1;elsetl:=tl-1;end if;elseth:=0000;tl:=0000; ga=0; ra=0; ya=0; a:=0;state:=green;end if;end if;end case;end if;timeah=th;timealif a=0then th:=0000; tl:=0100; a:=1; yb=1; gb=0; rb=0; chuif a=0then th:=0001; tl:=1001; a:=1; gb=1; rb=0; yb=0; chuif a=0then th:=0101; tl:=0100; a:=1; rb=1; yb=0; chuif a=0then th:=0000; tl:=0100; a:=1; yb=1; gb=0; rb=0; chu=1; elseif not(th=0000and tl=0001)thenif tl=0000thentl:=1001;th:=th-1;elsetl:=tl-1;end if;elseth:=0000;tl:=0000;a:=0;chu=0;state:=red;end if;end if;end case;end if;timeah=th;timeal=tl;end process;end bhv;反馈器library ieee;use ieee.std_logic_1164.all;entity smen is port( sm ,re,gr,ye:in std_logic; jinji:out std_logic);end smen;architecture se of smen isbeginprocess isbeginif(sm=1 and re=0 and gr=0 and ye=0) then jinji=1;else jinji=0;end if;end process;end se;消抖电路library ieee;use ieee.std_logic_1164.all;entity xiaodou isport(jinji,clk1hz:in std_logic; b:out std_logic);end xiaodou;architecture bhv of xiaodou issignal temp1:std_logic;beginprocess(clk1hz,jinji)variable temp2:std_logic;beginif(clk1hzevent and clk1hz=0)thentemp1=jinji;temp2:=not temp1;end if;b=temp1 and temp2 and clk1hz;end process;end bhv;状态转换library ieee;use ieee.std_logic_1164.all;entity no isport(a:in std_logic; en:out std_logic);end no;architecture no_arc of no isbeginprocess(a)variable tmp:std_logic;beginif(aevent and a=1)thentmp:=not tmp;end if;enq=d2;soq=d3;soq=d0;soq=d1;soq:=0111111;when0001=q:=0000110;when0010=q:=1011011;when0011=q:=1001111;when0100=q:=1100110;when0101=q:=1101101;when0110=q:=1111101;when0111=q:=0100111;when1000=q:=1111111;when1001=q:=1101111;when others=q:=1111001;end case;q0=q(0);q1=q(1);q2=q(

温馨提示

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

评论

0/150

提交评论