1、EDA交通灯控制器课程设计报告书交通灯控制器课程设计该交通信号控制器控制十字路甲、乙两条道路的红、黄和绿三色灯,指挥车辆和行人安全通行。 功能要求如下:1. 只有在小路上发现汽车时,高速公路上的交通灯才可能变成红灯。2. 当汽车行驶在小路上时,小路的交通灯保持为绿灯,但不能超过给定的时间。(20s)3. 高速公路灯转为绿色后,即使小路上有汽车出现,而高速公路上并无汽车,也将在给定的时间内保持绿灯。(60s)。 N N Y Y N Y N Y设计如下:1hz分频器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigne
2、d.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 clk1
3、00hz=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
4、;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(clk100hzev
5、ent 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:
6、=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;
7、 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:=000
8、0;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) th
9、en 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
10、 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:=
11、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(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仿真图如下;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1