15.3. Understanding Memory Widths

The hex conversion utility makes your memory architecture more flexible by allowing you to specify memory and ROM widths. To use the hex conversion utility, you must understand how the utility treats word widths. Three widths are important in the conversion process:

  • Target width

  • Memory width

  • ROM width

The terms target word, memory word, and ROM word refer to a word of such a width.

The following figure illustrates the separate and distinct phases of the hex conversion utility’s process flow.

Figure: Hex Conversion Utility Process Flow

../../_images/hexprocflow_pnu118.png

15.3.1. Target Width

Target width is the unit size (in bits) of the target processor’s word. The width is fixed for each target and cannot be changed. The Arm targets have a width of 32 bits.

15.3.2. Specifying the Memory Width

Memory width is the physical width (in bits) of the memory system. Usually, the memory system is physically the same width as the target processor width: a 16-bit processor has a 32-bit memory architecture. However, some applications require target words to be broken into multiple, consecutive, and narrower memory words.

By default, the hex conversion utility sets memory width to the target width (in this case, 32 bits).

You can change the memory width (except for TI-TXT, binary, and TI-Tagged formats) by:

  • Using the --memwidth option. This changes the memory width value for the entire file.

  • Setting the memwidth parameter of the ROMS directive. This changes the memory width value for the address range specified in the ROMS directive and overrides the --memwidth option for that range. See The ROMS Directive.

For both methods, use a value that is a power of 2 greater than or equal to 8.

You should change the memory width default value of 16 only when you need to break single target words into consecutive, narrower memory words.

Note

Binary Format is 8 Bits Wide You cannot change the memory width of the Binary format. The Binary hex format supports an 8-bit memory width only. See TI-TXT Hex Format (--ti_txt Option) for more about using the ROMS directive with an 8-bit format.

Note

TI-TXT Format is 8 Bits Wide You cannot change the memory width of the TI-TXT format. The TI-TXT hex format supports an 8-bit memory width only. See TI-TXT Hex Format (--ti_txt Option) for more about using the ROMS directive with the TI-TXT hex format.

The following figure shows how memory width is related to object file data.

Figure: Object File Data and Memory Widths

../../_images/datamemwidth_pnu118.png

15.3.3. Partitioning Data Into Output Files

ROM width determines how the hex conversion utility partitions the data into output files. ROM width specifies the physical width (in bits) of each ROM device and corresponding output file (usually one byte or eight bits). After the object file data is mapped to the memory words, the memory words are broken into one or more output files. The number of output files is determined by the following formulas:

  • If memory width ≥ ROM width:

number of files = memory width ÷ ROM width

  • If memory width < ROM width:

number of files = 1

For example, for a memory width of 32, you could specify a ROM width value of 32 and get a single output file containing 32-bit words. Or you can use a ROM width value of 16 to get two files, each containing 16 bits of each word.

The default ROM width that the hex conversion utility uses depends on the output format:

  • All hex formats except TI-Tagged are configured as lists of 8-bit bytes; the default ROM width for these formats is 8 bits.

  • TI-Tagged is a 16-bit format; the default ROM width for TI-Tagged is 16 bits.

Note

The TI-Tagged Format is 16 Bits Wide You cannot change the ROM width of the TI-Tagged format. The TI-Tagged format supports a 16-bit ROM width only.

Note

TI-TXT Format is 8 Bits Wide You cannot change the ROM width of the TI-TXT format. The TI-TXT hex format supports only an 8-bit ROM width. See TI-TXT Hex Format (--ti_txt Option) for more about using the ROMS directive with the TI-TXT hex format.

You can change ROM width (except for TI-Tagged and TI-TXT formats) by:

  • Using the --romwidth option. This option changes the ROM width value for the entire object file.

  • Setting the romwidth parameter of the ROMS directive. This parameter changes the ROM width value for a specific ROM address range and overrides the --romwidth option for that range. See The ROMS Directive.

For both methods, use a value that is a power of 2 greater than or equal to 8.

If you select a ROM width that is wider than the natural size of the output format, the utility simply writes multibyte fields into the file. The --romwidth option is ignored for the TI-TXT and TI-Tagged formats.

Memory width and ROM width are used only for grouping the object file data; they do not represent values. Thus, the byte ordering of the object file data is maintained throughout the conversion process. To refer to the partitions within a memory word, the bits of the memory word are always numbered from right to left as follows:

../../_images/memwidth_tdz079.png

The following figure shows how the object file data, memory, and ROM widths are related to one another.

Figure: Data, Memory, and ROM Widths

../../_images/datamemrom_pnu118.png