數(shù)字電子課程設(shè)計(jì)--交通燈_第1頁
數(shù)字電子課程設(shè)計(jì)--交通燈_第2頁
數(shù)字電子課程設(shè)計(jì)--交通燈_第3頁
數(shù)字電子課程設(shè)計(jì)--交通燈_第4頁
數(shù)字電子課程設(shè)計(jì)--交通燈_第5頁
已閱讀5頁,還剩7頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、東西方向秒表的低位東西方向秒表的高位南北方向秒表的低位南北方向秒表的高位利用狀態(tài)機(jī),定義四種狀態(tài)sti,st2,st3,st4定義秒表為30秒交通燈設(shè)計(jì)總結(jié)報(bào)告一方案設(shè)計(jì)與論證使用vhdl語言編程,在結(jié)構(gòu)體屮制造一個(gè)單進(jìn)程狀態(tài)機(jī),此狀態(tài)機(jī)只 進(jìn)行單純的狀態(tài)轉(zhuǎn)換,每個(gè)狀態(tài)中不涉及控制交通燈的亮滅,交通燈的 亮滅在單獨(dú)的一個(gè)進(jìn)程中進(jìn)行控制。時(shí)鐘由20mhz的晶體分頻形成1hz 的秒信號。二.vhdl編程設(shè)計(jì)library ieee;use ieee.std_logic_1164.all;使用庫函數(shù)use ieee.std logic unsigned.all;use ieee.std logic

2、arith.all;entity traffic isport(clk:instd_logic;rst: in std_logic;ew_t1 : out std_l0gic_vect0r(3 downto 0);ew_t2: out std_l0gic_vect0r(3 downto 0); ew r : out std logic;ew g : out std logic;ew_y : out std_logic;ns_t1 :out std_l0gic_vect0r(3 downto 0);ns_t2: out std_l0gic_vect0r(3 downto 0); ns r: ou

3、t std logic;ns g : out std logic;mbmm夕ns_y : out std_logic;);end entity traffic;architecture func of traffic istype state 1 is (st1,st2,st3,st4);signal state :state1;signal clk 1hz : std logic;signal count1 : integer range 0 to 30;signal count2 : integer range 0 to 30;beginpo:process(clk)variable a

4、: std_logic_vector(23 downto 0);beginif(clk*event and clk二t) theniffa'loolloooloololloolllllll'hhenclk_1hz<=not clk_1hz; a:=(others=>'0');elsea:=a+1;end if;end if;end process po;p:process(clk_1hz)beginif(rst='1')thenstate<=st1;count1<=30;count2<=30;ew_r<=

5、9;0'ew g<='1'ew_y<='0'ns_r<='1'ns_g<=,0,;ns_y<='o'elsif(clk_1hz'event and clk_1hz='1,)then case state iswhen sti => ew_r<='0'ew_g<='1'ew_y<='0'ns_r<=,1,;ns_g<=*0'ns_y<='o*;if(count1=5)then

6、state<=st2;elsestate<=st1;end if;count1<=count1-1;count2<=count2-1;when st2 =>ew_r<='0'ew_g<='0*;ew_y<='1'ns_r<='1,;ns g<='o'ns_y<='0,;if(count2=1)then分頻東西綠燈,南北紅燈東西黃燈,南北紅燈state<=st3;count1<=25;count2<=25;elsestate<=st2;

7、end if;count2<=count2-1;count1<=count1-1; when st3 =>ew_r<='1'ew_g<='0'ew_y<='0'ns_r<=,0,;ns_g<=,1,;ns_y<='0,;if(count2=5)thenstate<=st4;elsestate<=st3;end if;count2<=count2-1;count1<=count1-1; when st4 => ew_r<='1,;ew_g<

8、;='0'ew_y<='0'ns_r<=,0,;ns_g<='0'ns_y<='1,;if(count1=1)thenstate<=st1;elsestate<=st4; end if;count2<=count2-1;count1<=count1-1;when others => state <= sti;end case;end if;end process p;p1:process(clk_1hz)begincase c0unt1 iswhen 0 =>ew_tl&l

