|
|
----------------------------------------------------------------------------------
|
|
|
-- Company:
|
|
|
-- Engineer:
|
|
|
--
|
|
|
-- Create Date: 15:26:29 12/07/2013
|
|
|
-- Design Name:
|
|
|
-- Module Name: DAC8581 - Behavioral
|
|
|
-- Project Name:
|
|
|
-- Target Devices:
|
|
|
-- Tool versions:
|
|
|
-- Description:
|
|
|
--
|
|
|
-- Dependencies:
|
|
|
--
|
|
|
-- Revision:
|
|
|
-- Revision 0.01 - File Created
|
|
|
-- Additional Comments:
|
|
|
--
|
|
|
----------------------------------------------------------------------------------
|
|
|
library IEEE;
|
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
|
|
use IEEE.numeric_std.all;
|
|
|
library LPP;
|
|
|
use lpp.lpp_cna.all;
|
|
|
|
|
|
-- Uncomment the following library declaration if using
|
|
|
-- arithmetic functions with Signed or Unsigned values
|
|
|
use IEEE.NUMERIC_STD.ALL;
|
|
|
|
|
|
-- Uncomment the following library declaration if instantiating
|
|
|
-- any Xilinx primitives in this code.
|
|
|
--library UNISIM;
|
|
|
--use UNISIM.VComponents.all;
|
|
|
|
|
|
entity DAC8581 is
|
|
|
generic(clkfreq : integer := 100);
|
|
|
Port ( clk : in STD_LOGIC;
|
|
|
rstn : in STD_LOGIC;
|
|
|
smpclk : in STD_LOGIC;
|
|
|
sclk : out STD_LOGIC;
|
|
|
csn : out STD_LOGIC;
|
|
|
sdo : out STD_LOGIC;
|
|
|
smp_in : in STD_LOGIC_VECTOR (15 downto 0)
|
|
|
);
|
|
|
end DAC8581;
|
|
|
|
|
|
architecture Behavioral of DAC8581 is
|
|
|
|
|
|
|
|
|
signal smpclk_reg : std_logic;
|
|
|
signal sclk_gen : std_logic_vector(3 downto 0);
|
|
|
signal sclk_net : std_logic;
|
|
|
signal load : std_logic;
|
|
|
signal data_sreg : std_logic_vector(15 downto 0);
|
|
|
signal csn_sreg : std_logic_vector(15 downto 0);
|
|
|
begin
|
|
|
|
|
|
|
|
|
|
|
|
sclk_net <= sclk_gen(1);
|
|
|
sclk <= sclk_net;
|
|
|
|
|
|
process(rstn,clk)
|
|
|
begin
|
|
|
if rstn ='0' then
|
|
|
smpclk_reg <= '0';
|
|
|
sclk_gen <= "0000";
|
|
|
load <= '0';
|
|
|
elsif clk'event and clk = '1' then
|
|
|
smpclk_reg <= smpclk;
|
|
|
sclk_gen <= std_logic_vector(unsigned(sclk_gen) + 1);
|
|
|
if smpclk_reg = '0' and smpclk = '1' then
|
|
|
load <= '1';
|
|
|
else
|
|
|
load <= '0';
|
|
|
end if;
|
|
|
|
|
|
end if;
|
|
|
end process;
|
|
|
|
|
|
process(load,sclk_net)
|
|
|
begin
|
|
|
if load ='1' then
|
|
|
data_sreg <= smp_in;
|
|
|
csn_sreg <= (others => '0');
|
|
|
elsif sclk_net'event and sclk_net = '1' then
|
|
|
data_sreg <= data_sreg(14 downto 0) & '1';
|
|
|
csn_sreg <= csn_sreg(14 downto 0) & '1';
|
|
|
end if;
|
|
|
end process;
|
|
|
|
|
|
process(rstn,sclk_net)
|
|
|
begin
|
|
|
if rstn ='0' then
|
|
|
sdo <= '1';
|
|
|
csn <= '1';
|
|
|
elsif sclk_net'event and sclk_net = '0' then
|
|
|
sdo <= data_sreg(15);
|
|
|
csn <= csn_sreg(15);
|
|
|
end if;
|
|
|
end process;
|
|
|
|
|
|
|
|
|
|
|
|
end Behavioral;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|