Creating .hex files for memory initialization.

    Memory functions that require an initial value can have the initial contents declared in either a Intel .hex file or an Altera .mif file.  If you are using non-Altera tools for HDL analysis/simulation you have no choice but to use .hex files.  If you are doing all of your development through Altera then a .mif file is possible.  You can obtain a .hex file from a .mif file within Altera if you activate the simulator and use the Initialize >> Memory tools.

    An Intel Hexadecimal File (.hex) is often downloaded from a PC to a development system and run from RAM. Hex Files can also be converted to binary files and programmed into a configuration device. A sample Hex File is shown below:

    :10008000AF5F67F0602703E0322CFA92007780C361
    :1000900089001C6B7EA7CA9200FE10D2AA00477D81
    :0B00A00080FA92006F3600C3A00076CB
    :00000001FF

The format for this file is:

    First character (:) = Start of a record
    Next two characters = Record length (in this example, 10h)
    Next four characters = Load address (in this example, 0080h)
    Next two characters = Record type (see below)
    Remaining characters = Actual data
    Last two characters = Checksum (i.e., sum of all bytes + checksum = 00)

The last line of the file is special, and always looks like the last line shown above.
Hex File record types are shown below:

    00 = Data record
    01 = End of file record
    02 = Extended segment address record
    03 = Start segment address record
    04 = Extended linear address record
    05 = Start linear address record