entity pmod_da3 is
Port ( clk : in STD_LOGIC;
CSn : out STD_LOGIC;
LDACn : out STD_LOGIC;
SCLK : out STD_LOGIC;
SDAT : out STD_LOGIC;
data_taken : out STD_LOGIC := '0';
level : in STD_LOGIC_VECTOR (15 downto 0));
end pmod_da3;
architecture Behavioral of pmod_da3 is
type array_type is array (0 to 1 ) of std_logic_vector(15 downto 0);
signal array_name :array_type:=("0000000000000001","0000000000000011");
constant len : integer := 19;
signal CSn_shift_reg : std_logic_vector(len-1 downto 0) := (len-17 downto 0 => '1', others => '0');
signal LDACn_shift_reg : std_logic_vector(len-1 downto 0) := (1 => '0', others => '1');
signal SDAT_shift_reg : std_logic_vector(len-1 downto 0) := (others => '0');
signal sclk_state : std_logic_vector(1 downto 0) := "00";
begin
SCLK <= sclk_state(0);
LDACn <= LDACn_shift_reg(0);
CSn <= CSn_shift_reg(0);
clk_proc: process(clk)
variable a: integer range 0 to 15;
begin
if rising_edge(clk) then
data_taken <= '0';
case sclk_state is
when "00" => sclk_state <= "01";
-- Mpve the shift regeister along
SDAT <= array_name(a);
a:=a+1;
if (a=15) then
a:=0;
end if;
-- SDAT_shift_reg <= SDAT_shift_reg(len-2 downto 0) & 'X';
LDACn_shift_reg <= LDACn_shift_reg(len-2 downto 0) & LDACn_shift_reg(len-1);
if LDACn_shift_reg(1) = '0' then
SDAT_shift_reg(SDAT_shift_reg'high downto SDAT_shift_reg'high-level'high) <= level;
data_taken <= '1';
end if;
when "01" => sclk_state <= "10";
when "10" => sclk_state <= "11";
CSn_shift_reg <= CSn_shift_reg(len-2 downto 0) & CSn_shift_reg(len-1);
when others => sclk_state <= "00";
end case;
end if;
end process;
end Behavioral;
Question
guneryunus
i want to generate sine wave on dac (http://store.digilentinc.com/pmod-da3-one-16-bit-d-a-output/) i am using 16 bit dac and i am using spartan 3e . i cant do it . help me ??
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity pmod_da3 is
Port ( clk : in STD_LOGIC;
CSn : out STD_LOGIC;
LDACn : out STD_LOGIC;
SCLK : out STD_LOGIC;
SDAT : out STD_LOGIC;
data_taken : out STD_LOGIC := '0';
level : in STD_LOGIC_VECTOR (15 downto 0));
end pmod_da3;
architecture Behavioral of pmod_da3 is
type array_type is array (0 to 1 ) of std_logic_vector(15 downto 0);
signal array_name :array_type:=("0000000000000001","0000000000000011");
constant len : integer := 19;
signal CSn_shift_reg : std_logic_vector(len-1 downto 0) := (len-17 downto 0 => '1', others => '0');
signal LDACn_shift_reg : std_logic_vector(len-1 downto 0) := (1 => '0', others => '1');
signal SDAT_shift_reg : std_logic_vector(len-1 downto 0) := (others => '0');
signal sclk_state : std_logic_vector(1 downto 0) := "00";
begin
SCLK <= sclk_state(0);
LDACn <= LDACn_shift_reg(0);
CSn <= CSn_shift_reg(0);
clk_proc: process(clk)
variable a: integer range 0 to 15;
begin
if rising_edge(clk) then
data_taken <= '0';
case sclk_state is
when "00" => sclk_state <= "01";
-- Mpve the shift regeister along
SDAT <= array_name(a);
a:=a+1;
if (a=15) then
a:=0;
end if;
-- SDAT_shift_reg <= SDAT_shift_reg(len-2 downto 0) & 'X';
LDACn_shift_reg <= LDACn_shift_reg(len-2 downto 0) & LDACn_shift_reg(len-1);
if LDACn_shift_reg(1) = '0' then
SDAT_shift_reg(SDAT_shift_reg'high downto SDAT_shift_reg'high-level'high) <= level;
data_taken <= '1';
end if;
when "01" => sclk_state <= "10";
when "10" => sclk_state <= "11";
CSn_shift_reg <= CSn_shift_reg(len-2 downto 0) & CSn_shift_reg(len-1);
when others => sclk_state <= "00";
end case;
end if;
end process;
end Behavioral;
Link to comment
Share on other sites
7 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.