![第4章 VHDL設(shè)計提高_第1頁](http://file4.renrendoc.com/view/443db376aa417a66715dab5589f79ceb/443db376aa417a66715dab5589f79ceb1.gif)
![第4章 VHDL設(shè)計提高_第2頁](http://file4.renrendoc.com/view/443db376aa417a66715dab5589f79ceb/443db376aa417a66715dab5589f79ceb2.gif)
![第4章 VHDL設(shè)計提高_第3頁](http://file4.renrendoc.com/view/443db376aa417a66715dab5589f79ceb/443db376aa417a66715dab5589f79ceb3.gif)
![第4章 VHDL設(shè)計提高_第4頁](http://file4.renrendoc.com/view/443db376aa417a66715dab5589f79ceb/443db376aa417a66715dab5589f79ceb4.gif)
![第4章 VHDL設(shè)計提高_第5頁](http://file4.renrendoc.com/view/443db376aa417a66715dab5589f79ceb/443db376aa417a66715dab5589f79ceb5.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
4.2常用邏輯電路的VHDL實現(xiàn)4.1VHDL設(shè)計邏輯電路的基本思想和方法第4章VHDL設(shè)計提高4.1
VHDL設(shè)計邏輯電路的基本思想和方法4.1.1邏輯函數(shù)表達式方法4.1.2真值表方法4.1.3電路連接描述方法4.1.4不完整條件語句方法4.1.5層次化設(shè)計方法利用VHDL中的邏輯運算就可以實現(xiàn)任何組合邏輯電路的設(shè)計。4.1.1邏輯函數(shù)表達式方法在數(shù)字邏輯電路設(shè)計中,利用真值表來表達組合電路是非常常用的手段,其特點是直觀、明了,將真值表用VHDL描述出來也是硬件語言常用的方法之一。4.1.2真值表方法所謂電路連接描述方法,就是將給定的電路原理圖用portmap語句來實現(xiàn)。在電路中,某些元件不是基本元件,無法用邏輯函數(shù)表達式來表示,也就是說,無法用邏輯運算來實現(xiàn)。4.1.3電路連接描述方法圖4.1電路連接描述法的圖例libraryieee;useieee.std_logic_1164.all;entitydff1isport(clk:instd_logic;d:instd_logic;q:outstd_lgoic);end;architecturebhvofdff1issignalq1:std_logic;beginprocess(clk,q1)beginifclk'eventandclk='1'thenq1<=d;endif;endprocess;q<=q1;endbhv;4.1.4不完整條件語句方法圖4.2QuartsII綜合后的RTL電路圖層次化設(shè)計方法是自頂向下設(shè)計方法的最好體現(xiàn)。自頂向下的設(shè)計方法將系統(tǒng)分解為各個模塊的集合后,可以對設(shè)計的每個獨立模塊分別設(shè)計,最后將不同的模塊集成為最終的系統(tǒng),并對其進行綜合測試和評價。4.1.5層次化設(shè)計方法圖4.312位全加器電路原理圖1.子模塊設(shè)計libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityadder4bisport(clr,cin:instd_logic;a,b:instd_logic_vector(3downto0);s:outstd_logic_vector(3downto0);cout:outstd_logic);endadder4b;architectureartofadder4bissignalsint:std_logic_vector(4downto0);signalaa,bb:std_logic_vector(4downto0);beginprocess(clr)beginifclr='1'thensint<="00000";elseaa<='0'&a;bb<='0'&b;sint<=aa+bb+cin;endif;s<=sint(3downto0);cout<=sint(4);endprocess;endart;a2.頂層模塊設(shè)計libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityadder12bisport(clr,cin:instd_logic;a,b:instd_logic_vector(11downto0);s:outstd_logic_vector(11downto0);cout:outstd_logic);endadder12b;architectureartofadder12biscomponentadder4bisport(clr,cin:instd_logic;a,b:instd_logic_vector(3downto0);s:outstd_logic_vector(3downto0);cout:outstd_logic);endcomponent;signalcarry_out0,carry_out1:std_logic; beginu1:adder4bportmap(clr=>clr,cin=>cin,a=>a(3downto0),b=>b(3downto0),s=>s(3downto0),cout=>carry_out0);u2:adder4bportmap(clr=>clr,cin=>carry_out,a=>a(7downto4),b=>b(7downto4),s=>s(7downto4),cout=>carry_out1);u3:adder4bportmap(clr=>clr,cin=>carry_out,a=>a(11downto8),b=>b(11downto8),s=>s(11downto8),cout=>cout);endart;4.2常用邏輯電路的VHDL實現(xiàn)4.2.1基本組合邏輯電路設(shè)計4.2.2基本時序邏輯電路設(shè)計4.2.3狀態(tài)機的設(shè)計4.2.1基本組合邏輯電路設(shè)計1.基本邏輯門圖4.4基本邏輯門2.三態(tài)門圖4.58位三態(tài)控制門電路3.數(shù)據(jù)選擇器
4.3線-8線譯碼器圖4.63線-8譯碼器端口圖下面用VHDL語言分別以兩種方法描述3線-8線譯碼器,其源程序如下。方法一:用case語句描述,利用真值表輔助,很容易編寫程序。libraryieee;useieee.std_logic_1164.all;entitydecoder3_8isport(a,b,c,g1,g2a,g2b:instd_logic;y:outstd_logic_vector(7downto0));end;architectureaofdecoder3_8issignaldz:std_logic_vector(2downto0);begindz<=c&b&a;process(dz,g1,g2a,g2b)beginif(g1='1'andg2a='0'andg2b='0')thencasedziswhen"000"=>y<="11111110";when"001"=>y<="11111101";when"010"=>y<="11111011";when"011"=>y<="11110111";when"100"=>y<="11101111";when"101"=>y<="11011111";when"110"=>y<="10111111";when"111"=>y<="01111111";whenothers=>y<="××××××××";endcase;elsey<="11111111";endif;endprocess;end;方法二:利用移位操作符SLL和程序包std_logic_unsigned中的數(shù)據(jù)類型轉(zhuǎn)換函數(shù)conv_integer可以十分簡潔地完成3線-8線譯碼器的設(shè)計。(略去實體部分)architectureaofdecoder3_8isbeginoutput<="00000001"SLLCONV_INTEGER(input);end;方法三:也是利用移位操作符SLL,只不過是每次進程的啟動只改變一個端口的輸出。architecturebehaveofdecoder3_8isbeginprocess(input)beginoutput<=(others=>'0');output(conv_integer(input))<='1';endprocess;endbehave;5.優(yōu)先編碼器表4.2 8-3優(yōu)先編碼器的真值表輸入輸出din0din1din2din3din4din5din6din7output0output1output2×××××××0000××××××01100×××××011010××××0111011×××01111100××011111101×011111111001111111111libraryieee;useieee.std_logic_1164.allentitycoderisport(din:instd_logic_vector(0to7);output:outstd_logic_vector(0to2));end;architecturebehaveofcoderissignalsint:std_logic_vevtor(4downto0);beginprocess(din)beginif(din(7)='0')thenoutput<="000";elsif(din(6)='0')thenoutput<="100";elsif(din(5)='0')thenoutput<="010";elsif(din(4)='0')thenoutput<="110";elsif(din(3)='0')thenoutput<="001";elsif(din(2)='0')thenoutput<="101";elsif(din(1)='0')thenoutput<="011";elseoutput<="111";endif;endprocess;endbehav;6.七段碼譯碼器七段碼的輸出去驅(qū)動七段碼顯示器,才能顯示正常的數(shù)字。圖4.7共陰極數(shù)碼管顯示器電路示意圖libraryieee;useieee.std_logic_1164.allentitydecl7sisport(a:instd_logic_vector(3downto0);led7s:outstd_logic_vector(6downto0));end;architecturebehaveofdecl7sisbegin圖4.7共陰極數(shù)碼管顯示器電路示意圖
process(a)begincaseaiswhen"0000"=>led7s<="0111111";when"0001"=>led7s<="0000110";when"0010"=>led7s<="1011011";when"0011"=>led7s<="1001111";when"0100"=>led7s<="1100110";when"0101"=>led7s<="1101101";when"0110"=>led7s<="1111101";when"0111"=>led7s<="0000111";when"1000"=>led7s<="1111111";when"1001"=>led7s<="1101111";when"1010"=>led7s<="1110111";when"1011"=>led7s<="1111100";when"1100"=>led7s<="0111001";when"1101"=>led7s<="1011110";when"1110"=>led7s<="1111001";when"1111"=>led7s<="1110001";whenothers=>null;endcase;endprocess;end;7.二-十進制BCD譯碼器BCD譯碼器在電路設(shè)計中也經(jīng)常用到,尤其在計數(shù)、顯示、譯碼電路中。圖4.8BCD譯碼器端口圖libraryieee;useieee.std_logic_1164.all;useieee.std_logic_signed.all;entitybcdymqisport(din:inintegerrange15downto0;a,b:outintegerrange9downto0);end;architecturefpq1ofbcdymqisbeginp1:process(din)beginifdin<10thena<=din;b<=0;elsea<=din-10;b<=1;endif;endprocessp1;end;8.多位加(減)法器下面以4位全減器為例來說明,加法器可以用相似的方法實現(xiàn)。libraryieee;useieee.std_logic_1164.all;useieee.std_logic_signed.all;entityjianfaqiisport(a,b:instd_logic_vector(0to3);c0:instd_logic;c1:outstd_logic;d:outstd_logic_vector(0to3));end;architectureaofjianfaqiisbeginprocessbeginifa>b+c0thend<=a-(b+c0);c1<='0';elsec1<='1';d<=("10000")-(b+c0-a);endif;endprocess;end;4.2.2基本時序邏輯電路設(shè)計T觸發(fā)器的動作特點是翻轉(zhuǎn),我們以上升沿觸發(fā)的T觸發(fā)器設(shè)計為例進行講解。1.觸發(fā)器
libraryieee;useieee.std_logic_1164.all;useieee.std_logic_signed.all;entitytff1isport(t,clk:instd_logic;q:outstd_logic);end;architectureaoftff1issignalq_temp:std_logic;beginp1:process(clk)beginifrising_edge(clk)thenift='1'then--當T=1時T觸發(fā)器具有2分頻的功能
q_temp<=notq_temp;elseq_temp<=q_temp;endif;endif;q<=q_temp;endprocess;q<=q_temp;end;2.計數(shù)器計數(shù)器是邏輯電路中使用最廣泛的電路,在復(fù)雜電路的設(shè)計中幾乎離不開計數(shù)器。(1)n位二進制計數(shù)器設(shè)計一般把計數(shù)器的模值M=2n、狀態(tài)編碼為自然二進制數(shù)的計數(shù)器簡稱為n位二進制計數(shù)器。為了使設(shè)計的信號更具有工程實際的意義,下面的例子使用了一般情況下的in、out端口模式。libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitycnt4IS port(clk :in std_logic;q :out std_logic_vector(3downto0) ); endcnt4;architecturebehaveofcnt4issignalq1:std_logic_vector(3downto0);beginprocess(clk)beginif(clk'eventandclk='1')thenq1<=q1+1;endif;endprocess;q<=q1;endbehave;圖4.94位二進制計數(shù)器的仿真波形圖(2)一般計數(shù)器設(shè)計libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitycnt10is port(clk,rst,en,updown:instd_logic;cq:outstd_logic_vector(3downto0)); endcnt10;architecturebehaveofcnt10isbeginprocess(clk,rst,en,updown)variablecqi:std_logic_vector(3downto0);beginifrst='1'thencqi:=(others=>'0'); --計數(shù)器異步復(fù)位
elsif(clk'eventandclk='1')then --檢測時鐘上升沿
ifen='1'then --檢測是否允許計數(shù)(同步使能)
ifupdown='0'thenifcqi<9thencqi:=cqi+1; --允許計數(shù),檢測是否小于9elsecqi:=(others=>'0'); --大于9,計數(shù)值清零
endif;elseifcqi>0thencqi:=cqi-1; --檢測是否大于0elsecqi:=(others=>'1'); --否則,計數(shù)值置1endif;endif;endif;endif;cq<=cqi; --將計數(shù)值向端口輸出endprocess;endbehave;圖4.10一般計數(shù)器的仿真波形圖3.分頻器分頻器電路的實質(zhì)其實還是計數(shù)器的設(shè)計。
下面介紹兩種任意分頻的方法。
方法一:利用計數(shù)器的進位輸出端分頻。
要設(shè)計n分頻的分頻器,我們就設(shè)計一個N進制計數(shù)器,將計數(shù)器的進位作為分頻器的輸出。方法二:數(shù)控分頻器(通過改變并行置數(shù)值分頻)。
數(shù)控分頻器是利用計數(shù)值可并行預(yù)置的加法計數(shù)器設(shè)計完成的。方法是將計數(shù)器溢出位與預(yù)置數(shù)加載輸入信號相減。圖4.11數(shù)控分頻器的仿真波形圖4.移位寄存器方法一:利用信號的傳輸延遲性。圖4.12一般移位寄存器的仿真波形圖方法二:帶模式控制的移位寄存器。圖4.13帶模式控制的移位寄存器的仿真波形圖4.2.3狀態(tài)機的設(shè)計
溫馨提示
- 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度演員廣告代言合同
- 2025年度醫(yī)療機構(gòu)藥品采購委托代購合同
- 農(nóng)業(yè)綠色發(fā)展行動計劃
- 養(yǎng)老院合同協(xié)議書
- 用戶體驗設(shè)計原則及實踐
- 簡易買賣合同
- 云計算在企業(yè)資源規(guī)劃中的應(yīng)用
- 三農(nóng)產(chǎn)品追溯系統(tǒng)建設(shè)方案
- 模具設(shè)計與制造技術(shù)作業(yè)指導(dǎo)書
- 建房勞務(wù)人工的合同
- 高考英語經(jīng)常用的七百個詞匯
- 不定代詞用法總結(jié)及配套練習(xí)題
- PLC編程與應(yīng)用技術(shù)西門子S7-1200(高職)全套教學(xué)課件
- 部編版六年級下冊道法第一單元《完善自我、健康成長 》
- JJG 976-2024透射式煙度計
- 半干法脫硫工藝
- 強基計劃自我陳述范文模板
- 林黛玉人物形象分析
- 網(wǎng)絡(luò)和信息安全教育課件
- 公司貨款管理制度
- 術(shù)后下肢深靜脈血栓的預(yù)防和護理
評論
0/150
提交評論