MCS File Format for Xilinx FPGA

The MCS file (Memory Configuration File) is a file format used for memory programming. The essence of an MCS file is a HEX file, which follows the Intel-HEX encoding rules and can be opened directly with text editing tools. MCS files contain data corresponding to each address and ensure data integrity and accuracy through checksums.Xilinx’s MCS files do not include header information such as FPGA model and timestamp found in bit files.

Structure of MCS Files

:BBAAAARR…DDCC

1. Start Character (:): Indicates the start of each record.

2. Byte Count (BB): A 2-digit hexadecimal number (1 byte) that indicates the number of bytes in the DD data field of that record. For example, 10 indicates there are 16 data bytes.

3. Address (AAAA): A 4-digit hexadecimal number (2 bytes) that indicates the starting address of the data in that record. This address is relative to the current address offset. For address spaces exceeding 64KB, extended address records are needed.

4. Record Type (RR): A 2-digit hexadecimal number that indicates the type of record:

00: Data record line

01: End of file line

04: Extended linear address record, used to specify the high 16 bits of the address in the AAAA field of the data record, to support addressing spaces exceeding 64KB (0xFFFF). This record appears when high addresses need to be set.

5. Data (…DD): Consists of a number of hexadecimal bytes specified by BB, representing the actual configuration data or information related to the record type (e.g., the high address contained in the 04 type record). For 00 type records, this is a segment of FPGA configuration data.

6. Checksum (CC): A 2-digit hexadecimal number used to verify the integrity of that record. It is the two’s complement of the sum of all bytes from BB to the last DD byte in that record (converted to an integer) modulo 256 (i.e., taking the low 8 bits) (i.e., 0x100 – (sum % 0x100)). Alternatively, after retaining the low byte, it can be inverted and incremented by 1.

Three Types of Record Lines are formatted as follows:

1. Data Record Line: : + Byte Count + Address + 00 + Data Content + Checksum

2. End of File Line: : + 00 + 0000 + 01 + Checksum

3. Offset Address Line: : + 02 + 0000 + 04 + Address Offset + Checksum

When configuration data needs to be written to external Flash at addresses exceeding 0xFFFF (64KB), the high address must be set. An 04 record appears, with its data field (DD) containing 2 bytes (4 hexadecimal characters), for example, 0000. This indicates that the high 16 bits of the address in subsequent 00 type records are 0x0000, meaning the complete 32-bit linear address is: (0x0000 << 16) + 0xAAAA = 0xAAAA. This high address remains valid until the next 04 record changes it.

Example Parsing

:020000040000FA

:10000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00

:10001000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0

:10002000000000BB11220044FFFFFFFFFFFFFFFFA6

:10003000AA995566200000003003E0010000026B21

:10004000300080010000001220000000300220017A

:10FFC0000000000000000000000000000000000031

:10FFD0000000000000000000000000000000000021

:10FFE0000000000000000000000000000000000011

:10FFF0000000000000000000000000000000000001

:02000004000AF0

:1000000000000000000000000000000000000000F0

:1000100000000000000000000000000000000000E0

:1000200000000000000000000000000000000000D0

:1000300000000000000000000000000000000000C0

:1072500020000000200000002000000020000000AE

:10726000200000002000000020000000200000009E

:10727000200000002000000020000000200000008E

:0C728000200000002000000020000000A2

:00000001FF

Leave a Comment