劉世偉VHDL第二次作業(yè)_第1頁
劉世偉VHDL第二次作業(yè)_第2頁
劉世偉VHDL第二次作業(yè)_第3頁
劉世偉VHDL第二次作業(yè)_第4頁
劉世偉VHDL第二次作業(yè)_第5頁
已閱讀5頁,還剩2頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、計數(shù)顯示電路設(shè)計課 程: VHDL數(shù)字系統(tǒng)設(shè)計與測試?yán)?師: 學(xué) 號: 姓 名: 計數(shù)顯示電路設(shè)計一 設(shè)計要求設(shè)計輸出為3位BCD碼的計數(shù)顯示電路。由三個模塊構(gòu)成:十進(jìn)制計數(shù)器(BCD_CNT)、分時總線切換電路(SCAN)和七段顯示譯碼器電路(DEC_LED)。BCD碼計數(shù)電路從0計到9然后返回到0從新計數(shù)。3位BCD碼計數(shù)器可以實現(xiàn)從0到999的十進(jìn)制計數(shù)。要將計數(shù)過程用七段顯示LED數(shù)碼管顯示出來,這里采用動態(tài)分時總線切換電路對數(shù)碼管進(jìn)行掃描,對數(shù)碼管依次分時選中進(jìn)行輸出計數(shù)的個、十、百位的數(shù)據(jù)??驁D如圖1:圖1二 設(shè)計原理圖2是源程序的RTL級電路圖(RTL Viewer )。整個設(shè)計

2、分十進(jìn)制計數(shù)器模塊(BCD_CNT)、分時總線切換電路模塊(SCAN)和七段顯示譯碼器電路模塊(DEC_LED)構(gòu)成。總的輸入為十進(jìn)制計數(shù)器時鐘clk,異步復(fù)位清零信號reset,分時總線切換電路時鐘CL。在reset信號為0期間,在每個clk的上升沿計數(shù)器將加1。在每個cl的上升沿將會改變對三個數(shù)碼管的掃描選通??偟妮敵鰹閿?shù)碼管選通信號sel(三位),輸出到七段數(shù)碼管的數(shù)據(jù)信號ledout(七位)。圖2為了檢驗系統(tǒng)的正確與否,這里還添加了四個輸出:十進(jìn)制計數(shù)器輸出c1(四位)、c2(四位)、c3(四位),分時總線切換電路一個輸出q(四位),它是對計數(shù)器輸出c1、c2、c3進(jìn)行分時輸出。分時選

