Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to create a sine wave using lut in verilog?

Status
Not open for further replies.

keerthna

Member level 1
Member level 1
Joined
Sep 16, 2014
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
251
I want to use the lut approach to create a sine wave. but i dont know what exactly to have in that lut. can anyone please explain in detail. thanks in advance
 

Hi Keerthna,

I didnt understand your requirement.
Are you looking to create Sine Wave in FPGA using some HDL or you want to create a sine wave with LUT approach in a spread sheet ?

If you are looking to design using HDL then you can design a ROM and store values ( no. of values are the samples you want to have in 1 full cycle ) . FPGA will implement it with LUTs automatically.
 

google "fpga sine lut". Sorry for the google it answers, buuuut it seems you are a tad google deficient, and I am really not going to type 439873458967 chars for things that are totally easy to find. Read the results for previous google first, and then we can answer your follow up questions. ;)
 

I DID GOOGLE BUT COULDNT GET A CLEAR PICTURE OF IT. HOW DO I STORE THE VALUES? what values are stored in the lut?
 

You'll generate a table of sine values, either by an external tool (Matlab, Excel) or calculated it in HDL. Depending on your wave generation algorithm, a quarter or half sine cycle is sufficient to generate the sine waveform.
 

Using excel I can generate the table of values. But my problem is how many values should i store and what should be the difference between those values? I mean sin(0) , sin(10) like this how many and what values should i store ideally?
 

I DID GOOGLE BUT COULDNT GET A CLEAR PICTURE OF IT. HOW DO I STORE THE VALUES? what values are stored in the lut?

Really? What links did you look at?

The very first hit I get for example is this: https://www.fpga4fun.com/DDS2.html

Which explains the "store half of sine wave" part as FvM mentioned, and much more. But oh well, guess reading happens to other people. Good luck!
 

Using excel I can generate the table of values. But my problem is how many values should i store and what should be the difference between those values? I mean sin(0) , sin(10) like this how many and what values should i store ideally?
Ideally an infinite number of points...

Seriouslys speaking, the answer depends on several points.

1. It's presumed that you are using linear interpolation between table points. https://en.wikipedia.org/wiki/Linear_interpolation
2. Your design has a limited magnitude resolution (e.g. PWM or DAC word width) It's not reasonable to generate the sine much more accurate than it can be output.
3. Your application has certain accuracy requirements, e.g. acceptable voltage distortion of a sine inverter
4. You'll determine a maximum error for the generated sine wave, e.g. 8 or 10 bit accuracy. Then find out how many table points are required to come below this error limit with the interpolated sine waveform.
 

So if i have to generate a 50hz sine wave and my system clock frequency is 33Mhz and i take n=16, then according to fout=(M*fc)/2^n
i get M=0.0992 so the lut will have values starting from sin(0.099) , sin(0.198) this way? till sin (90) ??
 

Or you could just plug in the numbers you are dealing with here and get your table values.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top