library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.NUMERIC_STD.all; use ieee.math_real.all; entity AD7960_sim is port ( CLKp : in std_logic; CLKn : in std_logic; CNVp : in std_logic; CNVn : in std_logic; DCOp : out std_logic; DCOn : out std_logic; Dp : out std_logic; Dn : out std_logic; EN : in std_logic_vector(3 downto 0) ); end AD7960_sim; architecture sim of AD7960_sim is --- CLOCK --- signal counter500 : integer range 0 to 99 := 0; signal CLKp_buff : std_logic := '0'; signal CNVp_buff : std_logic := '0'; --- DATA --- type ROM512kx18 is array (0 to 511) of signed(17 downto 0); signal ROM : ROM512kx18; signal counter : unsigned(8 downto 0) := (others => '0'); signal samplecounter : unsigned(8 downto 0) := (others => '0'); signal speed : unsigned(8 downto 0) := "000000001"; signal ADC_Data_buff : std_logic_vector(17 downto 0) := (others => '0'); signal ADC_Data_SR : std_logic_vector(17 downto 0) := (others => '0'); begin DCOp <= transport CLKp after 3ns; DCOn <= transport CLKn after 3ns; Dp <= ADC_Data_SR(17); Dn <= not ADC_Data_SR(17); process begin wait for 2 ns; CLKp_buff <= CLKp; CNVp_buff <= CNVp; if CLKp_buff = '1' and CLKp = '0' then ADC_Data_SR <= ADC_Data_SR(16 downto 0) & '0'; end if; if CNVp_buff = '0' and CNVp = '1' then samplecounter <= samplecounter + 1; counter <= counter + speed; if samplecounter = 511 then speed <= speed + 4; samplecounter <= (others => '0'); end if; if speed > 510 and samplecounter = 511 then wait; end if; ADC_Data_buff <= std_logic_vector(ROM(to_integer(counter))); end if; counter500 <= counter500 + 1; if CLKp = '1' then counter500 <= 0; end if; if counter500 = 16 then ADC_Data_SR <= ADC_Data_buff; end if; end process; tabel: for I in 0 to 511 generate ROM(I) <= to_signed(integer(sin(2.0*MATH_PI*(real(I)+0.5)/512.0)*131071.5),18); end generate; end;