數(shù)字邏輯課程設計實驗報告(交通燈控制)_第1頁
數(shù)字邏輯課程設計實驗報告(交通燈控制)_第2頁
數(shù)字邏輯課程設計實驗報告(交通燈控制)_第3頁
數(shù)字邏輯課程設計實驗報告(交通燈控制)_第4頁
數(shù)字邏輯課程設計實驗報告(交通燈控制)_第5頁
已閱讀5頁,還剩1頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、實驗三:交通燈控制一、實驗目的(1)學習采用狀態(tài)機方法設計時序邏輯電路。(2)掌握ispLEVER 軟件的使用方法。(3)掌握用VHDL 語言設計數(shù)字邏輯電路。(4)掌握ISP 器件的使用。二、實驗所用器件和設備在系統(tǒng)可編程邏輯器件ISP1032 一片示波器 一臺萬用表或邏輯筆 一只TEC-5實驗系統(tǒng),或TDS-2B 數(shù)字電路實驗系統(tǒng) 一臺三、實驗內容以實驗臺上的4個紅色電平指示燈,4個綠色電平指示燈模仿路口的東南西北4個方向的紅,綠,黃交通燈??刂七@些交通燈,使它們按下列規(guī)律亮,滅。VHDL源代碼:LIBRARY ieee;USE ieee.std_logic_1164.all;ENTITY

2、 light isport (restfunc,emergency,clk: in std_logic;-restfunc為復位信號,emergency為緊急信號,clk為50kHz頻率時鐘light : out std_logic_vector(11 downto 0); -12個指示燈ARCHITECTURE func of light istype state is (s1,s2,s3,s4); -交通燈4個狀態(tài)signal current_state,next_state: state; -current_state,next_state為別為當前狀態(tài),轉移狀態(tài)signal en1,e

3、n2,en3,en4, c,c1,c2,c3,c4: std_logic; -en為使能信號,c為進位信號signal temp1: integer range 0 to 49999; signal temp2: integer range 0 to 99999; signal temp3: integer range 0 to 249999; signal temp4: integer range 0 to 9999; begin -1s計數(shù)器,對50kHz進行50000分頻process(clk,en1)beginif (clk'event and clk='1')

4、 then -上升沿判斷if (temp1=49999 and en1='1' and emergency='0') thentemp1<=0;c1<='1' -進位elsif (en1='1' and emergency='0') thentemp1<=temp1+1;c1<='0'end if;end if;if (en1='0') thenc1<='0'temp1<=0;end if;end process;process(c

5、lk,en2) -2s計數(shù)器,對50kHz進行100000分頻beginif (clk'event and clk='1') thenif (temp2=99999 and en2='1' and emergency='0') thentemp2<=0;c2<='1'elsif (en2='1'and emergency='0') thentemp2<=temp2+1;c2<='0'end if;end if;if (en2='0')

6、thenc2<='0'temp2<=0;end if;end process;process(clk,en3) -5s計數(shù)器,對50kHz進行250000分頻beginif (clk'event and clk='1') thenif (temp3=249999 and en3='1' and emergency='0') thentemp3<=0;c3<='1'elsif (en3='1' and emergency='0') thentemp3&l

7、t;=temp3+1;c3<='0'end if;end if;if (en3='0') thentemp3<=0;c3<='0'end if;end process;process(clk,en4) -0.2s計數(shù)器,對50kHz進行10000分頻beginif (clk'event and clk='1') thenif (temp4=9999 and en4='1') thentemp4<=0;c4<=not c4;elsif (en4='1') then

8、temp4<=temp4+1;end if;end if;end process;c<=c1 or c2 or c3; -進位信號process (c,restfunc) -狀態(tài)轉移,復位情況beginif (restfunc='1') then -復位信號current_state<=s1;elsif (c'event and c='0') then -遇到計數(shù)器進位轉移到下一狀態(tài)current_state<=next_state;end if;end process;process (current_state,emergen

9、cy) -狀態(tài)轉移,緊急情況beginif(emergency='1') then -緊急狀態(tài)紅燈全亮light<="000000001111"elsecase current_state iswhen s1=> -東西方向綠燈亮,南北方向紅燈亮,延時5秒en1<='0'en2<='0'light<="010100001010"en3<='1'next_state<=s2; -繼續(xù)下一狀態(tài),下同when s2=> -東西方向黃燈閃,南北方向紅燈

10、亮,延時2秒en3<='0'en2<='1'en4<='1'light(11 downto 7 )<="00000"light(6)<=c4;light(5)<='0'light(4)<=c4;light(3 downto 0)<="1010"next_state<=s3;when s3=> -東西方向紅燈亮,南北方向綠燈亮,延時5秒en2<='0'en4<='0'en3<='1'light<="101000000101"next_state<=s4;when s4=> -東西方向紅燈閃,南北方向黃燈閃,延時2秒en3<='0'en2<='1'en4<='1'light(11 downto 8 )<="0000"light(7)<=c4; -閃燈控制light(6)<='0'light(5)<=c4;lig

溫馨提示

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

評論

0/150

提交評論