主要内容

coder.hdl.literaltext

使用字面文本定义 pragma

自 R2024b 起

说明

coder.hdl.literaltext(literalText) 在您的 MATLAB® 代码中定义一条 pragma 语句,该语句出现在生成的 HLS 代码中的相同位置。

此 pragma 不影响 MATLAB 仿真行为。

示例

示例

全部折叠

在 MATLAB® 函数 myFun 中,使用 coder.hdl.literaltext 声明一条具有字面文本的 pragma 语句。此 pragma 语句出现在生成的 HLS 代码中的相同位置。

function out = myFun(in)
   out = zeros(10,10);
   a = in;
   b = in*8;
   for i = 1:10 
      for j = 1:10
         coder.hdl.literaltext("#pragma HLS loop_flatten");
         out(i,j) = a(i,j) + b(i,j);
      end
   end
end

从 MATLAB® 命令行窗口生成 HLS 代码。

cfg = coder.config("hdl");
cfg.Workflow = "High Level Synthesis";
cfg.SynthesisTool = "Xilinx Vitis HLS";
codegen -config cfg myFun -args {zeros(10)} -report
### Begin MATLAB to HLS Code Generation...
### Working on DUT: myFun.
### Begin HLS Code Generation
### Generating Resource Utilization Report resource_report.html.
### Working on myFunClass.hpp as myFunClass.hpp.
### Working on myFun_wrapper.cpp as myFun_wrapper.cpp.
### Generating HLS Conformance Report myFun_hdl_conformance_report.html.
### HLS Conformance check complete with 0 errors, 0 warnings, and 0 messages.
### To rerun codegen evaluate the following commands...

---------------------
cgi    = load('C:\ExampleManager\user.Bdoc.8_10\hdlcoder-ex58282915\codegen\myFun\hdlsrc\codegen_info.mat');
inVals = cgi.CodeGenInfo.inVals;
cfg    = cgi.CodeGenInfo.codegenSettings;
codegen -config cfg -args inVals -report
---------------------

### Code generation successful: View report

输入参数

全部折叠

pragma 语句,指定为字符串字面值。此参量必须为有效的 pragma 语句。

示例: "#pragma HLS loop_flatten"

版本历史记录

在 R2024b 中推出

另请参阅