Forum Discussion

efe373's avatar
efe373
Icon for New Contributor rankNew Contributor
4 years ago
Solved

MIF file

Hello,

I want to initialize my RAM using .mif file. I want to store 2 different width of data in the memory, one is 16-bit and the other is 18-bit. Therefore, I have decided to use 18-bit wide RAM. However, when I try to fill the .mif file I got confused. I want to write the initialization data in HEX format, addressing in DEC format. For example, if I want to have 0x0ABC as 16-bit data in the address 10d, what should I write?

10 : 00ABC;

Is this right?

Also if I want to have 11_1010_1011_1100_1101b (18-bit) in the address 15d, what should I write?

15 : FABCD;

Is this also right? If not, can you guide me a little?

Thanks.

  • Hi Yitim,


    In a Memory Initialization File, you must specify the memory depth and width values. In addition, you can specify data radixes as binary (BIN), hexadecimal (HEX), octal (OCT), signed decimal (DEC), or unsigned decimal (UNS) to display and interpret addresses and data values. Data values must match the specified data radix.


    The format is like this:


    DEPTH = 32; -- The size of memory in words

    WIDTH = 8; -- The size of data in bits

    ADDRESS_RADIX = HEX; -- The radix for address values

    DATA_RADIX = BIN; -- The radix for data values

    CONTENT -- start of (address : data pairs)

    BEGIN


    00 : 00000000; -- memory address : data

    01 : 00000001;

    02 : 00000010;

    03 : 00000011;

    04 : 00000100;

    05 : 00000101;


    END;


    You can easily use memory editor to create a mif file in file--> new --> memory file --> select your option.


3 Replies

  • SyafieqS's avatar
    SyafieqS
    Icon for Super Contributor rankSuper Contributor

    Hi Yitim,


    In a Memory Initialization File, you must specify the memory depth and width values. In addition, you can specify data radixes as binary (BIN), hexadecimal (HEX), octal (OCT), signed decimal (DEC), or unsigned decimal (UNS) to display and interpret addresses and data values. Data values must match the specified data radix.


    The format is like this:


    DEPTH = 32; -- The size of memory in words

    WIDTH = 8; -- The size of data in bits

    ADDRESS_RADIX = HEX; -- The radix for address values

    DATA_RADIX = BIN; -- The radix for data values

    CONTENT -- start of (address : data pairs)

    BEGIN


    00 : 00000000; -- memory address : data

    01 : 00000001;

    02 : 00000010;

    03 : 00000011;

    04 : 00000100;

    05 : 00000101;


    END;


    You can easily use memory editor to create a mif file in file--> new --> memory file --> select your option.


    • efe373's avatar
      efe373
      Icon for New Contributor rankNew Contributor

      Hi,

      Because you said 'Data values must match the specified data radix.', I wrote everything in binary, not hexadecimal. So, there is no problem. However, I wish Quartus do bit reduction when I specify 18-bit word length and write 0x3FFFF. Thanks.