From c8a945f3633bedd00a19fde83a0e683f50d29841 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 6 Apr 2025 23:13:24 -0400 Subject: [PATCH] Internals: Minor refactoring of checker parsing/tests. No functional change. --- src/V3CCtors.cpp | 4 +- src/V3Descope.cpp | 6 +-- src/verilog.y | 18 +++++--- test_regress/t/t_checker.out | 38 ---------------- test_regress/t/t_checker_unsup.out | 44 +++++++++++++++++++ .../t/{t_checker.py => t_checker_unsup.py} | 0 .../t/{t_checker.v => t_checker_unsup.v} | 8 ++++ test_regress/t/t_func_dotted_inl0.py | 8 ++-- 8 files changed, 72 insertions(+), 54 deletions(-) delete mode 100644 test_regress/t/t_checker.out create mode 100644 test_regress/t/t_checker_unsup.out rename test_regress/t/{t_checker.py => t_checker_unsup.py} (100%) rename test_regress/t/{t_checker.v => t_checker_unsup.v} (93%) diff --git a/src/V3CCtors.cpp b/src/V3CCtors.cpp index 566846f17..101841229 100644 --- a/src/V3CCtors.cpp +++ b/src/V3CCtors.cpp @@ -114,7 +114,7 @@ public: callp->argTypes("vlSymsp"); } else { if (m_type.isCoverage()) callp->argTypes("first"); - callp->selfPointer(VSelfPointerText{VSelfPointerText::This()}); + callp->selfPointer(VSelfPointerText{VSelfPointerText::This{}}); } rootFuncp->addStmtsp(callp->makeStmt()); } @@ -235,7 +235,7 @@ void V3CCtors::evalAsserts() { // if (signal & CONST(upper_non_clean_mask)) { fail; } AstVarRef* const vrefp = new AstVarRef{varp->fileline(), varp, VAccess::READ}; - vrefp->selfPointer(VSelfPointerText{VSelfPointerText::This()}); + vrefp->selfPointer(VSelfPointerText{VSelfPointerText::This{}}); AstNodeExpr* newp = vrefp; if (varp->isWide()) { newp = new AstWordSel{ diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index 867426dea..aa861f690 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -74,7 +74,7 @@ class DescopeVisitor final : public VNVisitor { string name = scopep->name(); string::size_type pos; if ((pos = name.rfind('.')) != string::npos) name.erase(0, pos + 1); - ret.thisPtr = VSelfPointerText{VSelfPointerText::This(), name}; + ret.thisPtr = VSelfPointerText{VSelfPointerText::This{}, name}; } return ret.thisPtr; } @@ -104,9 +104,9 @@ class DescopeVisitor final : public VNVisitor { if (VN_IS(scopep->modp(), Class)) { // Direct reference to class members are from within the class itself, references from // outside the class must go via AstMemberSel - return VSelfPointerText{VSelfPointerText::This()}; + return VSelfPointerText{VSelfPointerText::This{}}; } else if (relativeRefOk && scopep == m_scopep) { - return VSelfPointerText{VSelfPointerText::This()}; + return VSelfPointerText{VSelfPointerText::This{}}; } else if (relativeRefOk && !m_modSingleton && scopep->aboveScopep() == m_scopep && VN_IS(scopep->modp(), Module)) { // Reference to scope of instance directly under this module, can just "this->cell", diff --git a/src/verilog.y b/src/verilog.y index bc7c2586b..37de26266 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -1496,7 +1496,7 @@ list_of_ports: // IEEE: list_of_ports + list_of_port_declaratio portAndTagE: /* empty */ - { int p = PINNUMINC(); + { const int p = PINNUMINC(); const string name = "__pinNumber" + cvtToStr(p); $$ = new AstPort{CRELINE(), p, name}; AstVar* varp = new AstVar{CRELINE(), VVarType::WIRE, name, VFlagChildDType{}, @@ -6304,22 +6304,26 @@ property_port_item: // IEEE: property_port_item/sequence_port_item // // id {variable_dimension} [ '=' property_actual_arg ] // // seq IEEE: [ yLOCAL [ sequence_lvar_port_direction ] ] sequence_formal_type // // id {variable_dimension} [ '=' sequence_actual_arg ] - property_port_itemFront property_port_itemAssignment { $$ = $2; } + property_port_itemFront property_port_itemAssignment { $$ = $2; } ; property_port_itemFront: // IEEE: part of property_port_item/sequence_port_item - property_port_itemDirE property_formal_typeNoDt { VARDTYPE($2); } + property_port_itemDirE property_formal_typeNoDt + { VARDTYPE($2); } // // data_type_or_implicit | property_port_itemDirE data_type { VARDTYPE($2); GRAMMARP->m_typedPropertyPort = true; } | property_port_itemDirE yVAR data_type { VARDTYPE($3); GRAMMARP->m_typedPropertyPort = true; } - | property_port_itemDirE yVAR implicit_typeE { VARDTYPE($3); } - | property_port_itemDirE implicit_typeE { VARDTYPE($2); } + | property_port_itemDirE yVAR implicit_typeE + { VARDTYPE($3); } + | property_port_itemDirE implicit_typeE + { VARDTYPE($2); } ; property_port_itemAssignment: // IEEE: part of property_port_item/sequence_port_item/checker_port_direction - id variable_dimensionListE { $$ = VARDONEA($1, *$1, $2, nullptr); } + id variable_dimensionListE + { $$ = VARDONEA($1, *$1, $2, nullptr); } | id variable_dimensionListE '=' property_actual_arg { $$ = VARDONEA($1, *$1, $2, $4); BBUNSUP($3, "Unsupported: property variable default value"); } @@ -7128,7 +7132,7 @@ rs_case_item: // ==IEEE: rs_case_item //********************************************************************** // Checker -checker_declaration: // ==IEEE: part of checker_declaration +checker_declaration: // ==IEEE: part of checker_declaration checkerFront checker_port_listE ';' checker_or_generate_itemListE yENDCHECKER endLabelE { $$ = $1; diff --git a/test_regress/t/t_checker.out b/test_regress/t/t_checker.out deleted file mode 100644 index b64cf2a82..000000000 --- a/test_regress/t/t_checker.out +++ /dev/null @@ -1,38 +0,0 @@ -%Error-UNSUPPORTED: t/t_checker.v:33:1: Unsupported: checker - 33 | checker Chk - | ^~~~~~~ - ... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest -%Error-UNSUPPORTED: t/t_checker.v:36:8: Unsupported: checker data declaration - 36 | bit clk; - | ^~~ -%Error-UNSUPPORTED: t/t_checker.v:37:8: Unsupported: checker data declaration - 37 | bit in; - | ^~ -%Error-UNSUPPORTED: t/t_checker.v:38:8: Unsupported: checker data declaration - 38 | bit rst; - | ^~~ -%Error-UNSUPPORTED: t/t_checker.v:39:4: Unsupported: checker rand - 39 | rand bit randed; - | ^~~~ -%Error-UNSUPPORTED: t/t_checker.v:41:8: Unsupported: checker data declaration - 41 | int counter = 0; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_checker.v:43:8: Unsupported: checker data declaration - 43 | int ival; - | ^~~~ -%Error-UNSUPPORTED: t/t_checker.v:53:8: Unsupported: checker data declaration - 53 | int ival2; - | ^~~~~ -%Error-UNSUPPORTED: t/t_checker.v:61:4: Unsupported: checker default clocking - 61 | default clocking clk; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_checker.v:62:4: Unsupported: checker default disable iff - 62 | default disable iff rst; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_checker.v:64:4: Unsupported: checker - 64 | checker ChkChk; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_checker.v:64:12: Unsupported: recursive checker - 64 | checker ChkChk; - | ^~~~~~ -%Error: Exiting due to diff --git a/test_regress/t/t_checker_unsup.out b/test_regress/t/t_checker_unsup.out new file mode 100644 index 000000000..b4bec9b52 --- /dev/null +++ b/test_regress/t/t_checker_unsup.out @@ -0,0 +1,44 @@ +%Error-UNSUPPORTED: t/t_checker_unsup.v:31:4: Unsupported: checker + 31 | checker checker_in_module; + | ^~~~~~~ + ... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest +%Error-UNSUPPORTED: t/t_checker_unsup.v:37:4: Unsupported: checker + 37 | checker checker_in_pkg; + | ^~~~~~~ +%Error-UNSUPPORTED: t/t_checker_unsup.v:41:1: Unsupported: checker + 41 | checker Chk + | ^~~~~~~ +%Error-UNSUPPORTED: t/t_checker_unsup.v:44:8: Unsupported: checker data declaration + 44 | bit clk; + | ^~~ +%Error-UNSUPPORTED: t/t_checker_unsup.v:45:8: Unsupported: checker data declaration + 45 | bit in; + | ^~ +%Error-UNSUPPORTED: t/t_checker_unsup.v:46:8: Unsupported: checker data declaration + 46 | bit rst; + | ^~~ +%Error-UNSUPPORTED: t/t_checker_unsup.v:47:4: Unsupported: checker rand + 47 | rand bit randed; + | ^~~~ +%Error-UNSUPPORTED: t/t_checker_unsup.v:49:8: Unsupported: checker data declaration + 49 | int counter = 0; + | ^~~~~~~ +%Error-UNSUPPORTED: t/t_checker_unsup.v:51:8: Unsupported: checker data declaration + 51 | int ival; + | ^~~~ +%Error-UNSUPPORTED: t/t_checker_unsup.v:61:8: Unsupported: checker data declaration + 61 | int ival2; + | ^~~~~ +%Error-UNSUPPORTED: t/t_checker_unsup.v:69:4: Unsupported: checker default clocking + 69 | default clocking clk; + | ^~~~~~~ +%Error-UNSUPPORTED: t/t_checker_unsup.v:70:4: Unsupported: checker default disable iff + 70 | default disable iff rst; + | ^~~~~~~ +%Error-UNSUPPORTED: t/t_checker_unsup.v:72:4: Unsupported: checker + 72 | checker ChkChk; + | ^~~~~~~ +%Error-UNSUPPORTED: t/t_checker_unsup.v:72:12: Unsupported: recursive checker + 72 | checker ChkChk; + | ^~~~~~ +%Error: Exiting due to diff --git a/test_regress/t/t_checker.py b/test_regress/t/t_checker_unsup.py similarity index 100% rename from test_regress/t/t_checker.py rename to test_regress/t/t_checker_unsup.py diff --git a/test_regress/t/t_checker.v b/test_regress/t/t_checker_unsup.v similarity index 93% rename from test_regress/t/t_checker.v rename to test_regress/t/t_checker_unsup.v index 12ef18bac..fb8c0baa4 100644 --- a/test_regress/t/t_checker.v +++ b/test_regress/t/t_checker_unsup.v @@ -28,8 +28,16 @@ module t(/*AUTOARG*/ Chk check(clk, cyc); + checker checker_in_module; + endchecker + endmodule +package Pkg; + checker checker_in_pkg; + endchecker +endpackage + checker Chk // UNSUP (input clk, int in) ; diff --git a/test_regress/t/t_func_dotted_inl0.py b/test_regress/t/t_func_dotted_inl0.py index 1c461adb2..3c2548ae7 100755 --- a/test_regress/t/t_func_dotted_inl0.py +++ b/test_regress/t/t_func_dotted_inl0.py @@ -19,17 +19,17 @@ test.compile(v_flags2=['--no-json-edit-nums', '+define+ATTRIBUTES', '+define+NOU if test.vlt_all: test.file_grep( out_filename, - r'{"type":"MODULE","name":"ma",.*"loc":"\w,84:[^"]*","origName":"ma",.*,"modPublic":true') + r'{"type":"MODULE","name":"ma",.*"loc":"\w,84:[^"]*",.*"origName":"ma",.*,"modPublic":true') test.file_grep( out_filename, - r'{"type":"MODULE","name":"mb",.*"loc":"\w,99:[^"]*","origName":"mb",.*"modPublic":true') + r'{"type":"MODULE","name":"mb",.*"loc":"\w,99:[^"]*",.*"origName":"mb",.*"modPublic":true') test.file_grep( out_filename, - r'{"type":"MODULE","name":"mc","addr":"[^"]*","loc":"\w,127:[^"]*","origName":"mc",.*"modPublic":true' + r'{"type":"MODULE","name":"mc","addr":"[^"]*","loc":"\w,127:[^"]*",.*"origName":"mc",.*"modPublic":true' ) test.file_grep( out_filename, - r'{"type":"MODULE","name":"mc__PB1","addr":"[^"]*","loc":"\w,127:[^"]*","origName":"mc",.*"modPublic":true' + r'{"type":"MODULE","name":"mc__PB1","addr":"[^"]*","loc":"\w,127:[^"]*",.*"origName":"mc",.*"modPublic":true' ) test.execute()