Main Content

Apply RAM Mapping to Optimize Area

RAM mapping is an area optimization that maps storage and delay elements in your Simulink® model or MATLAB® code to random access memory (RAM) rather than to individual registers on hardware. RAM mapping can reduce the amount of area that your design uses in the target hardware by reducing the number of registers that elements consume and store those elements in RAM blocks.

RAM Mapping for a Simulink Model

You can map these Simulink model elements to RAM:

  • Delay blocks. To map delays to RAM, set the HDL block property UseRAM. For guidelines, see Map Large Delays to Block RAM.

  • Persistent variables in MATLAB Function blocks. To map persistent arrays in a MATLAB Function block to RAM, use the pragma coder.hdl.ramconfig or set the HDL block property MapPersistentVarsToRAM. For an example, see RAM Mapping with the MATLAB Function Block.

  • Lookup tables. To map lookup tables to RAM, set the HDL block property MapToRAM.

  • Simulink RAM blocks. To map the RAM blocks in the Simulink model to the RAM blocks on the target FPGA, set the HDL block property RAMDirective. For more information, see RAMDirective.

  • RAM blocks from the HDL Operations library:

    • Single Port RAM

    • Single Port RAM System

    • Dual Port RAM

    • Dual Port RAM System

    • Simple Dual Port RAM

    • Simple Dual Port RAM System

    • Dual Rate Dual Port RAM

    • Simple Tri Port RAM System

    • True Dual Port RAM System

  • Blocks with a RAM implementation.

Specify RAM Mapping for a Simulink Model

To specify RAM mapping for persistent arrays in a MATLAB Function block or Delay blocks:

  1. Set the associated RAM mapping property for the elements that you want to map to RAM. For example, to map a Delay block to RAM, set the UseRAM HDL block property to on. To map persistent arrays, set the MATLAB Function block HDL block property MapPersistentVarsToRAM to on or use the pragma coder.hdl.ramconfig in your MATLAB Function block after defining the persistent variables.

  2. Specify a minimum RAM mapping threshold by using the RAM mapping threshold configuration parameter. See Map pipeline delays to RAM and RAM mapping threshold.

RAM Mapping for a MATLAB Design

You can map these MATLAB code elements to RAM:

  • Persistent array variables

  • Pipeline registers in the generated HDL code

  • dsp.Delay System object™

  • hdl.Delay System object

  • hdl.RAM System object

Specify RAM Mapping for a MATLAB Design

To specify RAM mapping for delays or persistent arrays in a MATLAB function, in the Optimizations section of the HDL Code Generation tab of the MATLAB HDL Workflow Advisor:

  1. Set the associated RAM mapping property for the elements that you want to map to RAM. For example, to map persistent arrays, select the Map persistent array variables to RAMs option. For more information, see Map Persistent Arrays and dsp.Delay Objects to RAM. To map pipelines delays to RAM, select the Map pipeline delays to RAM option.

  2. Specify a value for the RAM mapping threshold option. For more information, see RAMThreshold.

For an example, see Map Matrices to Block RAMs to Reduce Area.

You can also map persistent array variables to RAM by using the pragma coder.hdl.ramconfig in your MATLAB code after you define and assign persistent variables in the code. coder.hdl.ramconfig allows you to select persistent variables to map to RAM and to map persistent variables to a specific RAM architecture, such as a simple tri port RAM. For more information, see coder.hdl.ramconfig.

Settings that Affect RAM Mapping

For an explanation of the settings that affect how HDL Coder™ maps design elements to RAM, see Manage How HDL Coder Maps RAM.

See Also

Model Settings

Topics