Main Content

coder.hdl.arraydistance

Specify minimum or maximum array distance inside pipelined for-loop

Since R2022b

Description

example

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

This pragma does not affect MATLAB® simulation behavior.

example

coder.hdl.arraydistance(arr_name,'max',arr_distance) enables you to specify 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.

Examples

collapse all

In the MATLAB function myMin, the minimum arr_distance inside the pipelined for-loop is 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, the maximum arr_distance inside the pipelined for-loop is 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