Forum Discussion
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