DAC7513 V1.0 ----
----VHDL CODE ------------------
-- Company: AUJUS TECHNOLOGY PVT .LTD
-- Engineer: ARUN CHAUDHARY
--
-- Project Name: DIGITAL TO ANALOG CONVETER
-- Target Devices: ZYBO ,ZEDBOARD
-- Tool Versions: VIVADO 2018.3
-- Description: DAC7513
--
-- Dependencies:
--
-- Revision:VERSION V1.0
-- Revision 0.01 - File Created
-- Additional Comments:
-- ---operating at 60 mhz for zedboad --operating at 100mhz
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity dac7513 is
generic (
power_down : std_logic_vector ( 1 downto 0) :="00" --- ---------pd1,pd0 bother are zro for normal operation
) ;
Port (
clk: in STD_LOGIC;
rst : in STD_LOGIC;
start : in std_Logic ;
adc_ack_next_frame: out std_logic ;
DIN : in STD_LOGIC_VECTOR (11 downto 0);
dac_SCL : out STD_LOGIC;
dac_SYNC_NOT : OUT STD_LOGIC ;
dac_DOUT : OUT STD_lOGIC
);
end dac7513;
architecture Behavioral of dac7513 is
type state is ( st1, st2, st3) ;
signal ps , ns : state ;
signal count_reg, count_next : unsigned ( 3 downto 0) ;
signal din_reg , din_next : std_logic_vector ( 15 downto 0) ;
signal scl , sync,dout_reg , dout_next : std_logic ;
signal sync_low : std_Logic ;
constant dont_care_bit: std_logic_vector (1 downto 0) := "XX" ;
signal clk_20mhz : std_Logic ;
signal clk_30mhz : std_Logic ;
signal c_reg , c_next : unsigned( 3 downto 0) ;
signal frame_complete : std_logic :='0' ;
signal dac_reg : std_logic_Vector ( 11 downto 0) :=(others=>'0') ;
component clk_wiz_0 is
port(
clk_out1:out std_logic ;
clk_out2:out std_logic ;
clk_in1: in std_logic
);
end component ;
begin
----------==============input register tto store the data
process( clk ,rst)
begin
if (rst='1') then
dac_reg<=(others=>'0') ;
elsif rising_edge ( clk) then
-- elsif falling_edge ( clk) then
dac_reg <= "101110111000";
-- dac_reg <= din ;
end if ;
end process ;
clk_30mhz<= clk ;
--dac_scl<= clk_20mhz;
dac_scl<= clk;
dac_sync_not <=sync ;
dac_dout <= dout_reg ;
----clock 20 mhz from 100 mhz
--u1 : clk_wiz_0
-- port map (
-- clk_out1=>clk_20mhz,
-- clk_out2=>clk_30mhz,
-- clk_in1=>clk
-- );
-----clock 100mhz
--process (clk_20mhz ,rst )
--begin
--if ( rst='1') then
-- ps <=st1 ;
-- din_reg <=(others=>'0') ;
-- c_reg <=(others=>'0') ;
-- elsif falling_edge ( clk_20mhz ) then
-- ps <=ns ;
-- din_reg <=din_next ;
-- c_reg <= c_next ;
-- end if ;
----clock 30 mhz
--process (clk_30mhz ,rst )
--begin
--if ( rst='1') then
-- ps <=st1 ;
-- din_reg <=(others=>'0') ;
-- c_reg <=(others=>'0') ;
-- elsif falling_edge ( clk_30mhz ) then
-- ps <=ns ;
-- din_reg <=din_next ;
-- c_reg <= c_next ;
-- end if ;
--end process ;
------------============falling edge data capture in ths sclk
process (clk_30mhz ,rst )
begin
if ( rst='1') then
ps <=st1 ;
din_reg <=(others=>'0') ;
c_reg <=(others=>'0') ;
dout_reg <='0' ;
elsif falling_edge ( clk_30mhz ) then
ps <=ns ;
din_reg <=din_next ;
c_reg <= c_next ;
dout_reg <= dout_next ;
end if ;
end process ;
----next state logic
process ( ps ,c_reg , din_reg ,start,dac_reg,dout_reg )
begin
ns <= ps ;
-- din_next <= dont_care_bit & power_down & din ;
din_next <= dont_care_bit & power_down & dac_reg ;
sync <='0' ;
c_next <= c_reg ;
frame_complete <='0' ;
dout_next <= dout_reg ;
case ps is
when st1=>
sync<='0' ;
if ( start ='1') then
ns <=st2 ;
end if;
when st2=>
sync <='1' ;
if (c_reg =1) then -----=======================minimum 50 ns sync signal mucst be high here 1 i.e 66 ns becuae of 30 mhz
--------======period is 33 ns ;
ns <=st3 ;
c_next <=(others=>'0') ;
else
c_next <=c_reg +1 ;
end if ;
when st3 =>
sync<='0' ; ----------=============fassling of sync signal means starting of the conversion
dout_next <=din_reg( 15) ; ---------------===========msb first store in the 16 bit shiff register
din_next (15 downto 0) <= din_reg ( 14 downto 0) & '0' ; -----==============right shift data and store in the shift register of the dac7513
if(c_reg=15) then
c_next <=(others=>'0' ) ;
ns <=st2 ;
frame_complete<='1' ;
else
c_next <= c_reg +1 ;
end if ;
end case ;
end process ;
adc_ack_next_frame <='1' when (frame_complete ='1') else '0' ;
end Behavioral;
----------------------------------
No comments:
Post a Comment