nliaqat
Newbie level 6

What is a general approach to control both the 10KHZ frequency and phase (angle) shifts of a N-number of signals generation.
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity triangle_wave_gen is
Port (
clk : in STD_LOGIC;
reset : in STD_LOGIC;
triangle : out STD_LOGIC_VECTOR(9 downto 0) -- Output: -511 to 511
);
end triangle_wave_gen;
architecture Behavioral of triangle_wave_gen is
signal ramp_counter : unsigned(9 downto 0) := (others => '0'); -- 10-bit counter for 1024 steps
signal triangle_val : integer range -511 to 511;
begin
process(clk)
begin
if rising_edge(clk) then
if reset = '1' then
ramp_counter <= (others => '0');
else
-- Ramp with wrap-around (modulo 1024)
if ramp_counter = 1023 then
ramp_counter <= (others => '0');
else
ramp_counter <= ramp_counter + 1;
end if;
end if;
end if;
end process;
-- Triangle generation and scaling
process(ramp_counter)
variable temp : integer;
begin
-- Create triangle wave from ramp
if ramp_counter < 512 then
temp := to_integer(ramp_counter); -- 0 to 511
else
temp := 1023 - to_integer(ramp_counter); -- 511 down to 0
end if;
-- Scale to -511 to +511
triangle_val <= 2 * temp - 511;
-- Output conversion to std_logic_vector
triangle <= std_logic_vector(to_signed(triangle_val, 10));
end process;
end Behavioral;