用VHDL設(shè)計(jì)十翻二運(yùn)算電路_第1頁
用VHDL設(shè)計(jì)十翻二運(yùn)算電路_第2頁
用VHDL設(shè)計(jì)十翻二運(yùn)算電路_第3頁
用VHDL設(shè)計(jì)十翻二運(yùn)算電路_第4頁
用VHDL設(shè)計(jì)十翻二運(yùn)算電路_第5頁
已閱讀5頁,還剩6頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、設(shè)計(jì)一個(gè)十翻二運(yùn)算電路內(nèi)容摘要: 十翻二電路可以用簡單的一些芯片組合而成,也可以用可編程邏輯器件來實(shí)現(xiàn),本次實(shí)踐用quartus 5.0來編程,F(xiàn)PGA采用EPF10K10LC84-4,通過本次實(shí)踐學(xué)會基本的實(shí)驗(yàn)技能,提高運(yùn)用理論知識解決實(shí)際問題的能力。關(guān)鍵詞:十翻二運(yùn)算電路 quartus EPF10K10LC84-4一、設(shè)計(jì)要求設(shè)計(jì)一個(gè)十翻二運(yùn)算電路,它能完成下列工作:1) 能完成三位十進(jìn)制數(shù)到二進(jìn)制數(shù)的轉(zhuǎn)換。2) 能自動顯示十進(jìn)制數(shù)(七段數(shù)碼管)和二進(jìn)制數(shù)(發(fā)光二級管)。3) 具有手動清零功能。三、確定電路組成方案要把三位十進(jìn)制數(shù)轉(zhuǎn)換為二進(jìn)制數(shù),運(yùn)算過程可以這樣,比如輸入是128,則顯示

2、乘100相加乘10128=1*100+2*10+8所以要包括乘100,乘10和相加的模塊,由于還要顯示輸入三位十進(jìn)制數(shù),因此還要有一個(gè)數(shù)碼管顯示模塊,電路方框圖如下: 百位 二進(jìn)制 十位 個(gè)位四、各個(gè)模塊的VHDL描寫1)、乘10模塊的VHDLlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity cheng10 isport (ten:in std_logic_vector(3 downto 0); tenout:out std_logic_vector(9 downto 0);end;a

3、rchitecture one of cheng10 issignal a:std_logic_vector(9 downto 0);signal b:std_logic_vector(9 downto 0);beginprocess(ten)begin a(6 downto 3)<=ten; b(4 downto 1)<=ten; tenout<=a+b;end process;end;2)、乘100模塊的VHDLlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity c

4、heng100 isport (hum:in std_logic_vector(3 downto 0); humout:out std_logic_vector(9 downto 0);end;architecture one of cheng100 issignal a:std_logic_vector(9 downto 0);signal b:std_logic_vector(9 downto 0);signal c:std_logic_vector(9 downto 0);signal d:std_logic_vector(9 downto 0);signal e:std_logic_v

5、ector(9 downto 0);signal f:std_logic_vector(9 downto 0);beginprocess(hum)begin a(6 downto 3)<=hum; b(4 downto 1)<=hum; c<=a+b; d(9 downto 3)<=c(6 downto 0); e(7 downto 1)<=c(6 downto 0); f<=d+e; humout<=f;end process;end;3)、相加模塊的VHDLlibrary ieee;use ieee.std_logic_1164.all;use i

