hello guys, I am working on a project which requires sine wave frequencies from MATLAB/SIMULINK using the system generator to be implemented into VHDL as a LUT. I want to use the DDS Compiler to generate the sine waves but am not sure how to put in a LUT for the values. It is an 12-bit output sine wave which is outputted to a DAC, I use a Spartan3E FPGA.
Any help is greatly appreciated, and if you need more info just ask.
hello guys, I am working on a project which requires sine wave frequencies from MATLAB/SIMULINK using the system generator to be implemented into VHDL as a LUT. I want to use the DDS Compiler to generate the sine waves but am not sure how to put in a LUT for the values. It is an 12-bit output sine wave which is outputted to a DAC, I use a Spartan3E FPGA.
Any help is greatly appreciated, and if you need more info just ask.
First point is to understand how much memory you will need for the application.Since your output word is going to be 12 bits long, you require a maximum of 12x2^12(48 Kbits) bits of memory.If you are going to use the symmetric nature of sine wave then it can be brought down to 48/4=12Kbits. Since this much is large for a distributed type of memory, choose a block ram to store the data.
How to generate the data values?
Use MATLAB
n=[0:2^12-1];
x=sin(2*pi*n/(2^12)); % x ranges from +1 to -1; This is the sine wave representing the minimum frequency wave for a particular sampling frequency that encloses almost all the levels in a 12 bit number.
Since DAC requires offset binary with values ranging from 0 to 4095, introduce a DC shift.
i.e x=x+1;
x=x*2048;
x=round(x);
convert the values to binary using dec2bin with 12 bit as length.
export it to a .COE file and use as the init file for block ram to be used in the design.
Thanks a lot vishak for your reply I typed what you gave me in matlan command window but i am a bit conviused, when i type all the equations how can i convert to bin and I am using Xilinx Rom block how can i use the file init. I am sorry if my questions seems stupid but i am really new to this field.
dec2bin is the command. The output will be in char. when i said init file , i meant the initialization vector for the ROM module.
you can search the xilinx website for the syntax for COE file for ROM initialization. When you instantiate ROM in your design, use the COE file containing the binary converted values as your init vector.