diff --git a/Changes b/Changes index 5693a1764..d4c76d539 100644 --- a/Changes +++ b/Changes @@ -5,13 +5,15 @@ indicates the contributor was also the author of the fix; Thanks! * Verilator 3.712 2009/** -** Patching SystemC is no longer required to trace sc_bvs. +** Patching SystemC is no longer required to trace sc_bvs. -*** Support zero-width constants in concatenations. [Jeff Winston] +*** Support zero-width constants in concatenations. [Jeff Winston] -*** Add verilator --pins-uint8 option to use sc_in. +*** Add verilator --pins-uint8 option to use sc_in. -*** Add verilator -V option, to show verbose version. +*** Add verilator -V option, to show verbose version. + +*** On WIDTH warnings, show variable name causing error. [Jeff Winston] **** Add BLKLOOPINIT error code, and describe --unroll-count. [Jeff Winston] diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index e535afbf3..1b33e452c 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -176,6 +176,11 @@ string AstNode::prettyName(const string& namein) { return pretty; } +string AstNode::prettyTypeName() const { + if (name()=="") return typeName(); + return string(typeName())+" '"+prettyName()+"'"; +} + int AstNode::widthPow2() const { // I.e. width 30 returns 32, width 32 returns 32. uint32_t width = this->width(); diff --git a/src/V3Ast.h b/src/V3Ast.h index 65968fdb6..7615f73cf 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -640,7 +640,7 @@ protected: public: // ACCESSORS virtual AstType type() const = 0; - const char* typeName() const { return type().ascii(); } + const char* typeName() const { return type().ascii(); } // See also prettyTypeName AstNode* nextp() const { return m_nextp; } AstNode* backp() const { return m_backp; } AstNode* op1p() const { return m_op1p; } @@ -676,6 +676,7 @@ public: static string encodeName(const string& namein); // Encode user name into internal C representation static string encodeNumber(vlsint64_t numin); // Encode number into internal C representation string prettyName() const { return prettyName(name()); } + string prettyTypeName() const; // "VARREF name" for error messages FileLine* fileline() const { return m_fileline; } int width() const { return m_width; } bool width1() const { return width()==1; } diff --git a/src/V3Const.cpp b/src/V3Const.cpp index e21fcf5c4..42b1993c3 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -1674,7 +1674,7 @@ private: // Default: Just iterate if (m_required) { nodep->v3error("Expecting expression to be constant, but can't convert a " - <typeName()<<" to constant."); + <prettyTypeName()<<" to constant."); } else { // Calculate the width of this operation if (m_params && !nodep->width()) { diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 5726f1001..cb3efcd2f 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -528,9 +528,9 @@ public: virtual void visit(AstTraceInc*, AstNUser*) {} // Handled outside the Visit class // Default virtual void visit(AstNode* nodep, AstNUser*) { - puts((string)"\n???? // "+nodep->typeName()+"\n"); + puts((string)"\n???? // "+nodep->prettyTypeName()+"\n"); nodep->iterateChildren(*this); - nodep->v3fatalSrc("Unknown node type reached emitter: "<typeName()); + nodep->v3fatalSrc("Unknown node type reached emitter: "<prettyTypeName()); } public: diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index bed46e7c8..2e0b8e126 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -442,9 +442,9 @@ class EmitVBaseVisitor : public EmitCBaseVisitor { virtual void visit(AstCell*, AstNUser*) {} // Handled outside the Visit class // Default virtual void visit(AstNode* nodep, AstNUser*) { - puts((string)"\n???? // "+nodep->typeName()+"\n"); + puts((string)"\n???? // "+nodep->prettyTypeName()+"\n"); nodep->iterateChildren(*this); - nodep->v3fatalSrc("Unknown node type reached emitter: "<typeName()); + nodep->v3fatalSrc("Unknown node type reached emitter: "<prettyTypeName()); } public: diff --git a/src/V3Hashed.cpp b/src/V3Hashed.cpp index e20a73858..ecd0c2075 100644 --- a/src/V3Hashed.cpp +++ b/src/V3Hashed.cpp @@ -65,7 +65,7 @@ private: if (!nodep->user4()) { if (nodep->backp()->castCFunc() && !(nodep->castNodeStmt() || nodep->castCFunc())) { - nodep->v3fatalSrc("Node "<typeName()<<" in statement position but not marked stmt (node under function)"); + nodep->v3fatalSrc("Node "<prettyTypeName()<<" in statement position but not marked stmt (node under function)"); } V3Hash oldHash = m_lowerHash; { diff --git a/src/V3Table.cpp b/src/V3Table.cpp index e228683db..7c42c6973 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -353,7 +353,7 @@ private: // In production code, we'll just not optimize. It should be fixed though. clearOptimizable(nodep, "Unknown node type, perhaps missing visitor in TableSimulateVisitor"); #ifdef VL_DEBUG - UINFO(0,"Unknown node type in TableSimulateVisitor: "<typeName()<prettyTypeName()<v3error("Port connection "<prettyName()<<" as part of a module instance array " <<" requires "<exprp()->typeName() + <<" bits, but connection's "<exprp()->prettyTypeName() <<" generates "<v3error("Unsupported: Port connection "<prettyName()<<" to inout signal " <<" requires "<exprp()->typeName() + <<" bits, but connection's "<exprp()->prettyTypeName() <<" generates "<4) nodep->backp()->dumpTree(cout," back: "); - nodep->v3warn(WIDTH,"Operator "<typeName() + nodep->v3warn(WIDTH,"Operator "<prettyTypeName() <<" expects "<typeName()<<" generates "<width() + <prettyTypeName()<<" generates "<width() <<(underp->width()!=underp->widthMin() ?" or "+cvtToStr(underp->widthMin()):"") <<" bits."); @@ -987,9 +987,9 @@ void WidthVisitor::widthCheckReduce (AstNode* nodep, const char* side, if (bad) { if (!ignoreWarn) { if (debug()>4) nodep->backp()->dumpTree(cout," back: "); - nodep->v3warn(WIDTH,"Logical Operator "<typeName() + nodep->v3warn(WIDTH,"Logical Operator "<prettyTypeName() <<" expects 1 bit on the "<typeName()<<" generates "<width() + <prettyTypeName()<<" generates "<width() <<(underp->width()!=underp->widthMin() ?" or "+cvtToStr(underp->widthMin()):"") <<" bits."); @@ -1006,7 +1006,7 @@ void WidthVisitor::widthCheckPin (AstNode* nodep, AstNode* underp, int expWidth, <<" port connection "<prettyName() <<" expects "<typeName()<<" generates "<width() + <prettyTypeName()<<" generates "<width() <<(underp->width()!=underp->widthMin() ?" or "+cvtToStr(underp->widthMin()):"") <<" bits."); diff --git a/test_regress/t/t_flag_werror_bad1.pl b/test_regress/t/t_flag_werror_bad1.pl index f4868a1ea..d80592b4d 100755 --- a/test_regress/t/t_flag_werror_bad1.pl +++ b/test_regress/t/t_flag_werror_bad1.pl @@ -13,9 +13,9 @@ compile ( v_flags2 => ["--lint-only"], fails=>$Self->{v3}, expect=> -'%Warning-WIDTH: t/t_flag_werror.v:\d+: Operator ASSIGNW expects 4 bits on the Assign RHS, but Assign RHS.s CONST generates 6 bits. +q{%Warning-WIDTH: t/t_flag_werror.v:\d+: Operator ASSIGNW expects 4 bits on the Assign RHS, but Assign RHS.s CONST '6'h2e' generates 6 bits. %Warning-WIDTH: Use .* and lint_on around source to disable this message. -%Error: Exiting due to', +%Error: Exiting due to}, ) if $Self->{v3}; ok(1); diff --git a/test_regress/t/t_flag_werror_bad2.pl b/test_regress/t/t_flag_werror_bad2.pl index 2f53d0389..41c91e2e8 100755 --- a/test_regress/t/t_flag_werror_bad2.pl +++ b/test_regress/t/t_flag_werror_bad2.pl @@ -14,8 +14,8 @@ compile ( fails=>$Self->{v3}, verilator_flags=> [qw(-sp -Werror-WIDTH)], expect=> -'%Error-WIDTH: t/t_flag_werror.v:\d+: Operator ASSIGNW expects 4 bits on the Assign RHS, but Assign RHS.s CONST generates 6 bits. -%Error: Exiting due to', +q{%Error-WIDTH: t/t_flag_werror.v:\d+: Operator ASSIGNW expects 4 bits on the Assign RHS, but Assign RHS.s CONST '6'h2e' generates 6 bits. +%Error: Exiting due to}, ) if $Self->{v3}; ok(1); diff --git a/test_regress/t/t_func_bad_width.pl b/test_regress/t/t_func_bad_width.pl index 0ce83d85b..9689e4165 100755 --- a/test_regress/t/t_func_bad_width.pl +++ b/test_regress/t/t_func_bad_width.pl @@ -11,10 +11,10 @@ compile ( v_flags2 => ["--lint-only"], fails=>$Self->{v3}, expect=> -'%Warning-WIDTH: t/t_func_bad_width.v:\d+: Operator FUNCREF expects 40 bits on the Function Argument, but Function Argument.s VARREF generates 39 bits. +q{%Warning-WIDTH: t/t_func_bad_width.v:\d+: Operator FUNCREF 'MUX' expects 40 bits on the Function Argument, but Function Argument's VARREF 'in' generates 39 bits. %Warning-WIDTH: Use [^\n]+ -%Warning-WIDTH: t/t_func_bad_width.v:\d+: Operator ASSIGN expects 4 bits on the Assign RHS, but Assign RHS.s FUNCREF generates 32 bits. -%Error: Exiting due to', +%Warning-WIDTH: t/t_func_bad_width.v:\d+: Operator ASSIGN expects 4 bits on the Assign RHS, but Assign RHS.s FUNCREF 'MUX' generates 32 bits. +%Error: Exiting due to}, ); ok(1); diff --git a/test_regress/t/t_inst_array_bad.pl b/test_regress/t/t_inst_array_bad.pl index 4a1aa33e6..7a5160b52 100755 --- a/test_regress/t/t_inst_array_bad.pl +++ b/test_regress/t/t_inst_array_bad.pl @@ -11,8 +11,8 @@ compile ( v_flags2 => ["--lint-only"], fails=>1, expect=> -'%Error: t/t_inst_array_bad.v:\d+: Port connection __pinNumber2 as part of a module instance array requires 1 or 8 bits, but connection\'s VARREF generates 9 bits. -%Error: Exiting due to.*', +q{%Error: t/t_inst_array_bad.v:\d+: Port connection __pinNumber2 as part of a module instance array requires 1 or 8 bits, but connection's VARREF 'onebitbad' generates 9 bits. +%Error: Exiting due to.*}, ); ok(1); diff --git a/test_regress/t/t_inst_overwide_bad.pl b/test_regress/t/t_inst_overwide_bad.pl index d9c4fa0d9..d469afe72 100755 --- a/test_regress/t/t_inst_overwide_bad.pl +++ b/test_regress/t/t_inst_overwide_bad.pl @@ -16,12 +16,12 @@ compile ( verilator_make_gcc=>0, fails=>$Self->{v3}, expect=> -'%Warning-WIDTH: t/t_inst_overwide.v:\d+: Output port connection outy_w92 expects 92 bits but connection\'s VARREF generates 30 bits. +q{%Warning-WIDTH: t/t_inst_overwide.v:\d+: Output port connection outy_w92 expects 92 bits but connection's VARREF 'outc_w30' generates 30 bits. %Warning-WIDTH: Use .* to disable this message. -%Warning-WIDTH: t/t_inst_overwide.v:\d+: Output port connection outz_w22 expects 22 bits but connection\'s VARREF generates 73 bits. -%Warning-WIDTH: t/t_inst_overwide.v:\d+: Input port connection inw_w31 expects 31 bits but connection\'s VARREF generates 1 bits. -%Warning-WIDTH: t/t_inst_overwide.v:\d+: Input port connection inx_w11 expects 11 bits but connection\'s VARREF generates 61 bits. -%Error: Exiting due to.*', +%Warning-WIDTH: t/t_inst_overwide.v:\d+: Output port connection outz_w22 expects 22 bits but connection's VARREF 'outd_w73' generates 73 bits. +%Warning-WIDTH: t/t_inst_overwide.v:\d+: Input port connection inw_w31 expects 31 bits but connection's VARREF 'ina_w1' generates 1 bits. +%Warning-WIDTH: t/t_inst_overwide.v:\d+: Input port connection inx_w11 expects 11 bits but connection's VARREF 'inb_w61' generates 61 bits. +%Error: Exiting due to.*}, ); ok(1); diff --git a/test_regress/t/t_lint_restore_bad.pl b/test_regress/t/t_lint_restore_bad.pl index e3b44b8bc..9bd82eec2 100755 --- a/test_regress/t/t_lint_restore_bad.pl +++ b/test_regress/t/t_lint_restore_bad.pl @@ -11,9 +11,9 @@ compile ( v_flags2 => ["--lint-only"], fails=>1, expect=> -'.*%Warning-WIDTH: t/t_lint_restore_bad.v:\d+: Operator ASSIGN expects 5 bits on the Assign RHS, but Assign RHS\'s CONST generates 64 bits. +q{.*%Warning-WIDTH: t/t_lint_restore_bad.v:\d+: Operator ASSIGN expects 5 bits on the Assign RHS, but Assign RHS's CONST '64'h1' generates 64 bits. %Warning-WIDTH: Use .* -%Error: Exiting due to.*', +%Error: Exiting due to.*}, ) if $Self->{v3}; ok(1);