




付費下載
下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、library ieee; - 分頻電路use entity fen isport(clk:in std_logic;clk1:out std_logic); -實體端口聲明end fen;architecture fen_arc of fen is - 結構體描述開始beginprocess(clk) -進程開始variable cnt:integer range 0 to 99;beginif clk'event and clk='1' then -高電平到if cnt=99 thencnt:=0; -0 開始計數clk1<='1' -輸出高電
2、平elsecnt:=cnt+1; -加計數clk1<='0' -輸出低電平end if;end if;end process; -進程描述結束end fen_arc; -結構體描述結束-A 路控制library ieee;use use entity Alu isport(clk:in std_logic;ar,ag,al,ay:out std_logic; -紅、綠、黃、左轉timas,timag:out std_logic_vector(3 downto 0); -十位、個位計數end Alu;architecture alu_arc of Alu istype rg
3、ly is(red,green,left,yellow); -燈亮順序為紅、綠、左轉、黃beginprocess(clk)variable a:std_logic; - 變量聲明variable ts,tg:std_logic_vector(3 downto 0);variable state:rgly;beginif clk'event and clk='1' then -高電平case state iswhen green=>if a='0' then -綠燈狀態ts:="0010" -十位計 2tg:="0100
4、" -個位計 4a:='1'ag<='0'ar<='1'elseif not(ts="0000" and tg="0001") then - 若計數值不為 1if tg="0000" then -若個位為 1tg:="1001" -個位置 9ts:=ts-1; -十位自減 1elsetg:=tg-1; -個位自減 1end if;elsets:="0000"tg:="0000"a:='0's
5、tate:=left; -轉為左轉燈狀態end if;end if;when left=>if a='0' then - 左轉燈ts:="0000" - 十位置 0tg:="1001" - 個位置 9a:='1'aL<='0'ag<='1'elseif not (ts="0000" and tg="0001")thenif tg="0000" thentg:="1001"ts:=ts-1;els
6、etg:=tg-1;end if;elsets:="0000"tg:="0000"a:='0'state:=yellow;- 轉為黃燈狀態end if;end if;when yellow=>if a='0' then -黃燈狀態ts:="0000" -十位置 0tg:="0100" -個位置 9a:='1'ay<='0'aL<='1'elseif not(ts="0000" and tg=&quo
7、t;0001") thenif tg="0000" thentg:="1001"ts:=ts-1;elsetg:=tg-1;end if;elsets:="0000"tg:="0000"a:='0'state:=red;end if;end if;when red=>if a='0' then - 紅燈狀態ts:="0011" - 十位置 3tg:="1001" -個位置 9a:='1'ar<='0
8、'ay<='1'elseif not(ts="0000" and tg="0001") thenif tg="0000" thentg:="1001"ts:=ts-1 ;elsetg:=tg-1;end if;elsets:="0000"tg:="0000"a:='0'state:=green;end if;end if;end case;timas<=ts;timag<=tg;end if;end process;e
9、nd alu_arc;-B 路燈控制程序。與 A 路相似。library ieee;use use entity blu isport(clk:in std_logic;br,bg,bl,by:out std_logic;timbs,timbg:out std_logic_vector(3 downto 0);end blu;architecture blu_arc of blu istype rgly is(green,left,yellow,red); -燈亮順序為綠、左轉、黃、紅beginprocess(clk)variable a:std_logic;variable ts,tg:st
10、d_logic_vector(3 downto 0);variable state:rgly;beginif clk'event and clk='1' thencase state iswhen green=>if a='0' thents:="0010"tg:="0100"a:='1'bg<='0'br<='1'elseif not(ts="0000" and tg="0001") thenif tg=&q
11、uot;0000" thentg:="1001"ts:=ts-1;elsetg:=tg-1;end if;elsets:="0000"tg:="0000"a:='0'state:=left;end if;end if;when left=>if a='0' thents:="0000"tg:="1001"a:='1'bL<='0'bg<='1'elseif not (ts="00
12、00" and tg="0001")thenif tg="0000" thentg:="1001"ts:=ts-1;elsetg:=tg-1;end if;elsets:="0000"tg:="0000"a:='0'state:=yellow;end if;end if;when yellow=>if a='0' thents:="0000"tg:="0100"a:='1'by<=
13、9;0'bL<='1'elseif not(ts="0000" and tg="0001") thenif tg="0000" thentg:="1001"ts:=ts-1;elsetg:=tg-1;end if;elsets:="0000"tg:="0000"a:='0'state:=red;end if;end if;when red=>if a='0' thents:="0011"t
14、g:="1001"a:='1'br<='0'by<='1'elseif not(ts="0000" and tg="0001") thenif tg="0000" thentg:="1001"ts:=ts-1 ;elsetg:=tg-1;end if;elsets:="0000"tg:="0000"a:='0'state:=green;end if;end if;end case;
15、timbs<=ts;timbg<=tg;end if;end process;end blu_arc;- 片選信號和數碼管顯示library ieee;use use entity dispa isport(clk:in std_logic;d0,d1,d2,d3:in std_logic_vector(3 downto 0);z:out std_logic_vector(3 downto 0);q:out std_logic_vector(6 downto 0);end dispa;architecture xuan_arc of dispa issignal d:std_log
16、ic_vector(3 downto 0);signal sel:std_logic_vector(2 downto 0);beginpi:process(clk)variable tmp:std_logic_vector(2 downto 0);beginif clk'event and clk='1' thenif tmp="000"thentmp:="001"elsif tmp="001" thentmp:="100"elsif tmp="100" thentmp:
17、="101"elsif tmp="101" thentmp:="000"end if;end if;sel<=tmp;end process pi;po:process(sel)begincase sel iswhen "000"=>z<="1110"d<=d0; -B 路個位計數when "001"=>z<="1101"d<=d1; -B 路十位計數when "100"=>z<=&
18、quot;1011"d<=d2; -A 路個位計數when others=>z<="0111"d<=d3; -A 路十位計數end case;end process po;p1:process(d)begincase d iswhen "0000" =>q<="1000000"when "0001" =>q<="1111001"when "0010" =>q<="0100100"when
19、 "0011" =>q<="0110000"when "0100" =>q<="0011001"when "0101" =>q<="0010010"when "0110" =>q<="0000010"when "0111" =>q<="1111000"when "1000" =>q<="00000
20、00"when others =>q<="0010000"end case;end process p1;end xuan_arc;- 整合控制。元件例化語句library ieee;use entity hldeng7 isport(clk:in std_logic;dout:out std_logic_vector(6 downto 0); -數碼管顯示輸出ar,ag,al,ay,br,bg,bl,by:out std_logic; - 紅綠燈狀態輸出k:out std_logic_vector(3 downto 0); -片選信號end entity hldeng7;architecture art of hldeng7 iscomponent fen is -元件聲明port(clk:in std_logic;clk1:out std_logic);end component fen;component alu is -元件聲明port(clk:in std_logic;ar,ag,al,ay:out std_logic;timas,timag:out std_logic_vector(3 downto 0);end component alu;component blu isport(clk:in std_log
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 碼頭防噪聲管理制度
- 砂石管理部管理制度
- 初中政治課程資源開發與法治教育融合研究論文
- 高中語文閱讀:校園經典文學作品分析與人文素養提升論文
- 中國醫用超聲儀行業市場占有率及投資前景預測分析報告
- 艾炙養生館管理制度
- 苗圃維護與管理制度
- 調直機行業相關投資計劃提議
- 財務制度體系
- 艾倫心理咨詢案例分析步驟
- 山東省威海市實驗中學2025屆七下英語期末達標檢測試題含答案
- 2025年河北省中考麒麟卷地理(三)及答案
- 河南天一大聯考2025年高二下學期期末學業質量監測英語試題
- 2025年北京市水務局所屬事業單位招聘工作人員101人筆試高頻重點提升(共500題)附帶答案詳解
- 【MOOC】新媒體文化十二講-暨南大學 中國大學慕課MOOC答案
- 國家開放大學《Python語言基礎》實驗2:基本數據類型和表達式計算參考答案
- 《心電監護》ppt課件
- 土地整治項目管理PPT
- GB∕T 40754-2021 商場公共設施服務規范
- 會計工作證明模板
- 中國核電標準化組織方式及工作方案
評論
0/150
提交評論