9、t;="0000"東西紅燈,南北綠燈東西紅燈,南北黃燈高低位都用四位二進(jìn)制表示when2=>when 3 =>when4=>when 5 =>when 6=>when 7=>when8=>when9=>when 10 =>when 11 =>when 12 =>when 13 =>when 14 =>when 15 =>when 16 =>when 17 =>when 18 =>when 19 =>when 20 =>when 21 =>when 22 =

10、>ew_tlv二 ”0011"ew_t2<=',0000n;ew_tl<="0100,'ew_t2<="0000n;ew_tl<="0101"ew_t2<="0000n;ew_tl<="0110"ew_t2<=',0000n;ew_tl<="0111"ew_t2<="0000n;ew_tl<="1000"ew t2<="0000u;ew_tl<="

11、;1001"ew_t2<="0000n;ew_tl<=h0000"ew_t2<="0001"ew tl<=,0001h;ew_t2<="0001,'ew_tl<=h0010h;ew_t2<="0001"ew_tl<=,0011h;ew_t2<=,0001,1;ew_tl<="0100,'ew_t2<="0001h;ew_tl<=h0101h;ew_t2<="0001"ew_tk=,0

12、110"ew_t2<=',0001n;ew_tl<=h0111h;ew_t2<=,0001"ew_tl<=h1000h;ew t2<="0001n;ew_tl<="1001h;ew_t2<="0001n;ew_tl<=h0000"ew_t2<="0010h;ew tl<=,0001h;ew_t2<="0010,'ew_tl<=,0010h;when 24 =>when 25 =>when 26 =>when 2

13、7 =>when 28 =>when 29 =>when 30 =>ew_tl<="0101"ew_t2<=”0010“;ew_tl<=,0110h;ew_t2<=,0010"ew_tl<=,0111h;ew_t2<=,0010n;ew_tl<="1000"ew_t2<=”0010“;ew_tl<=,1001h;ew_t2<=,0010"ew_tl<=h0000h;ew t2<="0011n;when others => n

14、ull;end case;case count2 iswhen0=>when 1=>when2=>when 3 =>when4=>when5=>when 6=>when7=>when8=>when9=>when 10 =>when 11 =>ns_tl<=,0000n;ns_t2<="0000"ns_tl<="0001"ns_t2<="0000,'ns_tl<="0010h;ns_t2<="0000"

15、ns_tl<=,0011h;ns_t2<="0000h;ns_tl<=,0100n;ns_t2<="0000"ns_tl<=,0101n;ns_t2<=,0000n;ns_tl<=,0110n;ns_t2<="0000"ns_tl<=m0111"ns t2<="0000h;ns_tl<=,1000n;ns_t2<="0000"ns_tl<="1001"ns_t2<="0000"ns

16、tl<="0000"ns_t2<="0001"ns_tl<=,0001,1;when 13 =>when 14 =>when 15 =>when 16 =>when 17 =>when 18 =>when 19 =>when 20 =>when 21 =>when 22 =>when 23 =>when 24 =>when 25 =>when 26 =>when 27 =>when 28 =>when 29 =>when 30 =>

17、;ns_tl<="0100"ns_t2<=,0001"ns_tl<="0101"ns_t2<="0001"ns_tl<="0110"ns_t2<="0001"ns_tl<=,0111"ns_t2<=,0001"ns_tl<=,1000,;ns_t2<="0001"ns_tl<="1001" ns t2<="0001h;ns_tl<=&quo

18、t;0000"ns_t2<="0010"ns_tl<="0001,;ns_t2<="0010"ns tl<="0010"ns_t2<="0010"nstlv-'ooir;ns_t2<="0010"nstivoioo”;ns_t2<="0010"ns_tl<="0101"ns_t2<="0010"ns_tl<=,0110"ns_t2<=

19、"0010"ns_tl<=,0111"ns_t2<=,0010n;ns_tl<="1000"ns_t2<="0010"ns_tl<="1001" ns t2<="0010"ns_tl<="0000"ns_t2<=,0011,'when others => null;end case;end process pl;end architecture func;三.仿真波形 和鎖定引腳node namedirectionlocationreservedgroup:1 okinputpin612° ew.goutputpinj143u ew.routputpin.4244一。ewj13outputpin."ewjl3.o453ew.tl outputpin.48ewjl3.o46o ew.t11outputpin.4947ewj1(o)o

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論