【正文】
when″1101″=tmp=″1000010″。 顯示 A when″1011″=tmp=″1100000″。 when″1001″=tmp=″0000100″。 when″0111″=tmp=″0001111″。 when″0101″=tmp=″0100100″。 when″0011″=tmp=″0000110″。 輸入 0000時,顯示 0 when″0001″=tmp=″1001111″。 architecturearcofseg7is signaltmp:std—logic—vector(6downto0)。 a,b,c,d,e,f,g:outstd—logic)。 —logic—。圖中, dat[ 3..0]是 8421BCD碼的輸入,a、 b、 c、 d、 e、 f、 g是驅(qū)動數(shù)碼管顯示的 7個輸出信號(設(shè)低電平有效)。 第 10章 VHDL硬件描述語言簡介 圖 多地址譯碼器的仿真波形 第 10章 VHDL硬件描述語言簡介 【 例 】 7段譯碼器電路的設(shè)計。 e nd pr oc e s s 。 w he n o t he rs = E = 11 11 11 11 。 w he n 101 11 101 10 = E = 101 11 11 1 。 w he n 101 11 101 00 = E = 1 110 11 11 。 w he n 101 11 100 10 = E = 1 11 110 11 。 a rc h i t e c t ure a rc _de c ode of d e c ode i s be gi n proc e s s (A ) 第 10章 VHDL硬件描述語言簡介 be gi n c a s e A i s w he n 101 11 100 00 = E = 1 11 11 11 0 。 10 位地址輸入 E : out s t d_l ogi c _ve c t or(7 dow nt o 0) 8 位譯碼輸出 )。 us e i e e e .s t d_l ogi c _un s i gne l l 。 第 10章 VHDL硬件描述語言簡介 圖 多地址譯碼器的邏輯符號 第 10章 VHDL硬件描述語言簡介 表 多地址 0x2F0~ 0x2F7譯碼電路的輸入 /輸出對應(yīng)關(guān)系表 A 9 A 8 A 7 A 6 A 5 A 4 A 3 A 2 A 1 A 0 E 0 E 1 E 2 E 3 E 4 E 5 E 6 E 7 1 0 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 1 1 0 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 0 1 0 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 1 1 1 0 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 第 10章 VHDL硬件描述語言簡介 l i bra ry i e e e 。 第 10章 VHDL硬件描述語言簡介 圖 4位二進(jìn)制加法器的仿真波形 第 10章 VHDL硬件描述語言簡介 2. 【 例 】 設(shè)計一個多地址譯碼電路,該電路有10位地址輸入線 A9~ A0,要求當(dāng)?shù)刂反a為 0x2F0~ 0x2F7時,譯碼器的輸出 E0~ E7分別被選通,且低電平有效。 4位二進(jìn)制加法器的仿真波形如圖 。b)、(″0000″amp?!睘椴⒅眠\算符, (′0′amp。 產(chǎn)生進(jìn)位輸出 end arc_add4。 先進(jìn)行并置操作, 然后進(jìn)行加法運算 sum=s(3 downto 0)。b)+(“0000”amp。 定義內(nèi)部信號 s 第 10章 VHDL硬件描述語言簡介 begin s=(?0?amp。 進(jìn)位輸出 end add4。 低位來的進(jìn)位 sum : out std_logic_vector(3 downto 0)。 entity add4 is port( a,b : in std_logic_vector(3 downto 0)。 use 。 第 10章 VHDL硬件描述語言簡介 【 例 】 設(shè)計一個 4 電路邏輯符號如圖 。 )()(2 dcbaf ???? end process。 a rc h i t e c t ur e behav ior of log is b e gi n proc ess be gi n f1=((not a ) and b) nor (c and d)。 定義輸入端口 a,b ,c, d f1 , f2 :out std _logic)。 use ieee .std_logic_uns 。 第 10章 VHDL硬件描述語言簡介 圖 f f2運算電路的邏輯符號 第 10章 VHDL硬件描述語言簡介 l ibr ary iee e。 第 10章 VHDL硬件描述語言簡介 VHDL語言描述實例 [ 例 ] 設(shè)計一個實現(xiàn)))((21dcbafcdbaf ????? 的組合邏輯電路。 end process。 end if。 else z = ?1?。 when s3 = if x = ?0? then z = ?0?。 next_state = s3。 next_state = s2。 end if。 else z = ?0?。 when s1 = if x = ?0? then z = ?0?。 next_state = s2。 next_state = s0。 組合邏輯 bin: process(current_state, x) begin next_state = current _state。 current_state = next_state。 用枚舉類型進(jìn)行狀態(tài)定義 signal current_state, next_state : state_type。 end mealy。 entity mealy is port ( x,clock : in bit。 use 。以下為狀態(tài)表(見表 )和狀態(tài)圖(見圖 )以及實現(xiàn)此狀態(tài)機(jī)的 VHDL代碼。 end behavior。 end case。 when s2 = z = ?1?。 描述每種狀態(tài)下電路的輸出 output_gen: process (current_state, x) begin case current_state is when s0 = z = ?0?。 end case。 else next_state =s1。 end if。 when s2 = if x = ?0? then next_state = s2。 else next_state =s2。 end if。 默認(rèn)狀態(tài)分配 c a s e c urre nt _s t a t e i s w he n s 0 = i f x = ‘0’ t h e n ne xt _s t a t e = s 0。 e nd p roc e s s 。 狀態(tài)信號的定義 be gi n 第 10章 VHDL硬件描述語言簡介 同步單元 s ync h : pro c e s s be gi n w a i t unt i l c l oc k ’e v e nt a nd c l oc k = ‘1’。 a rc hi t e c t u re be ha vi or of m oore i s t ype s t a t e _t ype i s ( s0 , s1 , s 2, s 3 )。 z : out s t d _l ogi c )。 e nt i t y m oore i s po rt ( c l oc k : i n s t d_l ogi c 。 use ieee .std_logic_116 。注意,本例中狀態(tài)機(jī)的描述主要由兩個進(jìn)程( process)組成:其中一個描述狀態(tài)轉(zhuǎn)移,另一個說明處于每一狀態(tài)下電路表現(xiàn)的功能(此部分為組合邏輯電路)。 第 10章 VHDL硬件描述語言簡介 表 有限狀態(tài)機(jī)的描述風(fēng)格 描述風(fēng)格 功能劃分 所需進(jìn)程數(shù) 1 1 、次態(tài)邏輯、狀態(tài)寄存器、輸出邏輯 1 2 1 、次態(tài)邏輯、狀態(tài)寄存器 2 、輸出邏輯 2 3 1 、次態(tài)邏輯 2 、狀態(tài)寄存器、輸出邏輯 2 4 1 、次態(tài)邏輯、輸出邏輯 2 、狀態(tài)寄存器 2 5 1 、狀態(tài)邏輯 2 、狀態(tài)寄存器 3 、輸出邏輯 3 第 10章 VHDL硬件描述語言簡介 3. 1) Moore 本例將介紹一個基本的 Moore型有限狀態(tài)機(jī)。這兩種狀態(tài)機(jī)的主要區(qū)別在于:Mealy型狀態(tài)機(jī)的輸出由狀態(tài)機(jī)的輸入和狀態(tài)機(jī)的狀態(tài)共同決定; Moore型狀態(tài)機(jī)的輸出僅與狀態(tài)機(jī)的狀態(tài)有關(guān),而與狀態(tài)機(jī)的輸入無關(guān)。這是例化元件端口名與連接實體端口名的關(guān)聯(lián)方式,其在 PORTMAP中的 (2)位置關(guān)聯(lián)方式:省去例化元件端口 =部分,在PORTMAP中只列出當(dāng)前系統(tǒng)中的連接實體端口名即可,但要求連接實體端口名與例化元件端口定義中的端口名一 (3)混合關(guān)聯(lián)方式:上述兩種關(guān)聯(lián)方式同時并存。 第 10章 VHDL硬件描述語言簡介 3. 把已經(jīng)設(shè)計好的設(shè)計實體定義為一個元件或一個模塊,它可以被高層次的設(shè)計引用。 第 10章 VHDL硬件描述語言簡介 3 with選擇表達(dá)式 select 賦值目標(biāo) =表達(dá)式 when … 表達(dá)式 when選擇值; 第 10章 VHDL硬件描述語言簡介 例如,選擇信號賦值語句的用法如下 : architecture oneof max41ais begin with qselect y=awhen ″