3、:=NOTCNT2;--如果溢出标志信号FULL为高电平,D触发器输出取反IFCNT2='1'THENFOUT<='1';ELSEFOUT<='0';ENDIF;ENDIF;ENDPROCESSP_DIVEND;一.按键选择模块 代码 LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_ARITH.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; ENTITY BUTTON IS PORT ( d : IN STD_LOGIC_VECTOR(2 DOWNT
4、O 0) a,b,c : OUT STD_LOGIC ) END; ARCHITECTURE ONE OF BUTTON IS BEGIN PROCESS( d ) BEGIN CASE d IS WHEN "000" => NULL; WHEN OTHERS => a <= d(0);--dlt b <= d(1);--sqr c <= d(2);--sin END CASE; END PROC
5、ESS; END; 三角波信号产生模块 代码 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity delta is port ( clk : in std_logic clr : in std_logic; q : out std_logic_vector(7 downto 0) ) end delta; architect
6、ure one of delta is begin process( clk,clr) variable num : std_logic_vector(7 downto 0); variable ff : std_logic; begin if clr = '0' then num := "00000000"; else if clk'event and clk = '1' then--时钟信号有上升沿时有效 if ff = '0' then if num = "11111000" then
7、 ff :='1'; else num := num + 8; end if;--以上,ff=0时,上升,直至num加到11111000时,使ff=1 else if num = "00000111" then num := "00000000"; ff := '0'; else num := num -8;--以上,ff=1时,下降,直至num减到00000111时,使ff=0 end if; end if; end