FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
6665 Discussions

.mif file generation of perticular freuency

Altera_Forum
Honored Contributor II
4,177 Views

hi, 

i am facing a problem to generate a .mif file of perticular frecuency for initializing the ROM in my tone generation project...can anybody help me regarding this...
0 Kudos
26 Replies
Altera_Forum
Honored Contributor II
217 Views

hi ..... 

so Kaz...what i have to use...cordic, small rom , large rom or multiplier based.... 

and in implementation what i hav to select,,,frequency modulation or phase modulation ....i tried each and every one.....some combination generates the mif file but in mif file data is not there.....plz help me in details..
0 Kudos
Altera_Forum
Honored Contributor II
217 Views

Hi, 

 

The choice is yours depending on your resource, I normally choose small memory. 

 

As to modulation you don't want any, you just want a sinusoid. 

 

As to mif not having data at all, this is bizarre but may be because of the way you are opening the file to read. there might be two files per sine/cosine e.g. F and C for fine and coarse. Try simulate the design before your verdict. 

 

kaz
0 Kudos
Altera_Forum
Honored Contributor II
217 Views

hey Kaz.. 

do u have workable matlab code to generate a tone of perticular frequency mif file....if u have plz send me...
0 Kudos
Altera_Forum
Honored Contributor II
217 Views

VHDL, by the way, has the option of generating sine tables according to your needs from pure HDL code, as shown in previous forum discussions.

0 Kudos
Altera_Forum
Honored Contributor II
217 Views

 

--- Quote Start ---  

Hi, 

 

The frequency depends on your Fs i.e. f = Fs/Number of points per cycle. 

 

To generate one sinusoid cycle of n points in Matlab and quantising onto 16 bits signed: 

data = sin(2*pi*[0:n-1]/n); 

data = round(data* (2^15-1)/max(data)); 

 

you can then display data as a column, copy and paste to a mif file(This is quicker than writing mif text) 

 

Kaz 

--- Quote End ---  

 

Hi, 

kaz... 

in ur matlab code....if we have to quantising onto 8 bit than what i have to change in it..and where i have to put the frequency...actually u r not using it... 

plz reply me soon
0 Kudos
Altera_Forum
Honored Contributor II
217 Views

Hi, 

 

for 8 bits you can generate one cycle sinusoid as follows: 

First: what is your Fs(sampling freq or effective clk)? assume it is 50MHz 

what is your tone freq? assume it is 2MHz 

 

Second: decide number of sinusoid points for one cycle: 50/2 = 25 

 

data = sin(2*pi*[0:24]/25); 

 

quantise onto 8 bits: 

data = round(data* (2^7-1)/max(data)); //signed 

 

When you store this data as LUT and read it out on your clk, it should generate a tone at 2Mhz. 

 

If your DAC uses offset binary as opposed to 2's complemnt then invert the sign bit for the DAC. 

 

However, I am a bit disappointed, I thought your tones are ready by now except for that wait for the orchestra director... 

 

If it turns out that your LUT is very large because your tone is very low then you can use a slightly different approach using a modulo adder.
0 Kudos
Reply