coder.hdl.interface
Description
coder.hdl.interface(
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.inputVar
,"Line Buffer",imageSize
,Name=Value
)
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.
Examples
Map Line Buffer Interface in MATLAB Code
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); 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.
Input Arguments
inputVar
— Working set input variable name
matrix
Working set input variable, specified as a matrix.
imageSize
— Input image size
2-element row 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-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.
FillMethod
— Boundary fill method
'ConstantFill'
(default) | 'Nearest'
| 'Reflected'
| 'Wrap'
Boundary fill method, specified as one of the options listed in this table.
Boundary Fill Method | Description |
---|---|
"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
— Origin of working set
Center of the working set (default) | 2-element row vector
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]
FillValue
— Constant value to fill outside of working set
0
(default) | scalar
Constant value to fill pixels falling outside of the working set.
Example: 1
Version History
Introduced in R2023aR2024a: Syntax update for coder.hdl.interface
Starting in R2024a, specify properties of the line buffer as name-value arguments.
See Also
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)