6、eee.std_logic_unsigned.all;entity xiangjia isport (ena:in std_logic; humout:in std_logic_vector(9 downto 0); tenout:in std_logic_vector(9 downto 0); oneout:in std_logic_vector(3 downto 0); shuchu:out std_logic_vector(9 downto 0);end;architecture one of xiangjia isbeginprocess(humout,tenout,oneout)be

7、gin if ena='0' then shuchu<="0000000000" else shuchu<=humout+tenout+oneout; end if;end process;end;4)、數(shù)碼管顯示模塊的VHDLLIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; use ieee.std_logic_unsigned.all; entity shumaxianshi is port(clk:in std_logic; ena:in std_logic; shuru:in std_logic_vec

8、tor(11 downto 0); sg:out std_logic_vector(6 downto 0); yima:out std_logic_vector(2 downto 0); end;architecture one of shumaxianshi is signal cnt4:std_logic_vector(1 downto 0); signal a:std_logic_vector(3 downto 0);beginp1:process(cnt4,ena) begin if ena='0' then a<="0000" else ca

9、se cnt4 is when "00" => yima <="000"a<=shuru(3 downto 0); when "01" => yima <="001"a<=shuru(7 downto 4);when "10" => yima <="010"a<=shuru(11 downto 8);when "11" => yima <="011"a<=“0000

10、”; when others => null; end case; end if; end process p1;p2:process(clk) begin if clk'event and clk='1' then cnt4 <=cnt4+1; end if;end process p2;p3:process(a) begin case a is when "0000" => sg <="0111111"when "0001" => sg <="0000110&q

11、uot; when "0010" => sg <="1011011"when "0011" => sg <="1001111" when "0100" => sg <="1100110"when "0101" => sg <="1101101" when "0110" => sg <="1111101"when "0111&qu

12、ot; => sg <="0000111" when "1000" => sg <="1111111"when "1001" => sg <="1101111" when others => null; end case;end process p3;end;5)、頂層文件的原理圖輸入6)、電腦仿真結(jié)果其中hum , ten, one是采用十進(jìn)制顯示,shuchu是采用十六進(jìn)制顯示。把sg和yima進(jìn)行放大,sg6.0分別對應(yīng)數(shù)碼管的fa,如下圖所示:從

13、上圖可以看出,yima為010時(shí)shuchu顯示的是1,001時(shí)是2,000時(shí)是8,011時(shí)是0,通過掃描的方式讓外部的四個(gè)數(shù)碼管輪流顯示。五、硬件測試1)、引腳鎖定如下:2)、硬件測試結(jié)果如下表所示:enaSw9 Sw10 Sw11 Sw12(百位)Sw1 Sw2 Sw3 Sw4(十位)Sw5 Sw6 Sw7 Sw8(個(gè)位)9 8 7 6 5 4 3 2 1 0(二進(jìn)制數(shù))數(shù)碼管顯示10 0 0 10 0 1 01 0 0 00 0 1 0 0 0 0 0 0 0012810 1 0 10 0 0 10 0 1 01 0 0 0 0 0 0 0 0 0051210 1 1 00 0 1 11

14、 0 0 11 0 0 1 1 1 1 1 1 1063910 0 0 00 0 0 11 0 0 0 0 0 0 0 0 1 0 0 1 000180X X X XX X X XX X X X0 0 0 0 0 0 0 0 0 00000其中1表示接高電平或是燈亮,0接低電平或是燈按,X表示接高電平或是低電平都可以。六、電路分析生成RTL,如下圖所示:1)、下圖是乘10模塊的內(nèi)部電路:從圖中可以看出,主要還是由10位全加器構(gòu)成的,由于要對ten信號左移三位保存在A9.0,ten信號左移一位保存在B9.0中,在把A9.0和 B9.0相加,這個(gè)過程要3個(gè)時(shí)間周期。2)、下面是乘100的電路圖:3

15、)、相加的電路4)、顯示電路七、小結(jié):在做本次實(shí)踐過程中,主要是碰到兩個(gè)比較大的困難:一、 設(shè)計(jì)思路,剛開始不知道要怎么入手,結(jié)合以前做過的十翻二數(shù)字電路課程設(shè)計(jì),一開始想把原來數(shù)電課設(shè)的電路圖,用VHDl把各個(gè)芯片寫好,再用原理圖輸入法,把各個(gè)芯片連起來,結(jié)果在調(diào)試時(shí)發(fā)現(xiàn)行不通,硬件測試時(shí),只能顯示一位十進(jìn)制到二進(jìn)制的轉(zhuǎn)換。后來,重新設(shè)計(jì)電路,從數(shù)學(xué)思路上考慮,把百位乘于100,十位乘于10,再和個(gè)位相加就能轉(zhuǎn)換為相應(yīng)的二進(jìn)制數(shù),而且這個(gè)方法思路清晰,結(jié)構(gòu)簡單,設(shè)計(jì)簡單,操作方便。二、 原理圖總線的命名,開始時(shí)一直不知道總線要怎么命名,出現(xiàn)“Error: Can't find name for bus”和“Error: Width mismatch in port "hum3.0" of instance "inst1" and type cheng100 - source is ""shuru11

溫馨提示

  • 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)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論