HLS Code Generation Report
HDL Coder™ produces a code generation report that helps you to:
Resolve code generation issues and verify that your MATLAB® code is suitable for code generation.
View generated High-Level Synthesis (HLS) code.
See how the code generator determines and propagates type information for variables and expressions in your MATLAB code.
Access additional reports such as, conformance report and resource utilization report.
Report Generation
You can use HDL Coder to produce a code generation report in one of these ways.
In the HDL Coder app:
Open the HDL Coder Workflow Advisor.
In the HDL Code Generation step options, on the Coding Style tab, under Generated Code Comments, select the Generate report check box.
At the command line, use codegen
options.
To generate a report, use the
-report
option.To generate and open a report, use the
-launchreport
option.
Alternatively, use configuration object properties.
To generate a report, set
GenerateReport
totrue
.To open the report after generating it, set
LaunchReport
totrue
.
Report Location
The code generation report is named report.mldatx
. It is located in
the html
subfolder of the code generation output folder. If you have
MATLAB R2018a or later, you can open the report.mldatx
file by
double-clicking it.
Files and Functions
The report lists MATLAB source functions and generated files. In the MATLAB Source pane, the Function List view organizes functions according to the containing file. To visualize functions according to the call structure, use the Call Tree view.
To view a function in the code pane of the report, click the function in the list. Clicking a function opens the file that contains the function. To edit the selected file in the MATLAB Editor, click Edit in MATLAB or click a line number in the code pane.
Specialized Functions or Classes
When a function is called with different types of inputs or a class uses different types for its properties, the code generator produces specializations. In the MATLAB Source pane, numbered functions (or classes) indicate specializations. For example:
Functions List After Fixed-Point Conversion
If you convert floating-point MATLAB code to fixed-point MATLAB code, and then generate fixed-point HLS code, the MATLAB Source pane lists the original MATLAB functions and the fixed-point MATLAB functions. For example:
MATLAB Source
To view a MATLAB function in the code pane, click the name of the function in the MATLAB Source pane. In the code pane, when you hover on a variable or expression, a tooltip displays information about its size, type, and complexity. Additionally, syntax highlighting helps you to identify MATLAB syntax elements and certain code generation attributes, such as whether a function is extrinsic or whether an argument is constant.
Extrinsic Functions
The report identifies an extrinsic function with purple text. The tooltip indicates that the function is extrinsic.
Constant Arguments
Orange text indicates a compile-time constant argument to an entry-point function or a specialized function. The tooltip includes the constant value.
Knowing the value of a constant argument helps you to understand the generated function signatures. It also helps you to see when code generation creates function specializations for different constant argument values.
To export the value to a variable in the workspace, click the Export icon .
MATLAB Variables
The Variables tab provides information about the variables for the selected MATLAB function. To select a function, click the function in the MATLAB Source pane.
The variables table shows:
Class, size, and complexity
Properties of fixed-point types
This information helps you to understand type propagation and identify type mismatch errors.
Visual Indicators on the Variables Tab
This table describes the symbols, badges, and other indicators in the variables table.
Column in the Variables Table | Indicator | Description |
---|---|---|
Name | expander | Variable has elements or properties that you can see by clicking the expander. |
Name | {:} | Heterogeneous cell array (all elements have the same properties) |
Name | {n} | nth element of a heterogeneous cell array |
Class | v > n | v is reused with a different class, size, and complexity.
The number n identifies each unique reuse (a reuse with a
unique set of properties). When you pause over a renamed variable, the report
highlights only the instances of this variable that share the class, size, and
complexity. |
Class | complex prefix | Complex number |
Class | Fixed-point type To see the fixed-point properties, click the badge. |
Tracing Code
You can trace between MATLAB source code and generated HLS code by using one of these methods:
Interactively visualize the mapping between the MATLAB code and the generated code. To access interactive tracing, open the code generation report and click Trace Code.
Include source code as comments in the generated HLS code.
When you click Trace Code on the HDL Coder Report Viewer, you see the MATLAB source code and the generated HLS code next to each other.
When you move your pointer over expressions that are part of larger expressions, different shades of purple help you to find the relevant expression in the corresponding HLS code.
Code Insights
The code generator can detect and report issues that can potentially occur in the generated code. View the messages on the Code Insights tab.
HLS code insights capture these inefficient loop constructs:
Presence of unbounded loops in the MATLAB code.
Presence of
break
,continue
, orreturn
statements in the MATLAB code.
Additional Reports
The Summary tab can have links to these additional reports:
Conformance report
You can view the code generation error, warning, and information messages in the conformance report. To highlight the source code for an error or warning, click the message. It is a best practice to address the first message before later messages because subsequent errors and warnings can be related to the first message.
Resource utilization report
The report contains a summary and detailed information about the hardware resources that could be utilized during synthesis of the generated HLS code.
For example, consider the MATLAB code and its tech bench.
MATLAB Code HLS Resource Utilization Report % MATLAB Code function y = mux(x,y) if x > 0 && x < 10 y = x + y; else y = 2*x + y; end end
% MATLAB Test Bench mux(4,5);
The table lists the mapping of operations/operators used in the MATLAB code to the hardware resources.
Resource Name Description Multipliers
Multiplication operations maps to multipliers on hardware.
Adders and Subtractors
Addition and subtraction operations maps to adders and subtractors on hardware.
Registers
MATLAB persistent variables maps to the registers on hardware.
RAMs
MATLAB persistent arrays maps to RAM on hardware to reduce the area on the target device.
Multiplexers
Conditional statements maps to the multiplexers on hardware.
I/O Bits
Specifies the total bit count of the input and output bits.
Shifters
Bit shift operations maps to the shifters on the hardware.