【正文】
elsif rising_edge(clk) then if count=500 then t=00000000。 elsif count=255 then t=11111111。 else count:=count+1。end if。end one。每次間隔50進行設(shè)計階梯波產(chǎn)生模塊jietibo:library ieee。use 。entity jietibo isport(reset:in std_logic。 t:buffer std_logic_vector(7 downto 0))。architecture one of jietibo isbeginprocess(clk)variable count:integer range 0 to 500。039。 elsif rising_edge(clk) then count:=count+1。 elsif count=450 then t=11011000。 elsif count=350 then t=10101000。 elsif count=250 then t=01110000。 elsif count=150 then t=01000100。 elsif count=50 then t=00011000。 end if。end process。(4)鋸齒波的設(shè)計采用0~255循環(huán)加法計數(shù)器實現(xiàn)。clk是時鐘信號,當(dāng)復(fù)位信號有效時,輸出為‘0’,輸出最小值設(shè)為“0”,最大值設(shè)為“255”,從“0”開始,當(dāng)時鐘檢測到有上升沿的時候,輸出就會呈現(xiàn)遞增的趨勢,加“1”。use 。use 。 clk: in std_logic。end entity。039。 elsif rising_edge(clk) then if t=11111111then t=00000000。 end if。end process。(5)、三角波的設(shè)計采用0~255~0循環(huán)加/減法計數(shù)器實現(xiàn)三角波產(chǎn)生模sanjiaobo:library ieee。use 。entity sanjiaobo isport(reset:in std_logic。 t:buffer std_logic_vector(7 downto 0))。architecture one of sanjiaobo isbeginprocess(clk)variable up:integer range 0 to 1。039。 elsif rising_edge(clk) then if up=1 then if t=11111111 then up:=0。 else t=t+1。 else if t=00000000then up:=1。 else t=t1。 end if。end process。(6)、分頻器數(shù)控分頻器的功能就是當(dāng)在輸入端給定不同輸入數(shù)據(jù)時,將對輸入的時鐘信號有不同的分頻比。本次設(shè)計采用八位的數(shù)控分頻器。分頻器USE 。ENTITY PULSE ISPORT ( CLK: in std_logic。 FOUT:out std_logic)。ARCHITECTURE behave OF PULSE IS SIGNAL FULL:STD_LOGIC。 BEGIN IF CLK39。139。 FULL=39。 ELSE CNT8:=CNT8+1。039。 END IF。 P_DIV:PROCESS(FULL) VARIABLE CNT2:STD_LOGIC。EVENT AND FULL=39。 THEN CNT2:=NOT CNT2。139。139。039。 END IF。END ARCHITECTURE behave。選擇器USE 。ENTITY Xuanzeqi ISPORT ( address: in std_logic_vector(2 downto 0)。 q:out std_logic_vector(7 downto 0))。ARCHITECTURE behave OF Xuanzeqi ISBEGINPROCESS(sel)BEGINCASE sel ISWHEN 001=q=d1。 階梯?WHEN 011=q=d3。 三角波WHEN 101=q=d5。END CASE。 END ARCHITECTURE be