Main Content

coder.hdl.arraydistance

Specify minimum or maximum array distance inside pipelined for-loop

Since R2022b

Description

coder.hdl.arraydistance(arr_name,'min',arr_distance)specifies the minimum array distance inside a pipelined for-loop. The array distance is the number of clock cycles between a memory read operation and memory write operation in an array. You must insert this pragma at the start of the for-loop body.

example

coder.hdl.arraydistance(arr_name,'max',arr_distance) specifies the maximum array distance inside a pipelined for-loop. You must insert this pragma at the start of the for-loop body.

This pragma does not affect MATLAB® simulation behavior and supports only MATLAB to HLS code generation workflow.

Note

coder.hdl.arraydistance pragma is supported only when Cadence® Stratus is chosen as the synthesis tool for HLS code generation.

example

Examples

collapse all

In the MATLAB function myMin, specify the minimum array distance inside the pipelined for-loop as 1.

function out = myMin(in)
 
    persistent arr1;
    if isempty(arr1)
        arr1 = int8(zeros(1,100));
    end
 
    coder.hdl.loopspec('pipeline',1);
    for i = 4:100
        coder.hdl.arraydistance('arr1','min',1);
        y = arr1(i - 3);
        arr1(i) = in;
    end
    out = y;
end

In the MATLAB function myMax, specify the maximum array distance inside the pipelined for-loop as 2.

function out = myMax(in)
 
    persistent arr1;
    if isempty(arr1)
        arr1 = int8(zeros(1,100));
    end
 
    coder.hdl.loopspec('pipeline',1);
    for i = 4:100
        coder.hdl.arraydistance('arr1','max',2);
        y = arr1(i - 3);
        arr1(i) = in;
    end
    out = y;
end

Input Arguments

collapse all

Name of the persistent array mapped to RAM, specified as a character vector.

Example: 'myArr'

Distance, in terms of the number of clock cycles, between a memory read and a memory write operation in an array, specified as a positive integer.

Example: 7

Version History

Introduced in R2022b