Hexadecimal (Intel-Format) File (.hex) Definition

An ASCII text file (with the extension .hex). You can use a Hexadecimal (Intel-Format) File (.hex) in the Intel® Quartus® Prime software to store the initial memory values for a memory block, such as RAM or ROM, that is implemented in an FPGA device, or to build software project executables.

You can use .hex files as input files in the Intel® Quartus® Prime software in the following ways:

  • The Memory Editor can create a .hex file for memory initialization in the Compiler and Simulator. You can also use a Memory Initialization File (.mif) to provide memory initialization data.
  • The In-System Memory Content Editor can use and create a .hex file to import and export data.
Note: The Intel® Quartus® Prime version of the .hex file differs from the standard Intel-Format .hex file in the following ways:
  • The Intel® Quartus® Prime version of the .hex file uses line feed (LF) line endings, whereas Intel-Format .hex supports carraige return (CR) or LF line endings.
  • The Intel® Quartus® Prime version of the .hex file is dependent on the width of the target memory, whereas Intel-Format .hex does not depend on the width of the target memory.
The format of each line in a .hexfile is as follows::AABBBBCCDD"¦DDEE

Code

Definition

AA

the number of bytes in the data field (DD"¦DD)

BBBB

starting address

CC

type (00 = data, 01 = end of file, 02 = address offset)

DD..DD

data field

EE

checksum value

Important: Use the Intel® Quartus® Prime Memory Editor to create .hex files for use in the Intel® Quartus® Prime software.

You can store configuration data for one or more Intel devices in an output file called a Hexadecimal (Intel-Format) Output File (.hexout). The .hexout file format is an ASCII text file with the extension .hexout to avoid overwriting initial memory content files that have the extension .hex.

The data width of a .hex file is always a multiple of 8 bits. When you initialize a memory block that is not the same width as the .hex file, the Intel® Quartus® Prime software wraps or pads the file as described in the table below:

File data width greater than memory width

File data width smaller than memory width

Memory size is a multiple of 8:

  • When the .hex file data width is a multiple of the memory width, the Intel® Quartus® Prime software wraps the data to subsequent addresses.
  • When the .hex file data width is not a multiple of the memory width, the Intel® Quartus® Prime software pads the data to a multiple of the memory width just greater than the .hex file data width. For example, with a memory width of 24 (Address: 040000002A124FFF72) and a .hex file data width of 32 (Address: 00000001FF), the Intel® Quartus® Prime software pads the 32 bit .hex file data width to 48 bits (the multiple of 24 just greater than 32), and then wraps the 48 bits around the 24 bit memory width, resulting in: Address: 00002A Address: 124FFF

Memory size is not a multiple of 8:

The Intel® Quartus® Prime software wraps the data to the memory width equal to the multiple of 8 and just greater than the actual memory width, and then truncates the memory block to the actual size of the memory width, which is not a multiple of 8.

  • RAM / ROM— The Intel® Quartus® Prime software pads the memory block with zeroes next to the MSB (most significant bit).
  • MAX® II User Flash Memory (UFM)— The Intel® Quartus® Prime software pads the memory block with ones next to the LSB (least significant bit).

If the size of the .hex file does not match the size of the memory you are initializing, the Intel® Quartus® Prime software performs as described in the table below:

File data depth greater than memory depth

File data depth smaller than memory depth

Ignores extra data.

  • RAM / ROM— The Intel® Quartus® Prime software initializes the addresses with no data to zero.
  • MAX® II User Flash Memory (UFM)— The Intel® Quartus® Prime software initializes the addresses with no data to the hexadecimal value of <F...F>.
Note: File data depth refers to the number of addresses that you are initializing. The Intel® Quartus® Prime software fills addresses that you are not initializing with zeros or <F...F>, depending on whether the file data depth is UFM or not.
Note:

In the Intel® Quartus® Prime software, you have the option of reading or writing .hex files in the byte addressable (Intel hexadecimal format) mode, or the word-addressable mode. You can choose between the two modes by changing the Read or write Hexadecimal Files (.hex) using byte addressing (Intel format) option in the Intel® Quartus® Prime software. Set this option in the Memory Editor page in the Options dialog box. Turning on this option for the current project overrides the global setting.

The Intel® Quartus® Prime software always reads word addressable .hex files in the word addressable mode even if you turn on Read or write Hexadecimal Files (.hex) using byte addressing (Intel format).