RTL Description Rules and Checks
HDL Coder™ conforms to the following RTL description rules and checks for modeling constructs that violate these rules. HDL Coder reports potential rule violations in the HDL coding standard report. To avoid these violations, see the rule recommendations.
2.A Guidelines for Combinational Logic
2.A.A Combinatorial Logic Conventions
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.A.A.1 Reference |
| HDL Coder includes the package in each entity in the generated VHDL code. | No action required. |
2.A.A.2 Warning |
| HDL Coder does not generate functions for DUT. | No action required. |
2.A.A.3 Warning |
| HDL Coder generates VHDL, Verilog, SystemVerilog code with the correct syntax and complies with this rule. | No action required. |
2.A.B Function Conventions
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.A.B.1 Error |
| HDL Coder does not generate functions for DUT. | No action required. |
| At the inputs and outputs, HDL Coder uses std_logic or std_logic_vector to describe the ports. | No action required. | |
2.A.B.2–3 Error |
| The generated HDL code complies with this rule for Verilog and SystemVerilog. | No action required. |
| By default, HDL Coder specifies the range for integer types in the generated code. | No action required. | |
2.A.B.4 Error |
| HDL Coder does not use tasks or fork-join constructs in the Verilog and SystemVerilog code. | No action required. |
| HDL Coder does not use bit or bit vector data types in the generated code. | No action required. | |
2.A.B.5 Error |
| When generating Verilog or SystemVerilog code, HDL Coder does not use clock edges in a task description. | No action required. |
2.A.B.6 Error |
| HDL Coder complies with this rule, because the generated VHDL code specifies the range that std_logic_vector uses. | No action required. |
2.A.C Bit Width Matching Conventions
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.A.C.1–2 Error |
| At module instantiation, HDL Coder enforces type matching, so that it complies with this rule. | No action required. |
| When generating VHDL code, HDL Coder specifies ‘IN’, ’OUT’, or ‘INOUT’ ports, and does not use buffer or linkage. | No action required. | |
2.A.C.3 Error |
| HDL Coder complies with this rule. | No action required. |
| When generating VHDL code, HDL Coder specifies ‘IN’, ’OUT’, or ‘INOUT’ ports and does not use buffer or linkage. | No action required. | |
2.A.C.4–5 Error |
| HDL Coder generates Verilog or SystemVerilog code that complies with this rule. | No action required. |
| In the generated VHDL code, HDL Coder does not specify an initial value to the input port. | No action required. |
2.A.D Operators Conventions
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.A.D.5 Message |
| In the generated Verilog or SystemVerilog code, HDL Coder complies with this rule for multibit operators. | No action required. |
2.A.D.6 Message |
| By default, HDL Coder does not reduce a single-bit or a large expression. If your design performs bit-reduction operations, the resulting HDL code can perform reduction of a large expression. | Update your design so that there are no calls to bit reduction operations. |
2.A.E Conditional Statement Conventions
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.A.E.3 Message |
| HDL Coder complies with this rule. | No action required. |
2.A.F Array, Vector, Matrix Conventions
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.A.F.2 Warning |
| Your design contains vectors whose LSB has a nonzero value. | Update your design so that the generated code contains vectors or memory whose LSB value is zero. |
2.A.F.4 Warning |
| HDL Coder enforces type matching and ensures that the index variable width is not too short. | No action required. |
2.A.F.5 Error |
| In the generated code, HDL Coder does not use x or z for an array index. | No action required. |
2.A.G Assignment Conventions
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.A.G.1 Error |
| HDL Coder directly assigns aggregates in the generated code without performing any intervening operations. | No action required. |
2.A.H Function Return Value Conventions
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.A.H.1 Reference |
| In the generated code, HDL Coder does not use constrained arrays in subprogram description. | No action required. |
2.A.H.2 Reference |
| In function description, when the return type is array, HDL Coder specifies the range for return values in function in the generated code. | No action required. |
2.A.H.4–6 Error |
| HDL Coder complies with this rule. | No action required. |
2.A.H.9–10 Warning |
| HDL Coder complies with this rule. | No action required. |
2.A.I Built-in Attribute Conventions
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.A.I.4–5 Error |
| By default, HDL Coder does not use user-defined attributes in the generated code. If you set HDL block properties, such as DSPStyle in your design, the generated code uses synthesis directives. | To fix this error, in your design, clear the HDL block property that you have set for using synthesis directives in the generated code. |
2.A.J VHDL Specific Conventions
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.A.J.1–6 Warning |
| If your design uses loop statements, HDL Coder generates this warning. | To avoid this warning, update your design so that there are no looping statements. |
2.A.J.8–13 Error |
| HDL Coder complies with this rule. | No action required. |
2.B Guidelines for “Always
” Constructs of Combinational Logic
2.B.A Latch Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.B.A.2 Reference |
| HDL Coder does not create latches. | No action required. |
2.B.B Signal Constraints - I
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.B.B.2–3 Message |
| HDL Coder generates code that complies with
the use of these constructs inside a
| No action required. |
| HDL Coder does not describe more than one
event expression in an | No action required. |
2.B.C Signal Constraints - II
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.B.C.1–2 Error |
| Your design uses constructs that
generate Verilog code with nonblocking assignments
in combinational | Update your MATLAB® algorithm or Stateflow® design so that the generated Verilog code does not use these constructs. |
2.B.C.3 Message |
| In an | No action required. |
2.C Guidelines for Flip-Flop Inference
2.C.A Assignment Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.C.A.1–2c Error |
| HDL Coder does not introduce
any additional
data or add these constructs when generating
flip-flops in | No action required. |
2.C.A.4–5b Warning |
| HDL Coder does not generate code that uses
| No action required. |
2.C.A.6 Error |
| HDL Coder uses | No action required. |
2.C.A.7 Message |
| HDL Coder does not generate multiple asynchronous resets. The generated code can contain multiple synchronous resets. | No action required. |
2.C.A.8 Error |
| HDL Coder does not use wait constructs. | No action required. |
2.C.A.9 Error |
| By default, HDL Coder uses the event syntax for clock events. By using the
| To fix this error, you can control
the |
2.C.B Blocking Statement Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.C.B.1–2 Warning |
| HDL Coder complies with this rule. | No action required. |
2.C.B.4 Error |
| The generated HDL code does not contain dead code, so HDL Coder complies with this rule. | No action required. |
2.C.C Clock Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.C.C.1–2b Error |
| HDL Coder uses the rising edge or falling edge of the clock, but does not use both edges of the clock. | No action required. |
2.C.C.4–5 Error |
| If your design generates code that uses clock enables and reset signals on networks, HDL Coder generates an error. | To minimize clock enables in the generated HDL code, in the HDL coding standard customization properties, enable the MinimizeClockEnableCheck property. To remove reset signals on the networks, in the HDL coding standard customization properties, enable the RemoveResetCheck setting. |
2.C.C.6 Warning |
| Your Simulink® model design or MATLAB code uses asynchronous reset signals. | To avoid this violation, use
synchronous reset signals for your design. In the
Configuration Parameters dialog box, set
Reset type to
|
2.C.D Initial Value Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.C.D.1 Error |
| The generated HDL code for your
design contains an unsynthesizable
| Disable the Initialize block RAM or Initialize all RAM blocks option in the HDL Workflow Advisor. You can disable this rule
checking by using the
|
2.C.F Mixed Timing Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.C.F.1–2a Warning |
| HDL Coder complies with this rule. | No action required. |
2.D Guidelines for Latch Description
2.D.A Module Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.D.A.2–3 Warning |
| HDL Coder does not create latches in the generated code. | No action required. |
2.D.A.4–5 Error |
| By default, HDL Coder does not create combinational loops. If your MATLAB algorithm contains combinational loops, the generated HDL code can use combinational loops. | Update your MATLAB code so that the generated HDL code does not contain any combinational loops. |
2.E Guidelines for Tristate Buffer
2.E.A Module Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.E.A.1–2 Warning |
| HDL Coder does not create latches or tristate buffers in the generated code. | No action required. |
2.E.A.4–5b Reference |
| HDL Coder does not create latches or tristate buffers in the generated code. | No action required. |
2.E.A.6–9 Error |
| By default, HDL Coder does not connect input or output ports directly to bidirectional ports. In your Simulink model, on the HDL block properties
for the input or output port, if you set
BidirectionalPort to
| In your Simulink model, on the HDL block properties
for the input or output port, set
BidirectionalPort to
|
2.E.B Connectivity Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.E.B.1 Warning |
| HDL Coder does not have tristate nets in the generated HDL code. | No action required. |
2.F Guidelines for Always
/Process
Construct with Circuit Structure into Account
2.F.B Constraints on Number of Conditional Statements
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.F.B.1 Error |
| The generated HDL code for your
design contains more than one conditional
statement (if-else, case, and loops) that is
described separately within a
| Update your design so that there is not more than one conditional statement that is described separately in a process block. You can customize this rule by
using the
|
2.F.B.1.a Error |
| The generated HDL code for your
design contains the same signal for VHDL code or
register for Verilog and SystemVerilog code
written to in multiple cascaded conditional
regions (such as | Update your design so that the signal or register is not written to more than once in cascaded conditional regions in the same process block or always construct. For more information, see Cascaded Conditional Region Variable Assignments. You can customize this rule by
using the
|
2.F.B.2 Error |
| HDL Coder does not modify the variables in the sensitivity list, including clock, reset, and enable signals. | No action required. |
2.G Guidelines for “IF” Statement Description
2.G.B Common Sub-Expression Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.G.B.2 Warning |
| The generated HDL code does not contain dead code, or result in conditions that are not executed. | No action required. |
2.G.C Nesting Depth Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.G.C.1a-b Message |
| The MATLAB code contains an
| Modify For example, the following
if ... if ... if ... else else else You
can customize this rule by using the
|
2.G.C.1c Message | Verilog/VHDL/SystemVerilog: Chain of if...else if
constructs must not be exceed default number of
levels. | The generated HDL code contains an
| Modify For
example, the following
if ... elseif ... elseif ... else You
can customize this rule by using the
|
2.G.D Begin-End Decorator Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.G.D.2–3 Message |
| The generated HDL code complies with these code constructs. | No action required. |
|
2.H Guidelines for “CASE” Statement Description
2.H.A CASE Structure Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.H.A.3–5 Reference |
| The generated HDL code complies with these constructs for case statements and does not use the full_case directive. | No action required. |
2.H.C Default Value Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.H.C.3 Warning |
| HDL Coder describes all possible cases in a case statement so that the synthesis tool does not infer a latch. | No action required. |
2.H.C.4 Message |
| HDL Coder does not use a signal that is assigned a don’t care value in the default clause. | No action required. |
2.H.C.5 Warning |
| To avoid latch inference, HDL Coder describes all possible cases, including the default clause. | No action required. |
2.H.C.6–7 Message |
| HDL Coder does not use don’t care values, and explores the entire space of an n-bit select signal. | No action required. |
2.H.D Don’t Care Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.H.D.1-4 Message |
| HDL Coder does not generate casex or casez constructs, so that it complies with this rule. | No action required. |
2.H.E Additional CASE Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.H.E.1–4 Message |
| HDL Coder does not use the
| No action required. |
2.I Guidelines for “FOR” Statement Description
2.I.A Loop Body Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.I.A.2a-b Message |
| HDL Coder does not generate casex or casez constructs so that it complies with this rule. | No action required. |
2.I.A.2c-e Message |
| HDL Coder generates the right loop constructs and complies with this rule. | No action required. |
|
2.I.B Non-Constant Operation Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.I.B.4 Error |
| HDL Coder uses separate for loops in the reset and logic parts of flip-flop descriptions. | No action required. |
2.I.C Exit Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.I.C.1 Error |
| The generated code contains for loops only when HDL Coder knows the number of iterations. When the loop is executing, HDL Coder does not exit from the for loop, | No action required. |
2.J Guidelines for Operator Description
2.J.A Comparison and Precedence Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.J.A.4a-c Message |
| By default, HDL Coder does not generate code that contains these constructs. If your Simulink model design uses
Constant blocks with
Architecture set to
| Update your Simulink model design so that the
Constant blocks do not use these
constructs when Architecture
is set to |
2.J.A.4v Error |
| By default, HDL Coder does not use | Update your Simulink model design so that the generated HDL code does not use constructs that rule 2.J.A.4a-c specifies. |
2.J.A.5–6 Warning |
| If your design uses unknown or high-impedance constants, HDL Coder displays a warning. | Update your Simulink model or MATLAB algorithm so that there are no high-impedance constants. |
| |||
2.J.A.7–8 Message |
| By default, HDL Coder complies with this rule. If your Simulink model uses RAM output signals with a Switch or Multiport switch block, the generated HDL code can use these constructs. | Update your Simulink model so that there are no RAM output signals to Switch or Multiport switch blocks. |
2.J.B Vector Operator Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.J.B.3 Message |
| HDL Coder does not perform logical negation on vectors. | No action required. |
2.J.C Relational Operator Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.J.C.1–6 Error |
| HDL Coder ensures that the data types of the operands match in a relational or logical expression. | No action required. |
|
2.J.D Signed Signal, Data Type Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.J.D.3–5 Warning |
| HDL Coder complies with this rule. | No action required. |
2.J.D.6 Warning |
| HDL Coder complies with this rule. | No action required. |
2.J.D.8 Warning |
| HDL Coder does not use the function
| No action required. |
2.J.E Number of Operator Repetition Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.J.E.5 Warning |
| HDL Coder complies with this rule. | No action required. |
2.J.F Precision Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.J.F.5 Warning | Verilog/VHDL/SystemVerilog: Large multipliers
must not be described using the multiplication
operator with RTL. | The generated HDL code contains a
multiplication operator ( | In your design, implement multiplications by using a shift-and-add algorithm, or ensure that the data size of the output of a multiplication does not require a bitwidth of 16 or greater. You can customize this
rule by using the
|
2.J.G Common Sub-Expression Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.J.G.2 Warning | Verilog/VHDL/SystemVerilog: common operational
expressions should be described
separately. | HDL Coder identifies the common operational expressions and describes them separately. | No action required. |
2.J.H Division Operator Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.J.H.1 Message | Verilog/VHDL/SystemVerilog: Do not use arithmetic
and logical expressions in the right and left
sides of the division or modulus
operator. | HDL Coder homogenizes the division operator into a separate statement and complies with this rule. | No action required. |
2.J.H.2–3 Message | Verilog/VHDL/SystemVerilog: Keep the left side of
the division or modulus operator within 12 bits.
If right side of the division or modulus operator
is not a power of two, keep it within 8
bits. | In your design, the left side of the modulus or division operation is greater than 12 bits, or the right side is not a power of two and greater than eight bits. | Update your design so that the number of bits in the operands of the division or modulus operation are within the bounds that the rule specifies. |
2.K Guidelines for Finite State Machine Description
2.K.A State Transition Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.K.A.4 Warning | Verilog/VHDL/SystemVerilog: Number of states of
an FSM should be within 40. | Your model design contains a Stateflow Chart or State Transition Table that uses more than 40 states. | Update your model design so that there are not more than 40 states. |
2.K.C Logic Separation Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.K.C.1 Reference | Verilog/VHDL/SystemVerilog: Ensure that
sequential and combinational parts of an FSM are
in separate always block. | By default, HDL Coder puts the sequential and
combinational parts of a Finite State Machine
(FSM) in separate | No action required. |
2.K.E Encoding Constraints
Rule / Severity | Message | Problem | Recommendations |
---|---|---|---|
2.K.E.2 Warning | VHDL: Do not assign state encoding by attaching
attributes to the state variable which is declared
as a type. | HDL Coder does not attach attributes to state variables in the generated code. | No action required. |