library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity frequence_controlled_word_1 is
port( clk : in std_logic;
RST : in std_logic;
frequence_controlled_word : out std_logic_vector(29 downto 0)
);
end frequence_controlled_word_1;
architecture behave of frequence_controlled_word_1 is
signal f : std_logic_vector(29 downto 0);
signal change_amount : std_logic_vector(29 downto 0);
signal num_of_step : std_logic_vector(29 downto 0);
signal sign : boolean;
begin
process(RST,clk)
begin
if (RST = '1') then
sign <= false;
elsif (clk = '1' and clk'event) then
if (sign = false) then
f <= f - change_amount;
sign <= true;
else
f <= f + change_amount;
sign <= false;
end if;
end if;
end process;
process(RST,clk)
begin
if (RST = '1') then
num_of_step <= "000000000000000000000000000000";
f <= "001000110110100011011010001110";--f0;
elsif (clk = '1' and clk'event) then
if (num_of_step="000000000000000000101110111001") then
num_of_step <= "000000000000000000000000000000";
f <= "001000110110100011011010001110";--f0;
else
num_of_step <= num_of_step + "000000000000000000000000000001";
end if;
end if;
end process;
process(num_of_step)
begin
change_amount <= num_of_step;
change_amount(29 downto 11) <= change_amount(18 downto 0);
change_amount(10 downto 0) <= "00000000000";
end process;
process(f)
begin
frequence_controlled_word <= f;
end process;
end behave;
这是我编得一个DDS频率控制字程序,要求频率以初值为中心上下浮动,扫描到正负最大值后再回到初值,如此循环。仿真发现reset为1时,frequence_controlled_word无法赋值,请教大侠如何改正。