⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dds32_2.vhd

📁 dds应用主要产生正弦波形
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
entity dds32_2 is
    port(  sysclk  : in std_logic;         -- 系统时钟
          ddsout  : out std_logic_vector(9 downto 0);-- DDS输出
            sel         : in std_logic;   -- 输入频率字高低16位选择
            selok       : in std_logic;   -- 选择好信号
            pfsel       : in std_logic;  -- 输入频率、相位选择
            -- 频率/相位字输入(与sel、selok配合使用)
            fpin        : in std_logic_vector(15 downto 0));
    end dds32_2;
architecture behave of dds32_2 is
    component dds is                           -- DDS主模块
generic(
                freq_width : integer := 32;     -- 输入频率字位宽
                phase_width : integer := 12;    -- 输入相位字位宽
                adder_width : integer := 32;    -- 累加器位宽
                romad_width : integer := 10;  -- 正弦ROM表地址位宽
                rom_d_width : integer := 10   -- 正弦ROM表数据位宽
                );  
        port( clk     : in std_logic;         -- DDS合成时钟
freqin : in std_logic_vector (freq_width-1 downto 0);-- 频率字输入
phasein :in std_logic_vector(phase_width-1 downto 0);-- 相位字输入    
ddsout  :out std_logic_vector(rom_d_width-1 downto 0));-- DDS输出
    end component dds;
    signal  clkcnt  : integer range 4 downto 0; -- 分频器
    signal  clk     : std_logic;
    signal  freqind : std_logic_vector(31 downto 0);  -- 频率字
    signal  phaseind: std_logic_vector(11 downto 0);  -- 相位字    
begin
    i_dds  : dds      -- 例化DDSC
        port map(clk => clk, ddsout => ddsout, 
              phasein => phaseind, freqin => freqind);
    clk <= sysclk;
process(sysclk) begin   --频率字的输入
        if(sysclk'event and sysclk = '1') then
            if(selok = '1' and pfsel = '0') then
                if(sel = '1') then
                    freqind(31 downto 16) <= fpin;  else
                    freqind(15 downto 0) <= fpin;
                end if;
            elsif(selok = '1' and pfsel = '1') then
                phaseind <= fpin(11 downto 0);
            end if;
        end if;
    end process;    
end behave;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -