Altera_Forum
Honored Contributor
15 years agoHow to make DDS with NCO megacore function?
I try to make square wave with NCO Megacore Function as below.
But, The square wave is not good for use like dds. How to make square wave like ad9850 dds ----- below is VHDL Code --------- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity dds is port ( phi_inc_i : IN STD_LOGIC_VECTOR (31 DOWNTO 0); clk : IN STD_LOGIC; reset_n : IN STD_LOGIC; clken : IN STD_LOGIC; freq_mod_i : IN STD_LOGIC_VECTOR (31 DOWNTO 0); fsin_o : OUT STD_LOGIC_VECTOR (21 DOWNTO 0); out_valid : OUT STD_LOGIC; square : out std_logic ); end dds; architecture behav of dds is component nco PORT ( phi_inc_i : IN STD_LOGIC_VECTOR (31 DOWNTO 0); clk : IN STD_LOGIC; reset_n : IN STD_LOGIC; clken : IN STD_LOGIC; freq_mod_i : IN STD_LOGIC_VECTOR (31 DOWNTO 0); fsin_o : OUT STD_LOGIC_VECTOR (21 DOWNTO 0); out_valid : OUT STD_LOGIC ); end component; signal f_sin : std_logic_vector(21 downto 0); begin the_nco_is : nco port map ( phi_inc_i => phi_inc_i, clk => clk, reset_n => reset_n, clken => clken, freq_mod_i => freq_mod_i, fsin_o => f_sin, out_valid => out_valid ); fsin_o <= f_sin; the_comparator_is : process(clk, reset_n) begin if reset_n = '0' then square <= '0'; elsif rising_edge(clk) then if f_sin > "1000000000000000000000" then square <= '1'; else square <= '0'; end if; end if; end process; end behav;