Main Content

Map Persistent Arrays to RAM

To map the persistent variables to RAMs in the generated SystemC code use the RAM Mapping optimization. Without this optimization, the variables are mapped to registers. RAM mapping is an area optimization. It reduces the area of your design in the target hardware.

Enable RAM Mapping

  1. In the HDL Workflow Advisor, select MATLAB to SystemC Workflow > SystemC Code Generation > Optimizations tab.

  2. Select the Map persistent array variables to RAMs option.

  3. Set the RAM mapping threshold to the size (in bits) of the smallest persistent array that you want to map to RAM.

RAM Mapping Requirements for Persistent Arrays

This table lists a summary of the RAM mapping behavior for persistent arrays.

Map Persistent Array Variables to RAMs SettingMapping Behavior


Map to RAM in the generated SystemC code.


Map to registers in the generated SystemC code.

Additional Notes

  • The large persistent arrays whose size in bits is greater than or equal to RAM mapping threshold are mapped to RAM. The size in bits is calculated as NumElements * WordLength.

    • NumElements is the number of elements in the array.

    • WordLength is the number of bits that represent the data type of the array.

  • The list of RAM variables is populated inside the ml.tcl metadata file generated during SystemC Code Generation. This metadata file is read by the Stratus HLS tool during project creation and maps these variables to RAM.

  • If Initialize Block RAM option is turned off, the RAM variables that have a zero initial value are not initialized inside initialize_ram_vars() method.

  • If the initial value of the variables is nonzero, then those RAM variables are initialized inside the initialize_ram_vars() method, irrespective of the Initialize Block RAM option value.

Related Topics