




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、交通信號控制器的vhdl的設計1. 設計任務 模擬十字路口交通信號燈的工作過程,利用實驗板上的兩組紅、黃、綠led作為交通信號燈,設計一個交通信號燈控制器,示意圖如圖1-1所示。要求:(1) 交通燈從綠變紅時,有4秒黃燈亮的間隔時間;(2) 交通燈紅變綠是直接進行的,沒有間隔時間;(3) 主干道上的綠燈時間為40秒,支干道的綠燈時間為20秒;(4) 在任意時間,顯示每個狀態(tài)到該狀態(tài)結束所需的時間。 支干道 主干道 圖1-1 路口交通管理示意圖表1-1 交通信號燈的4種狀態(tài)abcd主干道交通燈綠(40秒)黃(4秒)紅(20秒)紅(4秒)支干道交通燈紅紅綠黃2.設計要求 采用vhdl語言編寫程序,
2、并在quartusii工具平臺中進行開發(fā),下載到eda實驗箱進行驗證。 編寫設計報告,要求包括方案選擇、程序清單、調試過程、測試結果及心得體會。3.設計方案狀態(tài)寄存器秒脈沖信號發(fā)生器計數器clk 時間顯示數據輸出 次態(tài)發(fā)生器信號燈輸出信號 信號燈輸出 圖3-1 交通信號燈控制器程序原理框圖進程將clk信號分頻后產生1秒信號,然后構成兩個帶有預置數功能的十進制計數器,并產生允許十位計數器計數的控制信號。狀態(tài)寄存器實現狀態(tài)轉換和產生狀態(tài)轉換的控制信號,下個模塊產生次態(tài)信號和信號燈輸出信號,以及每一個狀態(tài)的時間值。經過五個模塊的處理,使時間計數、紅綠燈顯示能夠正常運行。程序原理圖如圖3-1所示。 4
3、.各模塊具體設計4.1頂層文件的設計 頂層文件的原理圖可以依據系統(tǒng)的框圖進行,由控制模塊jtd_ctrl、計時模塊jtd_time、譯碼驅動模塊jtd_light、顯示模塊jtd_dis和分頻模塊jtd_fqu五部分組成,其頂層原理圖文件如圖3-1所示。圖4-1交通燈頂層文件原理圖頂層模塊的程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity traffic isport( clk1k,clr:in std_logic;
4、m:in std_logic_vector(2 downto 0); led:out std_logic_vector(6 downto 0); sel:out std_logic_vector(2 downto 0); abl:out std_logic_vector(7 downto 0) );end traffic;architecture behave of traffic iscomponent jtd_fqu is -分頻器元件的例化port( clk1k:in std_logic; clk:out std_logic );end component;component jtd_d
5、is is -數碼顯示的元件例化port( clk1k,clk,clr:in std_logic; m:in std_logic_vector(2 downto 0); at,bt:in std_logic_vector(7 downto 0); led:out std_logic_vector(6 downto 0); sel:out std_logic_vector(2 downto 0) );end component;component jtd_light is -譯碼驅動的元件例化port( clr:in std_logic; m,s:in std_logic_vector(2 do
6、wnto 0); abl:out std_logic_vector(7 downto 0) );end component;component jtd_time is -計時元件的例化port( clk,clr:in std_logic; m,s:in std_logic_vector(2 downto 0); at,bt:out std_logic_vector(7 downto 0) );end component;component jtd_ctrl is -控制模塊的元件例化port( clk,clr:in std_logic; at,bt:in std_logic_vector(7
7、downto 0); m:in std_logic_vector(2 downto 0); s:out std_logic_vector(2 downto 0) );end component;signal clk:std_logic;signal at:std_logic_vector(7 downto 0);signal bt:std_logic_vector(7 downto 0);signal s:std_logic_vector(2 downto 0);begin u1:jtd_fqu port map( -名字關聯方式賦值 clk1k=>clk1k, clk=>clk
8、);u2:jtd_time port map( clr=>clr, at=>at, bt=>bt, clk=>clk, m=>m, s=>s );u3:jtd_ctrl port map( m=>m, s=>s, clk=>clk, clr=>clr, at=>at, bt=>bt );u4:jtd_dis port map( clk1k=>clk1k, clk=>clk, clr=>clr, at=>at, bt=>bt, led=>led, sel=>sel, m=>m
9、);u5:jtd_light port map( clr=>clr, s=>s, abl=>abl, m=>m );end behave;4.2 控制模塊jtd_ctrl的設計 控制的模塊根據外部輸入信號m2m0和計時模塊jtd_time的輸入信號,產生系統(tǒng)的狀態(tài)機,控制其他部分協(xié)調工作。控制模塊的源文件程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity jtd_ctrl isport( clk,clr:in std_logic; m:in std_lo
10、gic_vector(2 downto 0); -用m來表示系統(tǒng)的8種工作狀態(tài) at,bt:in std_logic_vector(7 downto 0); s:out std_logic_vector(2 downto 0) ); end jtd_ctrl; architecture jtd_1 of jtd_ctrl is signal q:std_logic_vector(2 downto 0); begin process(clr,clk,m,at,bt) begin if clr='1'then q<="000" -清'0'處
11、理 elsif(clk'event and clk='1')then -時鐘上升沿信號一來,m控制系統(tǒng)的8種狀態(tài) if m="000"then q<="001" end if; if m="001"then q<="011" end if; if m="010"then q<="101" end if; if m="011"then q<="111" end if; if m>=&q
12、uot;100"then if(at=x"01")or(bt=x"01")then q<=q+1; else q<=q; end if; end if; end if; end process; s<=q; -m的控制端轉向控制口s end jtd_1;該模塊的時序仿真和功能仿真波形圖如圖4-2圖4-2功能仿真4.3 計時模塊jtd_time的設計計時模塊用來設定a和b兩個方向計時器的初值,并為顯示模塊jtd_dis提供倒計時時間。當正常計時開始后,需要進行定時計數操作,由于東西和南北兩個方向上的時間顯示器是由兩個led七段顯
13、示數碼管組成的,因此需要產生兩個2位的計時信息:2個十位信號,2個個位信號,這個定時計數操作可以由一個定時計數器來完成,又因為交通燈的狀態(tài)變化是在計時為0的情況下才能進行的,因此需要一個計時電路來產生使能信號,因此定時計數的功能就是用來產生2個2位計時信息和使能信號。計時模塊的源文件程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity jtd_time isport( clk,clr:in std_logic; m,s:in std_logic_vector(2 downto 0
14、); at,bt:out std_logic_vector(7 downto 0) );end jtd_time;architecture jtd_2 of jtd_time is signal at1,bt1:std_logic_vector(7 downto 0);signal art,agt,alt,abyt:std_logic_vector(7 downto 0); signal brt,bgt,blt:std_logic_vector(7 downto 0);begin art<=x"55" -art<=“01010101”a方向紅燈亮 agt<
15、=x"40" -agt<=“01000000”a方向綠燈亮 alt<=x"15" -alt<=“00010101”燈間歇閃爍 abyt<=x"05"-abyt<=“00000101”ab兩方向黃燈亮 brt<=x"65"-brt<=“01100101”b方向紅燈亮 bgt<=x"30"-bgt<=“00110000”b方向綠燈亮 blt<=x"15"-blt<=“00010101”b方向燈閃爍 process(
16、clr,clk,m,s) begin if clr='1'then at1<=x"01"bt1<=x"01" elsif (clk'event and clk='1')then if m="000"then at1<=x"01"bt1<=x"51"-m=0時,a方向的計時器計時,b方向的紅燈亮 end if; if m="001"then at1<=x"01"bt1<=x"
17、;06"-m=1時,a方向的計時器計時,b方向綠燈亮 end if; if m="010"then at1<=x"41"bt1<=x"01"-b方向的計時器計時,a方向的黃燈亮 end if; if m="011"then at1<=x"06"bt1<=x"01"-b方向的計時器計時,a方向的紅燈亮 end if; if m>="100"then if(at1=x"01")or(bt1=x&quo
18、t;01")then case s is when"000"=>at1<=alt;bt1<=brt;-當s=0時,ab兩方向的計時器計時,a方向車左轉,b方向的紅燈亮 when"001"=>at1<=abyt;-當s=1時,a方向計時器計時,a方向黃燈亮 when"010"=>at1<=agt;-當s=2時,a方向計時器計時,a方向綠燈亮 when"011"=>at1<=abyt;-當s=3時,ab兩方向黃燈亮,a方向計時器計時 when"1
19、00"=>at1<=art;bt1<=blt;-當s=4時,a方向計時,紅燈亮,b方向車左轉,b方向計時器計時 when"101"=>bt1<=abyt;-當s=5時,b方向計時器計時,ab兩方向黃燈亮 when"110"=>bt1<=bgt;-當s=6時,b方向計時器計時,b方向綠燈亮 when"111"=>bt1<=abyt;-當s=7時,b方向計時器計時,ab兩方向車右轉 when others=>at1<=at1;bt1<=bt1; end ca
20、se; end if; if at1/=x"01"then if at1(3 downto 0)="0000"then at1(3 downto 0)<="1001"-第四位數碼管顯示 at1(7 downto 4)<=at1(7 downto 4)-1;高四位數碼管減一顯示 else at1(3 downto 0)<=at1(3 downto 0)-1;低四位數碼管減一顯示 at1(7 downto 4)<=at1(7 downto 4);高四位數碼管顯示不變 end if; end if; if bt1=x
21、"01"then if bt1(3 downto 0)="0000"then bt1(3 downto 0)<="1001"-b方向計數器低四位數碼管顯示9 bt1(7 downto 4)<=bt1(7 downto 4)-1;-b方向計數器高四位數碼管減一計數 else bt1(3 downto 0)<=bt1(3 downto 0)-1;-b方向計數器低四位數碼管減一計數 bt1(7 downto 4)<=bt1(7 downto 4); end if; end if; end if; end if;end
22、 process; at<=at1; bt<=bt1;end jtd_2; 該模塊是為節(jié)省資源而設的,實驗中有四個led七段數碼管顯示計數,點亮一個led需電流550ma,同時點亮4個led,cpld可能無法負荷這樣的電流驅動,而且功率太大,散熱也是問題。同時這么做也容易造成電路被燒毀,因此需要逐個循環(huán)點亮。又為使顯示結果持續(xù)不致閃爍抖動,只需每個掃描頻率超過人眼視覺暫留頻率24hz以上,就能達到。選擇1khz作為時鐘,分到4個數碼管,每個數碼管50hz(大于24hz),故不會有閃爍。 該模塊的功能仿真波形圖如圖4-4所示圖4-4功能仿真4.4 譯碼驅動模塊jtd_light的設計
23、譯碼驅動模塊根據控制信號,驅動交通燈的顯示。該模塊的源程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity jtd_light isport( clr:in std_logic; m,s:in std_logic_vector(2 downto 0); abl:out std_logic_vector(7 downto 0) );end jtd_light;architecture jtd_3 of jtd_light is signal lt:std_logic_vector(
24、7 downto 0);begin process(clr,s,m)begin if clr='1'then lt<="00000000" -清'0'時系統(tǒng)狀態(tài)全部處于關閉狀態(tài) else if m="000"then lt<="10000001" end if; if m="001"then lt<="00100001" end if; if m="010"then lt<="00011000" en
25、d if; if m="011"then lt<="00010010" end if; if m>="100"then case s is -八種情況下的狀況顯示 when"000"=>lt<="00010100" when"001"=>lt<="10000001" when"010"=>lt<="01000001" when"011"=>lt
26、<="00100001" when"100"=>lt<="01000001" when"101"=>lt<="00011000" when"110"=>lt<="00010100" when"111"=>lt<="00010010" when others=>lt<=lt; end case; end if; end if; end process;a
27、bl<=lt;end jtd_3;該模塊的功能仿真波形圖如圖4-5:圖4-5功能仿真4.5 顯示模塊jtd_dis的設計 顯示模塊用來顯示倒計時時間和系統(tǒng)的工作狀態(tài)。其輸出用來驅動六位數碼管,其中四位用于顯示倒計時時間,兩位顯示工作狀態(tài),采用動態(tài)掃描顯示。該模塊的源程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity jtd_dis isport( clk1k,clk,clr:in std_logic; m:in std_logic_vector(2 downto 0);
28、at,bt:in std_logic_vector(7 downto 0); led:out std_logic_vector(6 downto 0); sel:out std_logic_vector(2 downto 0) );end jtd_dis;architecture jtd_4 of jtd_dis is signal ou,stl,sth,mm:std_logic_vector(3 downto 0); signal dis,ds:std_logic_vector(7 downto 0); signal sl:std_logic_vector(2 downto 0);begin
29、 mm<="0"&m; sth<=x"a" process(clr,clk1k) begin if clr='1'then sl<="000" elsif(clk1k'event and clk1k='1')then if sl="101"then sl<="000" -清'0' else sl<=sl+1; -計數 end if; end if; end process; process(sl) be
30、gin case sl is -數碼管的位選 when"000"=>ou<=bt(3 downto 0); when"001"=>ou<=bt(7 downto 4); when"010"=>ou<=at(3 downto 0); when"011"=>ou<=bt(7 downto 4); when"100"=>ou<=stl; when"101"=>ou<=sth; when others=>o
31、u<=x"0" end case; end process; process(ou) begin case ou is -數碼管的譯碼 when x"0"=>ds<="00111111" -顯示'0' when x"1"=>ds<="00000110" -顯示'1' when x"2"=>ds<="01011011" -顯示'2' when x"3"
32、;=>ds<="01001111" -顯示'3' when x"4"=>ds<="01100110" -顯示'4' when x"5"=>ds<="01101101" -顯示'5' when x"6"=>ds<="01111100" -顯示'6' when x"7"=>ds<="00000111" -顯示'7' when x"8"=>ds<=
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 冷藏合同范本
- 加工車間轉租合同范本
- 不見面簽訂租賃合同范本
- 2025年合肥貨運車從業(yè)考試題
- 個人施工承攬合同范本
- app開發(fā)合同范本模板
- 加工訂單合同范本模板
- 農村供熱服務合同范本
- 個人股權質押合同范本
- 光租船合同范本
- 安徽省合肥市包河區(qū) 2024-2025學年九年級上學期期末道德與法治試卷(含答案)
- 2025年一次性死亡賠償協(xié)議模板(2篇)
- 廣州電視塔鋼結構施工方案
- 2024年湖南鐵路科技職業(yè)技術學院高職單招數學歷年參考題庫含答案解析
- 《梅大高速茶陽路段“5·1”塌方災害調查評估報告》專題警示學習
- 2024年06月江蘇昆山鹿城村鎮(zhèn)銀行校園招考筆試歷年參考題庫附帶答案詳解
- 小學二年級100以內進退位加減法800道題
- 3ds Max動畫制作實戰(zhàn)訓練(第3版)教學教案
- 艾滋病丙肝梅毒
- CNAS-CL01-G001:2024檢測和校準實驗室能力認可準則的應用要求
- 春季安全行車培訓資料
評論
0/150
提交評論