Forum Discussion

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

.mif file generation of perticular freuency

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...

26 Replies

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

    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..
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    hey Kaz..

    do u have workable matlab code to generate a tone of perticular frequency mif file....if u have plz send me...
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.

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

    --- 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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.