Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20704 Discussions

the quarter sine LUT code

Altera_Forum
Honored Contributor II
1,463 Views

Dear all 

I need to get the quarter sine LUT in DDFS (Herewith the MATLAB code that I used) 

 

i=[0:i-1]; 

x= (i-1)*sin ((pi/2)*i/31));
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
455 Views

 

--- Quote Start ---  

 

I need to get the quarter sine LUT 

--- Quote End ---  

 

Hope you got it :) 

What exactly the question is?
0 Kudos
Altera_Forum
Honored Contributor II
455 Views

According to this equation : 

i=[0:i-1]; 

x= (i-1)*sin ((pi/2)*i/i-1)+ 1/2*(i-1)); 

The result that I got is not the sine wave shape (the LUT values inverted in minus when it pass the half of (pi/2) range ). herewith the attached sine wave file
0 Kudos
Altera_Forum
Honored Contributor II
455 Views

As far as i know MATLAB uses floating point representation, which is not implemented in HDL by default. Maybe if you give more information (LUT input,output width, precision, what language you use) I could help you out.

0 Kudos
Altera_Forum
Honored Contributor II
455 Views

The Quarter sine wave LUT code for 8 bits: 

i=[0:255]; 

x= 255*sin ((pi/2) *i /255); 

y=str(x,8) ; 

but when i used it in DDS simulation , I got no sine wave((note: i applied all the other requirment))
0 Kudos
Altera_Forum
Honored Contributor II
455 Views

There is some error in your sine values but almost correct. 

Try this: 

 

x = round(255*sin(2*pi*(0:1023)/1024)); 

x = x(1:256); 

 

You should get proper quarter sine from x otherwise tell us what you do with x. 

 

you can also just use: 

x = round(255*sin(2*pi*(0:255)/1024));
0 Kudos
Reply