library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity DAC0832 is
port(clk:in std_logic; --系统时钟
rst:in std_logic; --复位信号
ile: out std_logic; --数据锁存允许信号
cont: out std_logic; --控制信号(WR1、WR2、CS、Xfer)
data_out: out std_logic_vector(7 downto 0)); --波形数据输出
end DAC0832;
architecture behav of DAC0832 is
signal q:integer range 0 to 63; --计数器
signal data:std_logic_vector(7 downto 0); --波形数据
begin
process(clk)
begin
if rst='1' then q<=0; --复位,对计数器q清零
elsif clk'event and clk='1' then
if q=63 then q<=0; --此IF语句对系统时钟进行64分频
if data="11111111" then data<="00000000"; --此IF语句产生锯齿波波形数据
else data<=data+1;
end if;
else q<=q+1;
end if;
end if;
end process;
ile<='1';cont<='0';data_out<=data; --ile、cont赋值;波形数据输出;
end behav;