1、 基于DDS信号技术的信号发生器的设计 直接数字式频率合成技术DDS是新一代的频率合成技术,采用数字控制信号的相位增加技术,具有频率分辨率高,频率切换快,频率切换时相位连续和相位噪声低以及全数字化易于集成等优点而被广泛采用。 一. 程序代码 (1) ADDER32B library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity ADDER32B is port( ain : in std_logic_vector(31 downto 0); bin
2、 in std_logic_vector(31 downto 0); cout: ou t std_logic_vector(31 downto 0) ); end; architecture one of ADDER32B is begin cout <= ain + bin; end; (2)juxing_rom LIBRARY ieee; USE ieee.std_logic_1164.all; LIBRARY altera_mf; USE altera_mf.all; ENTITY juxing_rom IS PORT ( ad
3、dress : IN STD_LOGIC_VECTOR (11 DOWNTO 0); clock : IN STD_LOGIC ; q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0) ); END juxing_rom; ARCHITECTURE SYN OF juxing_rom IS SIGNAL sub_wire0 : STD_LOGIC_VECTOR (7 DOWNTO 0); COMPONENT altsyncram GENERIC ( address_aclr_a : STRING; init_file
4、 STRING; intended_device_family : STRING; lpm_hint : STRING; lpm_type : STRING; numwords_a : NATURAL; operation_mode : STRING; outdata_aclr_a : STRING; outdata_reg_a : STRING; widthad_a : NATURAL; width_a : NATURAL; width_byteena_a : NATURAL ); PORT (
5、 clock0 : IN STD_LOGIC ; address_a : IN STD_LOGIC_VECTOR (11 DOWNTO 0); q_a : OUT STD_LOGIC_VECTOR (7 DOWNTO 0) ); END COMPONENT; BEGIN q <= sub_wire0(7 DOWNTO 0); altsyncram_component : altsyncram GENERIC MAP ( address_aclr_a => "NONE", init_file => "../MIF/juxing.mif",
6、 intended_device_family => "Cyclone", lpm_hint => "ENABLE_RUNTIME_MOD=NO", lpm_type => "altsyncram", numwords_a => 4096, operation_mode => "ROM", outdata_aclr_a => "NONE", outdata_reg_a => "CLOCK0", widthad_a => 12, width_a => 8, width_byteena_a => 1 ) PORT MAP (
7、clock0 => clock, address_a => address, q_a => sub_wire0 ); END SYN; (3)mux3_1 library ieee; use ieee.std_logic_1164.all; entity mux3_1 is port( sin:in std_logic_vector(7 downto 0); sanjiao,juxing:in std_logic_vector(7 downto 0); a,b:in std_logic; cout:out std_l
8、ogic_vector(7 downto 0) ); end mux3_1; architecture behavior of mux3_1 is signal addr:std_logic_vector(1 downto 0); begin process(a,b) begin addr(0)<=a; addr(1)<=b; case addr is when "00" => cout<=sin; when "01" => cout<=sanjiao; when "10" => cout
9、<=juxing; when others => null; end case; end process; end behavior; (4)sanjiao_rom LIBRARY ieee; USE ieee.std_logic_1164.all; LIBRARY altera_mf; USE altera_mf.all; ENTITY sanjiao_rom IS PORT ( address : IN STD_LOGIC_VECTOR (11 DOWNTO 0); clock : IN STD_LOGIC ; q
10、 : OUT STD_LOGIC_VECTOR (7 DOWNTO 0) ); END sanjiao_rom; ARCHITECTURE SYN OF sanjiao_rom IS SIGNAL sub_wire0 : STD_LOGIC_VECTOR (7 DOWNTO 0); COMPONENT altsyncram GENERIC ( address_aclr_a : STRING; init_file : STRING; intended_device_family : STRING; lpm_hint : STRING;
11、lpm_type : STRING; numwords_a : NATURAL; operation_mode : STRING; outdata_aclr_a : STRING; outdata_reg_a : STRING; widthad_a : NATURAL; width_a : NATURAL; width_byteena_a : NATURAL ); PORT ( clock0 : IN STD_LOGIC ; address_a : IN STD_LOGIC_VECTOR (11 DOWNTO 0
12、); q_a : OUT STD_LOGIC_VECTOR (7 DOWNTO 0) ); END COMPONENT; BEGIN q <= sub_wire0(7 DOWNTO 0); altsyncram_component : altsyncram GENERIC MAP ( address_aclr_a => "NONE", init_file => "../MIF/sanjiao.mif", intended_device_family => "Cyclone", lpm_hint => "ENABLE_RUNTIME_M
13、OD=NO", lpm_type => "altsyncram", numwords_a => 4096, operation_mode => "ROM", outdata_aclr_a => "NONE", outdata_reg_a => "CLOCK0", widthad_a => 12, width_a => 8, width_byteena_a => 1 ) PORT MAP ( clock0 => clock, address_a => address, q_a => sub_wire0 ); END
14、SYN; (5)sinx256_rom LIBRARY ieee; USE ieee.std_logic_1164.all; LIBRARY altera_mf; USE altera_mf.all; ENTITY sinx256_rom IS PORT ( address : IN STD_LOGIC_VECTOR (7 DOWNTO 0); inclock : IN STD_LOGIC ; q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0) ); END sinx256_rom; ARCHITECTURE SYN
15、OF sinx256_rom IS SIGNAL sub_wire0 : STD_LOGIC_VECTOR (7 DOWNTO 0); COMPONENT altsyncram GENERIC ( address_aclr_a : STRING; init_file : STRING; intended_device_family : STRING; lpm_hint : STRING; lpm_type : STRING; numwords_a : NATURAL; operation_mode : STRING; o
16、utdata_aclr_a : STRING; outdata_reg_a : STRING; widthad_a : NATURAL; width_a : NATURAL; width_byteena_a : NATURAL ); PORT ( clock0 : IN STD_LOGIC ; address_a : IN STD_LOGIC_VECTOR (7 DOWNTO 0); q_a : OUT STD_LOGIC_VECTOR (7 DOWNTO 0) ); END COMPONENT; BEGIN q
17、 <= sub_wire0(7 DOWNTO 0); altsyncram_component : altsyncram GENERIC MAP ( address_aclr_a => "NONE", init_file => "../MIF/sinx256_rom.mif", intended_device_family => "Cyclone", lpm_hint => "ENABLE_RUNTIME_MOD=NO", lpm_type => "altsyncram", numwords_a => 256, operation_mode
18、 => "ROM", outdata_aclr_a => "NONE", outdata_reg_a => "CLOCK0", widthad_a => 8, width_a => 8, width_byteena_a => 1 ) PORT MAP ( clock0 => inclock, address_a => address, q_a => sub_wire0 ); END SYN; (6)REG32B library ieee; use ieee.std_logic_1164.all; entity REG32B
19、is port( clk : in std_logic; din : in std_logic_vector(31 downto 0); dout: out std_logic_vector(31 downto 0) ); end; architecture one of REG32B is begin process(clk,din) begin if clk'event and clk = '1' then dout <= din; end if; end process; ----dout <= passer
20、 end; (6)sin LIBRARY ieee; USE ieee.std_logic_1164.all; LIBRARY altera_mf; USE altera_mf.all; ENTITY sin IS PORT ( address : IN STD_LOGIC_VECTOR (7 DOWNTO 0); clock : IN STD_LOGIC ; q : OUT STD_LOGIC_VECTOR (7 DOWNTO 0) ); END sin; ARCHITECTURE SYN OF sin IS S
21、IGNAL sub_wire0 : STD_LOGIC_VECTOR (7 DOWNTO 0); COMPONENT altsyncram GENERIC ( clock_enable_input_a : STRING; clock_enable_output_a : STRING; init_file : STRING; intended_device_family : STRING; lpm_hint : STRING; lpm_type : STRING; numwords_a : NATURAL; ope
22、ration_mode : STRING; outdata_aclr_a : STRING; outdata_reg_a : STRING; widthad_a : NATURAL; width_a : NATURAL; width_byteena_a : NATURAL ); PORT ( clock0 : IN STD_LOGIC ; address_a : IN STD_LOGIC_VECTOR (7 DOWNTO 0); q_a : OUT STD_LOGIC_VECTOR (7 DOWNTO 0) );
23、 END COMPONENT; BEGIN q <= sub_wire0(7 DOWNTO 0); altsyncram_component : altsyncram GENERIC MAP ( clock_enable_input_a => "BYPASS", clock_enable_output_a => "BYPASS", init_file => "../sin.mif", intended_device_family => "Stratix II", lpm_hint => "ENABLE_RUNTIME_MOD=NO",
24、 lpm_type => "altsyncram", numwords_a => 256, operation_mode => "ROM", outdata_aclr_a => "NONE", outdata_reg_a => "CLOCK0", widthad_a => 8, width_a => 8, width_byteena_a => 1 ) PORT MAP ( clock0 => clock, address_a => address, q_a => sub_wire0 ); END SYN; (二)仿真波形






