Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
10 years ago

How to create sine and cos waves of different frequencies using Cyclone III(VHDL)

Hi,

Is there anyone can help me to deal with one problem: How to create sine or cos waves in Cyclone III FPGA in VHDL. I have no clear idea to program the VHDL code although I have search some documents.

I will be much appreciate if someone can help me out.

Thank you very much.

Best wishes,

peipei

9 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    If you have no VHDL knowledge, my first suggestion would be to find a good tutorial and get yourself familiar with the language.

    As for the sin waves, sine and cosine are identical, but with a phase shift. It would be easy enough to build a ROM of sin values in VHDL and just read them out.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    There are many methods that can be used, A simple lookup table is the easiest, then just step through the lookup table at different rates.

    If you truly want to generate Sin and Cos values, a CORDIC algorithm is the way to go.

    Pete
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    If it was me I will use the altera ip away from manual hdl coding. I think cordic is too much for a beginner to hand code or understand.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    If it was me I will use the altera ip away from manual hdl coding. I think cordic is too much for a beginner to hand code or understand.

    --- Quote End ---

    Does altera provide cordic IP for user now?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Tricky,

    I have learnt VHDL and I suppose I have some knowledge of this language.

    But just for this application, I have not clear idea to achieve this.

    In my mind, I want to use Look up table, due to the ADA board is 14 bits, and I have generated the different values in Excel for one cycle, I am not sure should I generate all 2^14 values or not.

    Thanks for your reply.

    Best wishes,

    peipei

    --- Quote Start ---

    If you have no VHDL knowledge, my first suggestion would be to find a good tutorial and get yourself familiar with the language.

    As for the sin waves, sine and cosine are identical, but with a phase shift. It would be easy enough to build a ROM of sin values in VHDL and just read them out.

    --- Quote End ---

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Jerry,

    I am planning to use LUT.

    Do you have specific suggestions? My ADA board is 14 bits.

    Thanks,

    Best wishes,

    peipei

    --- Quote Start ---

    Does altera provide cordic IP for user now?

    --- Quote End ---

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Remember Sin and cosine are reflective, so you only need 2^13 values in the rom, you use the 14th bit as the sign bit.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    CORDIC is suitable for generating the sin/cos of an angle.

    You can generate sin(a + delta) from sin(a - delta) and sin(a) with a single multiply (and a shift).

    The only slight problen is that the amplitude can drift.