《EDA交通灯控制器课程设计报告书.docx》由会员分享,可在线阅读,更多相关《EDA交通灯控制器课程设计报告书.docx(11页珍藏版)》请在三一文库上搜索。
1、下载可编辑交通灯控制器课程设计该交通信号控制器控制十字路甲 、乙两条道路的红 、黄和绿三色灯 ,指挥车辆和行人安全通行 。功能要求如下 :1. 只有在小路上发现汽车时 ,高速公路上的交通灯才可能变成红灯。2. 当汽车行驶在小路上时 ,小路的交通灯保持为绿灯 ,但不能超过给定的时间 。( 20s)3. 高速公路灯转为绿色后 ,即使小路上有汽车出现 ,而高速公路上并无汽车 ,也将在给定的时间内保持绿灯 。( 60s)。高速公路通车N小路有车NYT>60sY5 秒黄灯后小路通车N5s 黄灯小路有车YNYT>20s设计如下 : 1hz 分频器library ieee;entity fen_
2、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(clk100hz'event and clk100hz='1')thenif qan=
3、"1001"then qan<="0000"cin<='1'else qan<=qan+1;cin<='0'end if;end if;end process;process(clk100hz,cin)beginif(clk100hz'event and clk100hz='1')thenif cin='1' thenif qbn="1001" then qbn<="0000"else qbn<=qbn+1;
4、end if ;end if ;end if ;end process;process(qan,qbn)beginif (qan="1001"and qbn="1001")then clk1hz<='1'else clk1hz<='0'end if;end process;end bhv; 2hz 分频器library ieee;entity fen_pin2 isport (clk100hz:in std_logic;clk2hz:out std_logic);end fen_pin2;architectur
5、e bhv of fen_pin2 isbeginprocess(clk100hz)variable cnt:integer range 0 to 24;variable tmp:std_logic;begin.专业 .整理 .下载可编辑if(clk100hz'event and clk100hz='1')thenif cnt=24 thencnt:=0;tmp:=not tmp;elsecnt:=cnt+1;end if;end if;clk2hz<=tmp;end process;end bhv; 主干道控制library ieee;entity contra
6、lz isport(clk:in std_logic;ra,ga,ya:out std_logic;timeah,timeal:out std_logic_vector(3 downto 0);end contralz;architecture bhv of contralz istype rg is(green,red,yellow2);beginprocess(clk)variable a:std_logic;variable th,tl:std_logic_vector(3 downto 0);variable state:rg;beginif clk'event and clk
7、='1'thencase state iswhen green=>if a='0'thenth:="0101"tl:="1001"a:='1'ga<='1'ra<='0'ya<='0'elseif not(th="0000"and tl="0001")thenif tl="0000"thentl:="1001"th:=th-1;elsetl:=tl-1;.专
8、业 .整理 .下载可编辑end if;elseth:="0000"tl:="0000"a:='0'state:=red;end if;end if;when red=>if a='0'thenth:="0001"tl:="1001"a:='1'ra<='1'ya<='0'ga<='0'elseif not(th="0000"and tl="0001")the
9、nif tl="0000"thentl:="1001"th:=th-1;elsetl:=tl-1;end if;elseth:="0000"tl:="0000"a:='0'ra<='0'ga<='0'state:=yellow2;end if;end if;when yellow2=>if a='0'thenth:="0000"tl:="1001"a:='1'ya<=
10、9;1'ga<='0'ra<='0'elseif not(th="0000"and tl="0001")thenif tl="0000"thentl:="1001"th:=th-1;.专业 .整理 .下载可编辑elsetl:=tl-1;end if;elseth:="0000"tl:="0000"ga<='0'ra<='0'ya<='0'a:='0
11、39;state:=green;end if;end if;end case;end if;timeah<=th;timeal<=tl;end process;end bhv; 支路控制library ieee;entity contralx isport(clk:in std_logic;rb,gb,yb,chu:out std_logic;timeah,timeal:out std_logic_vector(3 downto 0);end contralx;architecture bhv of contralx istype rgy is(red,yellow1,green,
12、yellow2);beginprocess(clk)variable a:std_logic;variable th,tl:std_logic_vector(3 downto 0);variable state:rgy;beginif clk'event and clk='1'thencase state iswhen yellow1=>if a='0'thenth:="0000"tl:="0100"a:='1'yb<='1'gb<='0'.专业 .
13、整理 .下载可编辑rb<='0'chu<='1'elseif not(th="0000"and tl="0001")thenif tl="0000"thentl:="1001"th:=th-1;elsetl:=tl-1;end if;elseth:="0000"tl:="0000"a:='0'state:=green;end if;end if;when green=>if a='0'thent
14、h:="0001"tl:="1001"a:='1'gb<='1'rb<='0'yb<='0'chu<='1'elseif not(th="0000"and tl="0001")thenif tl="0000"thentl:="1001"th:=th-1;elsetl:=tl-1;end if;elseth:="0000"tl:="0000&qu
15、ot;a:='0'state:=yellow2;end if;end if;when red=>if a='0'thenth:="0101"tl:="0100"a:='1'.专业 .整理 .下载可编辑rb<='1'yb<='0'chu<='1'elseif not(th="0000"and tl="0001")thenif tl="0000"thentl:="1001
16、"th:=th-1;elsetl:=tl-1;end if;elseth:="0000"tl:="0000"a:='0'state:=yellow1;end if;end if;when yellow2=>if a='0'thenth:="0000"tl:="0100"a:='1'yb<='1'gb<='0'rb<='0'chu<='1'elseif not(th=
17、"0000"and tl="0001")thenif tl="0000"thentl:="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;
18、反馈器library ieee;entity smen isport( sm ,re,gr,ye:in std_logic;jinji:out std_logic);end smen;architecture se of smen isbeginprocessisbeginif(sm='1' and re='0' and gr='0' and ye='0') then jinji<='1'elsejinji<='0'end if;end process;end se; 消抖电路libra
19、ry ieee;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(clk1hz'event and clk1hz='0')thentemp1<=jinji;temp2:=not temp1;end if;b<=temp1 and te
20、mp2 and clk1hz;end process;end bhv; 状态转换library ieee;.专业 .整理 .下载可编辑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(a'event and a='1')thentmp:=not tmp;end if;en<=tmp;end process;end no_arc; mux4l library
21、 ieee;port(sel:in std_logic_vector(2 downto 0); d0,d1,d2,d3:in std_logic_vector(3 downto 0); q:out std_logic_vector(3 downto 0);so:out std_logic_vector(1 downto 0); end mux41;architecture bhv of mux41 is beginprocess(sel)begincase sel iswhen"100"=>q<=d2;so<="00"when"
22、;101"=>q<=d3;so<="01"when"000"=>q<=d0;so<="10"when others=>q<=d1;so<="11"end case;end process;end bhv; 译码器library ieee;entity dec7s isport(d:in std_logic_vector(3 downto 0);q0,q1,q2,q3,q4,q5,q6:out std_logic);end dec7s;.专业 .整理 .
23、下载可编辑architecture bhv of dec7s isbeginprocess(d)variable q:std_logic_vector(6 downto 0);begincase d iswhen"0000"=>q:="0111111"when"0001"=>q:="0000110"when"0010"=>q:="1011011"when"0011"=>q:="1001111"when"
24、0100"=>q:="1100110"when"0101"=>q:="1101101"when"0110"=>q:="1111101"when"0111"=>q:="0100111"when"1000"=>q:="1111111"when"1001"=>q:="1101111"when others=>q:="1111001"end case;q0<=q(0);q1<=q(1);q2<=q(2);q3<=q(3);q4<=q(4);q5<=q(5);q6<=q(6);end process;end bhv;.专业 .整理 .下载可编辑仿真图如下 :Ya,ra,ga 表示主干道黄红绿灯;yb,rb,gb表示乡村小路黄红绿灯。下图表示 :主路绿灯 60s ,红灯 20s, 黄灯 5s,即使中途来车也不发生跳转。下图说明 :175s 之后再无车来,则保持主路绿灯,支路红灯1200s 仿真图如下 ;.专业 .整理 .