Main Content

coder.hdl.interface

Map input or output variable to interface in generated HLS code

Since R2023a

Description

coder.hdl.interface(inputVar,"Line Buffer","ImageSize",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.

example

coder.hdl.interface(varName,interfaceName) maps the input or the output variable to the specified interface in the generated code targeted for Vitis HLS.

You must insert this pragma at the start of the MATLAB design.

This pragma does not affect MATLAB simulation behavior.

example

Examples

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","ImageSize",[20 20],FillMethod="Nearest");
    sum = 0;
    for i = 1:size(in1,1)
        for j = 1:size(in1,2)
            sum = sum + in1(i,j);
        end
    end
    out = sum / numel(in1);
end
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(); 
end 

Note

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

Map one or more input or output variables to different interfaces in the generated HLS code targeted for AMD® Vitis HLS tool using coder.hdl.interface pragma.

% MATLAB Code
function [y1,y2] = fVector(x1,x2)
    coder.hdl.interface('x1', 'AXI4-Lite');
    coder.hdl.interface('x2', 'AXI4 Master');
    coder.hdl.interface('y1', 'AXI4-Stream');
    y1 = x1 + x2;
    y2 = x1 - x2;
end

% MATLAB Test bench
y1 = zeros(1,100);
y2 = y1;
x1 = [1,23,3,3,2,3,2,53,4];
x2 = x1;
[y1,y2] = fVector(x1,x2);

Input Arguments

collapse all

Working set input variable, specified as character vector.

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 of the input or the output variable, specified as a character vector.

Interface name, specified as — "AXI4-Lite", "AXI4 Master", or "AXI4-Stream".

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