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

📄 sinproc.vhdl

📁 Direct Digital Synthesis (DDS),最好用的可步进的数字频率发生器的方法
💻 VHDL
字号:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity sinproc is
    Port ( clk, reset: in std_logic; --clk为65536Hz(pow(2,16))
	      --input_select: in std_logic;--输入频率1/相位0选择
           data_in :in std_logic_vector(15 downto 0);	
			  --相位增量14位(用16位,目的是和累计器位数一样),输入的是频率的大小
           ddsout : out std_logic_vector(9 downto 0));  --dds输出10位,寻1024个数
end sinproc;

architecture Behavioral of sinproc is
			    signal acc : std_logic_vector(15 downto 0);	--累加器,16位
				 signal freqw : std_logic_vector(15 downto 0):="0000000001000000";
begin  
    process(clk,reset,data_in)
	      begin
			   if (reset='0') then	 --复位,即重新设置频率
				       acc<="0000000000000000";--累加器清零,16位
						 freqw<=data_in;--输入频率值
            elsif (clk'event and clk='1' ) then
				      acc <=acc+freqw; --实现累加功能
            end if;
    end process;
      ddsout<=acc(15 downto 6);
	    --10位,地址为0~1023
	
end Behavioral;

⌨️ 快捷键说明

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