Forum Discussion
Altera_Forum
Honored Contributor
8 years agoAdjustable frequency generator
Hi, I am trying to implement adjustable rectangular wave generator in MAX10. The code below: library ieee;use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity DIVIDER_2 is
p...
Altera_Forum
Honored Contributor
8 years agoYou can just implement it in the same way as a DDS. For example, you could have a 32-bit unsigned phase accumulator and 32-bit unsigned tuneword. Choose the tuneword to get the frequency you want and just increment the phase accumulator by it each clock cycle. By using an unsigned, it will automatically wrap around.
For a normal DDS, you would use the upper few bits as an index into a sin wave table. In your case, the upper bit is your square wave. The tuneword is just F * 2**32 / Fclk