【文章內(nèi)容簡介】
的輸入變量 ?標(biāo)準(zhǔn)邏輯序列類型,std_logic_vector ? 邏輯輸出 描述: 同邏輯輸入。 ? 邏輯關(guān)系 描述: ① 列出真值表 適用于輸入變量較少、或函數(shù)有效輸入值較少的情況。 ② 求取邏輯函數(shù)表達(dá)式 輸出變量較少或輸出變量相互獨立的情況。 ③ 邏輯關(guān)系直接表述 (邏輯關(guān)系概括 ?直接邏輯描述 ) 碼制轉(zhuǎn)換等問題(數(shù)值運算類) 例二:設(shè)計一位 BCD碼加法器 entity bcd_adder is port(d1,d2:in std_logic_vector(3 downto 0)。 Bh,Bl:out std_logic_vector(3 downto 0))。 end bcd_adder。 architecture aa of bcd_adder is signal a,b,t,s:std_logic_vector(7 downto 0)。 begin a = 0000amp。d1。 b = 0000amp。d2。 t = a + b 。 s = t when t10 else t+6。 Bh = s(7 downto 4)。 Bl = s(3 downto 0)。 end aa。 二、常用時序邏輯電路設(shè)計 ( 1) 觸發(fā)器設(shè)計 ( D) ( 2)計數(shù)器設(shè)計(分頻器) ( 3)移位寄存器設(shè)計 ( 4)狀態(tài)機設(shè)計:序列檢測器 Process的物理意義 Process進(jìn)程 由敏感信號觸發(fā),并以 Process結(jié)束為時間分界點, 實現(xiàn)信號的初態(tài)到次態(tài)的轉(zhuǎn)換 。分界點以前引用信號的當(dāng)前值(初態(tài)值),并通過賦值語句指定信號的次態(tài)值;分界點以后,次態(tài)值生效。 時序電路 VHDL描述方法 I. 狀態(tài)方程法 確定敏感信號,用信號初態(tài)值和其他輸入表示出次態(tài)值,然后代入賦值語句。 II. 狀態(tài)表法 確定敏感信號,按一定規(guī)則列出狀態(tài)轉(zhuǎn)換表,逐行描述或多行概括描述。 ( 1)觸發(fā)器設(shè)計 D Q CP CP D Qn+1 無變化 X Qn 01 0 0 01 1 1 D觸發(fā)器 LIBRARY IEEE。 USE 。 ENTITY dff IS PORT( cp,d: IN STD_LOGIC。 q: OUT STD_LOGIC)。 END dff。 ARCHITECTURE a OF dff IS BEGIN process(cp) begin if cp39。event and cp=39。139。 then q=d。 end if。 end process。 END a。 (2)A 簡單計數(shù)器設(shè)計 計 數(shù) 器 CLK Q3Q2Q1Q0 四位加計數(shù)器 LIBRARY ieee。 USE 。 USE 。 USE 。 ENTITY counter IS PORT( clk: in STD_LOGIC。 q: buffer STD_LOGIC_vector(3 downto 0))。 END counter。 ARCHITECTURE a OF counter IS BEGIN process(clk) begin if (clk39。event and clk=39。139。) then q=q+1。 end if。 end process。 END a。 四位加計數(shù)器 計 數(shù) 器 CLK CLR (2)B 帶 同步 清零、 同步 置數(shù)功能的計數(shù)器 LD Q3Q2Q1Q0 D3D2D1D0 控制信號 CLR、 LD:具有更高優(yōu)先級 LIBRARY ieee。 USE 。 USE 。 USE 。 ENTITY counter IS PORT( clk,clr,ld: in STD_LOGIC。 d: in STD_LOGIC_vector(3 downto 0)。 q: buffer STD_LOGIC_vector(3 downto 0))。 END counter。 ARCHITECTURE a OF counter IS BEGIN process(clk) begin if (clk39。event and clk=39。139。) then if(clr=39。139。) then q=0000。 elsif(ld=39。139。)then q=d。 else q=q+1。 end if。 end if。 end process。 END a。 計 數(shù) 器 CLK CLR (2)C 帶 異步 清零、 同步 置數(shù)功能的計數(shù)器 LD Q3Q2Q1Q0 D3D2D1D0