3、通個、十、百位的數(shù)碼管并將相應(yīng)要顯示的數(shù)據(jù)輸出到七段顯示譯碼器電路(DEC_LED),由此實現(xiàn)數(shù)碼管的動態(tài)掃描顯示。三 VHDL實現(xiàn)(1)頂層模塊:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity top is -定義了一個頂層的模塊topport(clk,reset:in std_logic; CL:in std_logic; c1,c2,c3:out std_logic_vector(3 downto 0); ledout:

4、out std_logic_vector(6 downto 0); q:out std_logic_vector(3 downto 0); sel:out std_logic_vector(2 downto 0);end top;architecture content of top issignal c1_1,c2_1,c3_1:std_logic_vector(3 downto 0);signal q_1:std_logic_vector(3 downto 0);-因為c1,c2,c3,q是中間信號量,也是輸出,故引入c1_1,c2_1,c3_1q_1作為中間變量component BCD

5、_CNT is -定義元件BCD_CNT port(clk,reset:in std_logic; c1,c2,c3:out std_logic_vector(3 downto 0);end component;component SCAN is -定義元件SCANport( c1,c2,c3:in std_logic_vector(3 downto 0); CL:in std_logic; q:out std_logic_vector(3 downto 0); sel:out std_logic_vector(2 downto 0);end component;component DEC_L

6、ED is -定義元件DEC_LEDport( q:in std_logic_vector(3 downto 0); ledout:out std_logic_vector(6 downto 0);end component;beginu1: BCD_CNT port map (clk,reset,c1_1,c2_1,c3_1); -調(diào)用元件實例BCD_CNTu2: SCAN port map(c1_1,c2_1,c3_1,CL,q_1,sel); -調(diào)用元件實例SCANu3: DEC_LED port map(q_1,ledout); -調(diào)用元件實例DEC_LEDc1<=c1_1; -

7、中間變量值賦給輸出c2<=c2_1;c3<=c3_1;q <=q_1; end content;(2)十進(jìn)制計數(shù)器電路(BCD_CNT)模塊:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity BCD_CNT is port(clk,reset:in std_logic; c1,c2,c3:out std_logic_vector(3 downto 0);end BCD_CNT;architecture cnt

8、of BCD_CNT issignal cn1,cn2,cn3:std_logic_vector(3 downto 0); begin cnt1:process(clk,reset) begin if(reset='1') then cn1<="0000" elsif(clk'event and clk='1') then if(cn1<9) then cn1<=cn1+1; else cn1<="0000" end if; end if; end process cnt1; c1<=

9、cn1; -個位計數(shù) cnt2:process(cn1(3),reset) -cn1(3)是clk的十分頻 begin if(reset='1') then cn2<="0000" elsif(cn1(3)'event and cn1(3)='0') then if(cn2<9) then cn2<=cn2+1; else cn2<="0000" end if; end if; end process cnt2; c2<=cn2; -十位計數(shù) cnt3:process(cn2(3),r

10、eset) -cn2(3)是clk的一百分頻 begin if(reset='1') then cn3<="0000" elsif(cn2(3)'event and cn2(3)='0') then if(cn3<9) then cn3<=cn3+1; else cn3<="0000" end if; end if; end process cnt3; c3<=cn3; -百位計數(shù)end cnt;(3)分時總線切換電路(SCAN)模塊:library ieee;use ieee.std

11、_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity SCAN is port( c1,c2,c3:in std_logic_vector(3 downto 0); cl:in std_logic; q:out std_logic_vector(3 downto 0); sel:out std_logic_vector(2 downto 0); end SCAN;architecture one of SCAN issignal cnt:std_logic_vector(1 dow

12、nto 0);signal q_temp:std_logic_vector(3 downto 0);signal sel_temp:std_logic_vector(2 downto 0); begin p1:process(cl) -模3計數(shù)器 begin if(cl'event and cl='1') then if(cnt<2) then cnt<=cnt+1; else cnt<="00" end if; end if; end process p1; p2:process(cnt) begin case cnt is -產(chǎn)

13、生分時切換信號q_temp; when "00" => q_temp<=c1; sel_temp<="001" when "01" => q_temp<=c2; sel_temp<="010" when "10" => q_temp<=c3; sel_temp<="100" when others=> null; end case; end process p2; q<=q_temp; sel<=sel_

14、temp;end one;(4)七段顯示譯碼器電路(DEC_LED)模塊:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity DEC_LED is port( q:in std_logic_vector(3 downto 0); ledout:out std_logic_vector(6 downto 0);end DEC_LED;architecture one of DEC_LED is begin process(q) -七

15、段譯碼電路 begin case q is when "0000" => ledout<="0111111" when "0001" => ledout<="0000110" when "0010" => ledout<="1011011" when "0011" => ledout<="1001111" when "0100" => ledout<=&qu

16、ot;1100110" when "0101" => ledout<="1101101" when "0110" => ledout<="1111101" when "0111" => ledout<="0000111" when "1000" => ledout<="1111111" when "1001" => ledout<="1101111" when others => null; end case; end process;end one; 四 仿真結(jié)果及分析圖2是電路的總體輸入輸出仿真波形。圖3由圖3可以看出,當(dāng)掃描頻率CL很大的時候,sel從1、2、4變化,即在一個時刻,sel只有一位為高,計數(shù)器的輸出只有一位C1或C2或C3選中,并且正確的輸出。當(dāng)復(fù)位信號reset先為高的時候清零,當(dāng)變?yōu)榈偷臅r候隨著clk上升沿到來計數(shù)器開始計數(shù),從000999,c1為個位,十位為c2,c3是百位。計數(shù)器為0時,ledout輸出為十六進(jìn)制3F(2進(jìn)制0111111),為1時輸出為為06H,等等,輸

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(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)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論