Main Content


Specify input to be mapped to the line buffer interface in HLS

Since R2023a



coder.hdl.interface(inputVar,"Line Buffer",imageSize,Name=Value) maps the input variable to the line buffer interface in Cadence® Stratus HLS. Specify properties of the line buffer interface as one or more name-value arguments.

You must insert this pragma at the start of the MATLAB® design. The specified line buffer properties are stored inside the ml.tcl file that is read by the Cadence Stratus importer.

This pragma does not affect MATLAB simulation behavior.


collapse all

Map the working set in1 to the line buffer interface in Cadence Stratus HLS by using the coder.hdl.interface pragma. Calculate the average of the values in the working set.

function out = line_buffer_average(in1)
    coder.hdl.interface(in1,"Line Buffer",[20 20],FillMethod="Nearest");
    sum = 0;
    for i = 1:size(in1,1)
        for j = 1:size(in1,2)
            sum = sum + in1(i,j);
    out = sum / numel(in1);
coder.hdl.interface uses the default value [3 3] for origin, which is the center of the working set, and the default value 0 for FillValue.

The MATLAB test bench demonstrates the usage of the hdl.WorkingSet class and getWorkingSet method. It generates the working sets for each pixel of the input image.

image = rand(20,20); 
ws = hdl.WorkingSet(image,[5 5],FillMethod="Nearest"); 
[ws, workingSet] = ws.nextWorkingSet(); 
while ws.hasNextWorkingSet() 
    out = line_buffer_average(workingSet); 
    [ws, workingSet] = ws.nextWorkingSet(); 


The hdl.WorkingSet class, nextWorkingSet, and hasNextWorkingSet methods must be used inside the MATLAB test bench.

Input Arguments

collapse all

Working set input variable, specified as a matrix.

Size of the image size from which the working sets are to be generated, specified as a 2-element row vector of positive integers.

Example: [20 20]

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.interface(in1,"Line Buffer",[20 20],FillMethod ="Nearest");

If you do not specify a name-value argument, MATLAB uses the default value for the missing argument.

Boundary fill method, specified as one of the options listed in this table.

Boundary Fill MethodDescription
"ConstantFill"Each value is filled with the specified constant value.
"Nearest"The value from the nearest location at the edge of the image to fill each boundary element.
"Reflected"Each element outside of the edge of the image is filled with a value that is within the image and an equal distance from the edge of the image.
"Wrap"Boundary values are filled with values wrapped around from the preceding or following rows of the image to fill boundary elements.

Origin of the working set, specified as a 2-element row vector of positive integers.

For the boundary fill method "Wrap", the default value of origin is [1 1].

Example: [2 2]

Constant value to fill pixels falling outside of the working set.

Example: 1

Version History

Introduced in R2023a

expand all