The DATA_MEM_BANK pragma aligns a symbol or variable to a specified internal data memory bank boundary. The constant specifies a specific memory bank to start your variables on. C7000 devices contain 16 64-bit memory banks. The value of constant can be 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, or 15.
The syntax of the pragma in C is:
#pragma DATA_MEM_BANK (symbol, constant) |
The syntax of the pragma in C++ is:
#pragma DATA_MEM_BANK (constant) |
Only global variables can be aligned with the DATA_MEM_BANK pragma.
The DATA_MEM_BANK pragma allows you to align data on any data memory bank that can hold data of the type size of the symbol. This is useful if you need to align data in a particular way to avoid memory bank conflicts.
This pragma increases the amount of space used in data memory by a small amount as padding is used to align data onto the correct bank.
A value of 'n' for the constant argument to the DATA_MEM_BANK pragma causes the last seven bits of the starting address to be a value equal to 'n*8'. For example, for a value of 1, the last seven bits of the starting address will be 0x08. For a value of 14, the last seven bits of the starting address will be 0x70.
The code in Example 6 uses the DATA_MEM_BANK pragma to specify the alignment of the x, y, z, w, and zz arrays. It then assigns values to all the array elements and prints the starting address of each array.