📄 squaproc.vhdl
字号:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity squaproc 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(8 downto 0)); --dds输出9位,寻512个数
end squaproc;
architecture Behavioral of squaproc is
signal acc : std_logic_vector(15 downto 0); --累加器,16位
signal freqw : std_logic_vector(15 downto 0):="0000000001100100";
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 7);
--9位,地址为0~511
end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -