Main Content

coder.hdl.ramconfig

Specify RAM mapping configuration for persistent array variables

Since R2023b

    Description

    coder.hdl.ramconfig(p) sets the default RAM mapping configuration for the persistent array p to a simple dual-port RAM. HDL Coder™ maps the persistent array to the specified RAM during HDL code generation. p is not required to meet the RAM mapping threshold to be mapped to RAM.

    coder.hdl.ramconfig(p,Name=Value) sets the RAM mapping configuration for the persistent variable p to a single, simple dual, dual, or simple tri-port RAM with properties set using one or more name-value pairs.

    example

    coder.hdl.ramconfig({p1,...,pN},Name=Value) sets the RAM mapping configuration for the persistent variables p1 through pN to a single, simple dual, dual, or simple tri-port RAM with properties set using one or more name-value pairs.

    example

    coder.hdl.ramconfig(Name=Value) sets the RAM mapping configuration for all persistent variables that meet the RAM mapping threshold to a single, simple dual, dual, or simple tri-port RAM with properties set using one or more name-value pairs.

    example

    coder.hdl.ramconfig(p,'none') disables RAM mapping for the persistent variable p, even if p meets the RAM mapping threshold.

    example

    Examples

    collapse all

    Set the default RAM mapping configuration for persistent variables above the RAM mapping threshold as a simple tri-port RAM and enable asynchronous read.

    ...
    persistent A B;
    if isempty(A)
      A = int16(zeros(1,32));
      B = int16(zeros(1,32));
    end
    coder.hdl.ramconfig(RAMType="Simple Tri Port", AsyncRead=true);

    HDL Coder maps the persistent variables that are above the RAM mapping threshold to the specified RAM configuration during HDL code generation, even if the MATLAB Function block HDL block property MapPersistentVarsToRAM is set to off. For more information on RAM mapping threshold, see RAM mapping threshold.

    Set the RAM mapping configuration as a dual port RAM for persistent variable A.

    ...
    persistent A B;
    if isempty(A)
      A = int16(zeros(1,32));
      B = int16(zeros(1,32));
    end
    coder.hdl.ramconfig(A,RAMType="Dual Port")

    HDL Coder maps A to RAM during HDL code generation, even if it does not meet the RAM mapping threshold or the MATLAB Function block HDL block property MapPersistentVarsToRAM is set to off.

    Set the RAM mapping configuration as a dual port RAM for the persistent variables A and B.

    ...
    persistent A B C;
    if isempty(A)
      A = int16(zeros(1,32));
      B = int16(zeros(1,32));
      C = int16(zeros(1,32));
    end
    coder.hdl.ramconfig({A,B},RAMType="Dual Port")

    HDL Coder maps A and B to RAM during HDL code generation, even if they do not meet the RAM mapping threshold or the MATLAB Function block HDL block property MapPersistentVarsToRAM is set to off.

    Disable RAM mapping for the persistent variable A.

    ...
    persistent A B;
    if isempty(A)
      A = int16(zeros(1,32));
      B = int16(zeros(1,32));
    end
    coder.hdl.ramconfig(A,'none')

    HDL Coder does not map A to RAM, even if it meets the RAM mapping threshold and the MATLAB Function block HDL block property MapPersistentVarsToRAM is set to on.

    Input Arguments

    collapse all

    Persistent array variable to map to the specified RAM configuration, specified as a persistent array. You must define the persistent variable in the code before using the coder.hdl.ramconfig pragma.

    Persistent array variables to map to the specified RAM configuration, specified as a persistent array. You must define the persistent variables in the code before using the coder.hdl.ramconfig pragma.

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: coder.hdl.ramconfig(RAMType="Simple Tri Port")

    Type of RAM to map persistent variables to, specified as one of these values:

    • "Single port" — Single port RAM with write data, write address, and write enable as inputs and read data as the output.

    • "Simple dual port" — Simple dual port RAM with write data, write address, write enable, and read address as inputs and data from read address as the output.

    • "Dual port" — Dual port RAM with write data, write address, write enable, and read address as inputs and data from read address and write address as the outputs.

    • "Simple tri port" — Simple tri port RAM with write data, write address, write enable, and read address a and b as inputs and data from read address a and b as the outputs.

    Option to use the asynchronous read feature in your target hardware, specified as a numeric or logical 1 (true) or 0 (false). Boards that support asynchronous read allow the hardware to execute a read instruction immediately instead of waiting one cycle.

    Behavior for the write output, specified as either:

    • "New data" — Send out new data at the address to the output.

    • "Old data" — Send out old data at the address to the output.

    This property is not available when you specify RAMType as Simple dual port or Simple tri port or if you set AsyncRead to true.

    Version History

    Introduced in R2023b