parent
c9e021924f
commit
aa6fbd35db
|
|
@ -0,0 +1,8 @@
|
||||||
|
.. comment: generated by t_param_hier_bad
|
||||||
|
.. code-block:: sv
|
||||||
|
:linenos:
|
||||||
|
:emphasize-lines: 3
|
||||||
|
|
||||||
|
sub #(.X(MY_X)) u_sub ();
|
||||||
|
|
||||||
|
localparam int SUB_Y = u_sub.Y; // <--- BAD: IEEE 1800-2023 6.20.2 no hierarchical
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
.. comment: generated by t_param_hier_bad
|
||||||
|
.. code-block::
|
||||||
|
|
||||||
|
%Error-HIERPARAM: example.v:1:32 Parameter values cannot use hierarchical values (IEEE 1800-2023 6.20.2)
|
||||||
|
: ... note: In instance 't'
|
||||||
|
36 | localparam int SUB_Y = u_sub.Y;
|
||||||
|
| ^
|
||||||
|
|
@ -896,6 +896,25 @@ List Of Warnings
|
||||||
This setting on the top module will be ignored.
|
This setting on the top module will be ignored.
|
||||||
|
|
||||||
|
|
||||||
|
.. option:: HIERPARAM
|
||||||
|
|
||||||
|
An error that a hierarchical value or function is being used to assign a parameter.
|
||||||
|
IEEE 1800-2023 6.20.2 requires this error.
|
||||||
|
|
||||||
|
Faulty example:
|
||||||
|
|
||||||
|
.. include:: ../../docs/gen/ex_HIERPARAM_faulty.rst
|
||||||
|
|
||||||
|
Results in:
|
||||||
|
|
||||||
|
.. include:: ../../docs/gen/ex_HIERPARAM_msg.rst
|
||||||
|
|
||||||
|
Suppressing this error may allow some hierarchical references to work (especially hierarchical
|
||||||
|
references into interface references), however not all cases are possible, e.g. it cannot
|
||||||
|
reference the parameter of a lower module in a way that affects determining the parameters
|
||||||
|
that elaborate that lower module.
|
||||||
|
|
||||||
|
|
||||||
.. option:: IFDEPTH
|
.. option:: IFDEPTH
|
||||||
|
|
||||||
Warns that if/if else statements have exceeded the depth specified with
|
Warns that if/if else statements have exceeded the depth specified with
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ public:
|
||||||
GENCLK, // Generated Clock. Historical, never issued.
|
GENCLK, // Generated Clock. Historical, never issued.
|
||||||
GENUNNAMED, // Generate unnamed, without label
|
GENUNNAMED, // Generate unnamed, without label
|
||||||
HIERBLOCK, // Ignored hierarchical block setting
|
HIERBLOCK, // Ignored hierarchical block setting
|
||||||
|
HIERPARAM, // Parameter using hierarchical value
|
||||||
IFDEPTH, // If statements too deep
|
IFDEPTH, // If statements too deep
|
||||||
IGNOREDRETURN, // Ignoring return value (function as task)
|
IGNOREDRETURN, // Ignoring return value (function as task)
|
||||||
IMPERFECTSCH, // Imperfect schedule (disabled by default). Historical, never issued.
|
IMPERFECTSCH, // Imperfect schedule (disabled by default). Historical, never issued.
|
||||||
|
|
@ -213,19 +214,19 @@ public:
|
||||||
"CDCRSTLOGIC", "CLKDATA", "CMPCONST", "COLONPLUS", "COMBDLY", "CONSTRAINTIGN",
|
"CDCRSTLOGIC", "CLKDATA", "CMPCONST", "COLONPLUS", "COMBDLY", "CONSTRAINTIGN",
|
||||||
"CONTASSREG", "COVERIGN", "DECLFILENAME", "DEFOVERRIDE", "DEFPARAM", "DEPRECATED",
|
"CONTASSREG", "COVERIGN", "DECLFILENAME", "DEFOVERRIDE", "DEFPARAM", "DEPRECATED",
|
||||||
"ENCAPSULATED", "ENDLABEL", "ENUMITEMWIDTH", "ENUMVALUE", "EOFNEWLINE", "GENCLK",
|
"ENCAPSULATED", "ENDLABEL", "ENUMITEMWIDTH", "ENUMVALUE", "EOFNEWLINE", "GENCLK",
|
||||||
"GENUNNAMED", "HIERBLOCK", "IFDEPTH", "IGNOREDRETURN", "IMPERFECTSCH", "IMPLICIT",
|
"GENUNNAMED", "HIERBLOCK", "HIERPARAM", "IFDEPTH", "IGNOREDRETURN", "IMPERFECTSCH",
|
||||||
"IMPLICITSTATIC", "IMPORTSTAR", "IMPURE", "INCABSPATH", "INFINITELOOP", "INITIALDLY",
|
"IMPLICIT", "IMPLICITSTATIC", "IMPORTSTAR", "IMPURE", "INCABSPATH", "INFINITELOOP",
|
||||||
"INSECURE", "LATCH", "LITENDIAN", "MINTYPMAXDLY", "MISINDENT", "MODDUP", "MODMISSING",
|
"INITIALDLY", "INSECURE", "LATCH", "LITENDIAN", "MINTYPMAXDLY", "MISINDENT", "MODDUP",
|
||||||
"MULTIDRIVEN", "MULTITOP", "NEWERSTD", "NOEFFECT", "NOLATCH", "NONSTD", "NULLPORT",
|
"MODMISSING", "MULTIDRIVEN", "MULTITOP", "NEWERSTD", "NOEFFECT", "NOLATCH", "NONSTD",
|
||||||
"PARAMNODEFAULT", "PINCONNECTEMPTY", "PINMISSING", "PINNOCONNECT", "PINNOTFOUND",
|
"NULLPORT", "PARAMNODEFAULT", "PINCONNECTEMPTY", "PINMISSING", "PINNOCONNECT",
|
||||||
"PKGNODECL", "PREPROCZERO", "PROCASSINIT", "PROCASSWIRE", "PROFOUTOFDATE", "PROTECTED",
|
"PINNOTFOUND", "PKGNODECL", "PREPROCZERO", "PROCASSINIT", "PROCASSWIRE",
|
||||||
"PROTOTYPEMIS", "RANDC", "REALCVT", "REDEFMACRO", "RISEFALLDLY", "SELRANGE",
|
"PROFOUTOFDATE", "PROTECTED", "PROTOTYPEMIS", "RANDC", "REALCVT", "REDEFMACRO",
|
||||||
"SHORTREAL", "SIDEEFFECT", "SPECIFYIGN", "SPLITVAR", "STATICVAR", "STMTDLY",
|
"RISEFALLDLY", "SELRANGE", "SHORTREAL", "SIDEEFFECT", "SPECIFYIGN", "SPLITVAR",
|
||||||
"SYMRSVDWORD", "SYNCASYNCNET", "TICKCOUNT", "TIMESCALEMOD", "UNDRIVEN", "UNOPT",
|
"STATICVAR", "STMTDLY", "SYMRSVDWORD", "SYNCASYNCNET", "TICKCOUNT", "TIMESCALEMOD",
|
||||||
"UNOPTFLAT", "UNOPTTHREADS", "UNPACKED", "UNSIGNED", "UNUSEDGENVAR", "UNUSEDLOOP",
|
"UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNOPTTHREADS", "UNPACKED", "UNSIGNED",
|
||||||
"UNUSEDPARAM", "UNUSEDSIGNAL", "USERERROR", "USERFATAL", "USERINFO", "USERWARN",
|
"UNUSEDGENVAR", "UNUSEDLOOP", "UNUSEDPARAM", "UNUSEDSIGNAL", "USERERROR", "USERFATAL",
|
||||||
"VARHIDDEN", "WAITCONST", "WIDTH", "WIDTHCONCAT", "WIDTHEXPAND", "WIDTHTRUNC",
|
"USERINFO", "USERWARN", "VARHIDDEN", "WAITCONST", "WIDTH", "WIDTHCONCAT",
|
||||||
"WIDTHXZEXPAND", "ZERODLY", "ZEROREPL", " MAX"};
|
"WIDTHEXPAND", "WIDTHTRUNC", "WIDTHXZEXPAND", "ZERODLY", "ZEROREPL", " MAX"};
|
||||||
return names[m_e];
|
return names[m_e];
|
||||||
}
|
}
|
||||||
// Warnings that default to off
|
// Warnings that default to off
|
||||||
|
|
@ -252,10 +253,10 @@ public:
|
||||||
bool pretendError() const VL_MT_SAFE {
|
bool pretendError() const VL_MT_SAFE {
|
||||||
return (m_e == ASSIGNIN || m_e == BADSTDPRAGMA || m_e == BADVLTPRAGMA || m_e == BLKANDNBLK
|
return (m_e == ASSIGNIN || m_e == BADSTDPRAGMA || m_e == BADVLTPRAGMA || m_e == BLKANDNBLK
|
||||||
|| m_e == BLKLOOPINIT || m_e == CONTASSREG || m_e == ENCAPSULATED
|
|| m_e == BLKLOOPINIT || m_e == CONTASSREG || m_e == ENCAPSULATED
|
||||||
|| m_e == ENDLABEL || m_e == ENUMITEMWIDTH || m_e == ENUMVALUE || m_e == IMPURE
|
|| m_e == ENDLABEL || m_e == ENUMITEMWIDTH || m_e == ENUMVALUE || m_e == HIERPARAM
|
||||||
|| m_e == MODMISSING || m_e == PARAMNODEFAULT || m_e == PINNOTFOUND
|
|| m_e == IMPURE || m_e == MODMISSING || m_e == PARAMNODEFAULT
|
||||||
|| m_e == PKGNODECL || m_e == PROCASSWIRE || m_e == PROTOTYPEMIS
|
|| m_e == PINNOTFOUND || m_e == PKGNODECL || m_e == PROCASSWIRE
|
||||||
|| m_e == ZEROREPL // Says IEEE
|
|| m_e == PROTOTYPEMIS || m_e == ZEROREPL // Says IEEE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Warnings to mention manual
|
// Warnings to mention manual
|
||||||
|
|
|
||||||
|
|
@ -1361,8 +1361,8 @@ class ParamVisitor final : public VNVisitor {
|
||||||
if (!valuep) return;
|
if (!valuep) return;
|
||||||
valuep->foreachAndNext([&](const AstNodeExpr* exprp) {
|
valuep->foreachAndNext([&](const AstNodeExpr* exprp) {
|
||||||
if (const AstVarXRef* refp = VN_CAST(exprp, VarXRef)) {
|
if (const AstVarXRef* refp = VN_CAST(exprp, VarXRef)) {
|
||||||
refp->v3error("Parameter values cannot use hierarchical values"
|
refp->v3warn(HIERPARAM, "Parameter values cannot use hierarchical values"
|
||||||
" (IEEE 1800-2023 6.20.2)");
|
" (IEEE 1800-2023 6.20.2)");
|
||||||
} else if (const AstNodeFTaskRef* refp = VN_CAST(exprp, NodeFTaskRef)) {
|
} else if (const AstNodeFTaskRef* refp = VN_CAST(exprp, NodeFTaskRef)) {
|
||||||
if (refp->dotted() != "") {
|
if (refp->dotted() != "") {
|
||||||
refp->v3error("Parameter values cannot call hierarchical functions"
|
refp->v3error("Parameter values cannot call hierarchical functions"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,9 @@ interface intf
|
||||||
endinterface
|
endinterface
|
||||||
|
|
||||||
module sub (intf.modp the_intf_port [4]);
|
module sub (intf.modp the_intf_port [4]);
|
||||||
const int intf_foo = the_intf_port[0].FOO;
|
// verilator lint_off HIERPARAM
|
||||||
|
localparam intf_foo = the_intf_port[0].FOO;
|
||||||
|
// verilator lint_on HIERPARAM
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
if (intf_foo != 4) $stop;
|
if (intf_foo != 4) $stop;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,9 @@ module Core(
|
||||||
);
|
);
|
||||||
|
|
||||||
// this will constify and valDiv2 will have the default value
|
// this will constify and valDiv2 will have the default value
|
||||||
const int valDiv4Upper = intf.valDiv2;
|
// verilator lint_off HIERPARAM
|
||||||
|
localparam valDiv4Upper = intf.valDiv2;
|
||||||
|
// verilator lint_on HIERPARAM
|
||||||
|
|
||||||
SimpleIntf #(.VAL(68)) core_intf ();
|
SimpleIntf #(.VAL(68)) core_intf ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
%Error: t/t_interface_param_another_bad.v:9:36: Parameter values cannot use hierarchical values (IEEE 1800-2023 6.20.2)
|
%Error-HIERPARAM: t/t_interface_param_another_bad.v:9:36: Parameter values cannot use hierarchical values (IEEE 1800-2023 6.20.2)
|
||||||
: ... note: In instance 't'
|
: ... note: In instance 't'
|
||||||
9 | simple_bus #(.PARAMETER(sb_intf.dummy)) simple();
|
9 | simple_bus #(.PARAMETER(sb_intf.dummy)) simple();
|
||||||
| ^~~~~
|
| ^~~~~
|
||||||
... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance.
|
... For error description see https://verilator.org/warn/HIERPARAM?v=latest
|
||||||
%Error: t/t_interface_param_another_bad.v:9:36: Expecting expression to be constant, but variable isn't const: 'dummy'
|
%Error: t/t_interface_param_another_bad.v:9:36: Expecting expression to be constant, but variable isn't const: 'dummy'
|
||||||
: ... note: In instance 't'
|
: ... note: In instance 't'
|
||||||
9 | simple_bus #(.PARAMETER(sb_intf.dummy)) simple();
|
9 | simple_bus #(.PARAMETER(sb_intf.dummy)) simple();
|
||||||
| ^~~~~
|
| ^~~~~
|
||||||
|
... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance.
|
||||||
%Error: t/t_interface_param_another_bad.v:9:18: Can't convert defparam value to constant: Param 'PARAMETER' of 'simple'
|
%Error: t/t_interface_param_another_bad.v:9:18: Can't convert defparam value to constant: Param 'PARAMETER' of 'simple'
|
||||||
: ... note: In instance 't'
|
: ... note: In instance 't'
|
||||||
9 | simple_bus #(.PARAMETER(sb_intf.dummy)) simple();
|
9 | simple_bus #(.PARAMETER(sb_intf.dummy)) simple();
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,11 @@ module t (/*AUTOARG*/
|
||||||
.intf_array (array_interface)
|
.intf_array (array_interface)
|
||||||
);
|
);
|
||||||
|
|
||||||
const int THE_TOP_FOO = the_interface.FOO;
|
// verilator lint_off HIERPARAM
|
||||||
const int THE_TOP_FOO_BITS = $bits({the_interface.FOO, the_interface.FOO});
|
localparam THE_TOP_FOO = the_interface.FOO;
|
||||||
const int THE_ARRAY_FOO = array_interface[0].FOO;
|
localparam THE_TOP_FOO_BITS = $bits({the_interface.FOO, the_interface.FOO});
|
||||||
|
localparam THE_ARRAY_FOO = array_interface[0].FOO;
|
||||||
|
// verilator lint_on HIERPARAM
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
if (THE_TOP_FOO != 5) begin
|
if (THE_TOP_FOO != 5) begin
|
||||||
|
|
@ -75,12 +77,14 @@ module testmod
|
||||||
test_if.mp intf_array [1:0]
|
test_if.mp intf_array [1:0]
|
||||||
);
|
);
|
||||||
|
|
||||||
const int THE_FOO = intf.FOO;
|
// verilator lint_off HIERPARAM
|
||||||
const int THE_OTHER_FOO = intf_no_mp.FOO;
|
localparam THE_FOO = intf.FOO;
|
||||||
const int THE_ARRAY_FOO = intf_array[0].FOO;
|
localparam THE_OTHER_FOO = intf_no_mp.FOO;
|
||||||
const int THE_BAR = intf.BAR;
|
localparam THE_ARRAY_FOO = intf_array[0].FOO;
|
||||||
const int THE_OTHER_BAR = intf_no_mp.BAR;
|
localparam THE_BAR = intf.BAR;
|
||||||
const int THE_ARRAY_BAR = intf_array[0].BAR;
|
localparam THE_OTHER_BAR = intf_no_mp.BAR;
|
||||||
|
localparam THE_ARRAY_BAR = intf_array[0].BAR;
|
||||||
|
// verilator lint_on HIERPARAM
|
||||||
|
|
||||||
always @(posedge clk) begin
|
always @(posedge clk) begin
|
||||||
if (THE_FOO != 5) begin
|
if (THE_FOO != 5) begin
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
%Error: t/t_param_hier_bad.v:36:32: Parameter values cannot use hierarchical values (IEEE 1800-2023 6.20.2)
|
%Error-HIERPARAM: t/t_param_hier_bad.v:36:32: Parameter values cannot use hierarchical values (IEEE 1800-2023 6.20.2)
|
||||||
: ... note: In instance 't'
|
: ... note: In instance 't'
|
||||||
36 | localparam int SUB_Y = u_sub.Y;
|
36 | localparam int SUB_Y = u_sub.Y;
|
||||||
| ^
|
| ^
|
||||||
... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance.
|
... For error description see https://verilator.org/warn/HIERPARAM?v=latest
|
||||||
%Error: t/t_param_hier_bad.v:38:35: Parameter values cannot call hierarchical functions (IEEE 1800-2023 6.20.2)
|
%Error: t/t_param_hier_bad.v:38:35: Parameter values cannot call hierarchical functions (IEEE 1800-2023 6.20.2)
|
||||||
: ... note: In instance 't'
|
: ... note: In instance 't'
|
||||||
38 | localparam int SUB_FUNC = u_sub.sub_func();
|
38 | localparam int SUB_FUNC = u_sub.sub_func();
|
||||||
| ^~~~~~~~
|
| ^~~~~~~~
|
||||||
|
... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance.
|
||||||
%Error: t/t_param_hier_bad.v:44:18: Parameter values cannot call hierarchical functions (IEEE 1800-2023 6.20.2)
|
%Error: t/t_param_hier_bad.v:44:18: Parameter values cannot call hierarchical functions (IEEE 1800-2023 6.20.2)
|
||||||
: ... note: In instance 't'
|
: ... note: In instance 't'
|
||||||
44 | sub #(.X(block.block_func())) u_sub2 ();
|
44 | sub #(.X(block.block_func())) u_sub2 ();
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,17 @@ import vltest_bootstrap
|
||||||
|
|
||||||
test.scenarios('linter')
|
test.scenarios('linter')
|
||||||
|
|
||||||
|
if not os.path.exists(test.root + "/.git"):
|
||||||
|
test.skip("Not in a git repository")
|
||||||
|
|
||||||
test.lint(fails=True, expect_filename=test.golden_filename)
|
test.lint(fails=True, expect_filename=test.golden_filename)
|
||||||
|
|
||||||
|
test.extract(in_filename=test.top_filename,
|
||||||
|
out_filename=test.root + "/docs/gen/ex_HIERPARAM_faulty.rst",
|
||||||
|
lines="34-36")
|
||||||
|
|
||||||
|
test.extract(in_filename=test.golden_filename,
|
||||||
|
out_filename=test.root + "/docs/gen/ex_HIERPARAM_msg.rst",
|
||||||
|
lines="1-4")
|
||||||
|
|
||||||
test.passes()
|
test.passes()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue