From 078275034d40b7cdb295fd78ec0958969a38347f Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 11 Oct 2025 10:47:46 -0400 Subject: [PATCH] Internals: Parse randsequence but still unsupported (#6131 partial) --- src/V3AstNodeStmt.h | 128 +++++++- src/V3AstNodes.cpp | 8 + src/V3LinkDot.cpp | 4 - src/V3LinkParse.cpp | 24 ++ src/verilog.y | 93 ++++-- test_regress/t/t_randsequence.out | 367 +--------------------- test_regress/t/t_randsequence_bad.out | 17 +- test_regress/t/t_randsequence_bad.v | 5 + test_regress/t/t_randsequence_recurse.out | 5 + test_regress/t/t_randsequence_recurse.py | 19 ++ test_regress/t/t_randsequence_recurse.v | 33 ++ 11 files changed, 303 insertions(+), 400 deletions(-) create mode 100644 test_regress/t/t_randsequence_recurse.out create mode 100755 test_regress/t/t_randsequence_recurse.py create mode 100644 test_regress/t/t_randsequence_recurse.v diff --git a/src/V3AstNodeStmt.h b/src/V3AstNodeStmt.h index c934fd290..810de333e 100644 --- a/src/V3AstNodeStmt.h +++ b/src/V3AstNodeStmt.h @@ -202,7 +202,7 @@ public: // === AstNode === class AstCaseItem final : public AstNode { - // Single item of AstCase/AstRandCase + // Single item of AstCase/AstRandCase/AstRSCase // @astgen op1 := condsp : List[AstNodeExpr] // @astgen op2 := stmtsp : List[AstNode] public: @@ -771,6 +771,119 @@ public: void timeunit(const VTimescale& flag) { m_timeunit = flag; } VTimescale timeunit() const { return m_timeunit; } }; +class AstRSCase final : public AstNodeStmt { + // Randsequence case statement + // @astgen op1 := exprp : AstNodeExpr // Condition (scurtinee) expression + // @astgen op2 := itemsp : List[AstCaseItem] +public: + AstRSCase(FileLine* fl, AstNodeExpr* exprp, AstCaseItem* itemsp) + : ASTGEN_SUPER_Case(fl) { + this->exprp(exprp); + addItemsp(itemsp); + } + ASTGEN_MEMBERS_AstRSCase; + int instrCount() const override { return INSTR_COUNT_BRANCH; } + bool sameNode(const AstNode* samep) const override { return true; } +}; +class AstRSIf final : public AstNodeStmt { + // Randsequence if + // @astgen op1 := condp : AstNodeExpr + // @astgen op2 := thensp : List[AstNode] + // @astgen op3 := elsesp : List[AstNode] +public: + AstRSIf(FileLine* fl, AstNodeExpr* condp, AstNode* thensp, AstNode* elsesp) + : ASTGEN_SUPER_RSIf(fl) { + this->condp(condp); + addThensp(thensp); + addElsesp(elsesp); + } + +public: + ASTGEN_MEMBERS_AstRSIf; + bool isGateOptimizable() const override { return false; } + bool isGateDedupable() const override { return false; } + int instrCount() const override { return INSTR_COUNT_BRANCH; } + bool sameNode(const AstNode* /*samep*/) const override { return true; } +}; +class AstRSProd final : public AstNodeStmt { + // randomsquence production, under a AstRandSequence + // @astgen op1 := fvarp : Optional[AstVar] + // @astgen op2 := portsp : List[AstNode] + // @astgen op3 := rulesp : List[AstRSRule] + string m_name; // Name of block, or "" to use first production +public: + AstRSProd(FileLine* fl, const string& name, AstNode* portsp, AstRSRule* rulesp) + : ASTGEN_SUPER_RSProd(fl) + , m_name{name} { + addPortsp(portsp); + addRulesp(rulesp); + } + ASTGEN_MEMBERS_AstRSProd; + string name() const override VL_MT_STABLE { return m_name; } + int instrCount() const override { return INSTR_COUNT_BRANCH; } +}; +class AstRSProdItem final : public AstNodeStmt { + // randomsquence production item + // @astgen op1 := argsp : List[AstNodeExpr] + string m_name; // Name of block, or "" to use first production +public: + AstRSProdItem(FileLine* fl, const string& name, AstNodeExpr* argsp) + : ASTGEN_SUPER_RSProdItem(fl) + , m_name{name} { + addArgsp(argsp); + } + ASTGEN_MEMBERS_AstRSProdItem; + string name() const override VL_MT_STABLE { return m_name; } + int instrCount() const override { return INSTR_COUNT_BRANCH; } +}; +class AstRSProdList final : public AstNodeStmt { + // randomsquence production list + // @astgen op1 := weightp : Optional[AstNodeExpr] + // @astgen op2 := prodsp : List[AstNode] + bool m_randJoin = false; // Is rand join'ed +public: + AstRSProdList(FileLine* fl, AstNodeExpr* weightp, AstNode* prodsp) + : ASTGEN_SUPER_RSProdList(fl) { + this->weightp(weightp); + addProdsp(prodsp); + } + ASTGEN_MEMBERS_AstRSProdList; + void dump(std::ostream& str) const override; + void dumpJson(std::ostream& str) const override; + int instrCount() const override { return INSTR_COUNT_BRANCH; } + bool randJoin() const { return m_randJoin; } + void randJoin(bool flag) { m_randJoin = flag; } +}; +class AstRSRepeat final : public AstNodeStmt { + // randsequence repeat + // @astgen op1 := countp : AstNodeExpr + // @astgen op2 := stmtsp : List[AstNode] +public: + AstRSRepeat(FileLine* fl, AstNodeExpr* countp, AstNode* stmtsp) + : ASTGEN_SUPER_RSRepeat(fl) { + this->countp(countp); + addStmtsp(stmtsp); + } + ASTGEN_MEMBERS_AstRSRepeat; + bool isGateOptimizable() const override { return false; } + int instrCount() const override { return INSTR_COUNT_BRANCH; } + bool sameNode(const AstNode* /*samep*/) const override { return true; } +}; +class AstRSRule final : public AstNodeStmt { + // randomsquence rule + // @astgen op1 := weightp : Optional[AstNodeExpr] + // @astgen op2 := prodlistsp : List[AstRSProdList] + // @astgen op3 := stmtsp : List[AstNode] +public: + AstRSRule(FileLine* fl, AstNodeExpr* weightp, AstRSProdList* prodlistsp, AstNode* stmtsp) + : ASTGEN_SUPER_RSRule(fl) { + this->weightp(weightp); + addProdlistsp(prodlistsp); + addStmtsp(stmtsp); + } + ASTGEN_MEMBERS_AstRSRule; + int instrCount() const override { return INSTR_COUNT_BRANCH; } +}; class AstRandCase final : public AstNodeStmt { // @astgen op2 := itemsp : List[AstCaseItem] public: @@ -781,6 +894,19 @@ public: ASTGEN_MEMBERS_AstRandCase; int instrCount() const override { return INSTR_COUNT_BRANCH; } }; +class AstRandSequence final : public AstNodeStmt { + // @astgen op2 := prodsp : List[AstRSProd] + string m_name; // Name of block, or "" to use first production +public: + AstRandSequence(FileLine* fl, const string& name, AstRSProd* prodsp) + : ASTGEN_SUPER_RandSequence(fl) + , m_name{name} { + addProdsp(prodsp); + } + ASTGEN_MEMBERS_AstRandSequence; + string name() const override VL_MT_STABLE { return m_name; } // * = Block name + int instrCount() const override { return INSTR_COUNT_BRANCH; } +}; class AstRelease final : public AstNodeStmt { // Procedural 'release' statement // @astgen op1 := lhsp : AstNodeExpr diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 270a8c44f..250fb1600 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -2256,6 +2256,14 @@ void AstRange::dump(std::ostream& str) const { if (fromBracket()) str << " [FB]"; if (ascending()) str << " [ASCENDING]"; } +void AstRSProdList::dumpJson(std::ostream& str) const { + dumpJsonBoolFunc(str, randJoin); + dumpJsonGen(str); +} +void AstRSProdList::dump(std::ostream& str) const { + this->AstNode::dump(str); + if (randJoin()) str << " [RANDJOIN]"; +} void AstRange::dumpJson(std::ostream& str) const { dumpJsonBoolFunc(str, ascending); dumpJsonBoolFunc(str, fromBracket); diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 2a227a2ec..4a849d6e5 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -80,10 +80,6 @@ VL_DEFINE_DEBUG_FUNCTIONS; // ###################################################################### // Matcher classes (for suggestion matching) -class LinkNodeMatcherClass final : public VNodeMatcher { -public: - bool nodeMatch(const AstNode* nodep) const override { return VN_IS(nodep, Class); } -}; class LinkNodeMatcherClassOrPackage final : public VNodeMatcher { public: bool nodeMatch(const AstNode* nodep) const override { diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 32850290d..02ebe5f5b 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -584,6 +584,30 @@ class LinkParseVisitor final : public VNVisitor { } iterateChildren(nodep); } + void visit(AstRandSequence* nodep) override { + cleanFileline(nodep); + nodep->v3warn(E_UNSUPPORTED, "Unsupported: randsequence"); + iterateChildren(nodep); + VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); + } + void visit(AstRSCase* nodep) override { + cleanFileline(nodep); + nodep->v3warn(E_UNSUPPORTED, "Unsupported: randsequence case"); + iterateChildren(nodep); + VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); + } + void visit(AstRSIf* nodep) override { + cleanFileline(nodep); + nodep->v3warn(E_UNSUPPORTED, "Unsupported: randsequence if"); + iterateChildren(nodep); + VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); + } + void visit(AstRSRepeat* nodep) override { + cleanFileline(nodep); + nodep->v3warn(E_UNSUPPORTED, "Unsupported: randsequence repeat"); + iterateChildren(nodep); + VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); + } void visit(AstWait* nodep) override { cleanFileline(nodep); iterateChildren(nodep); diff --git a/src/verilog.y b/src/verilog.y index ffc3ff35e..011a04cd5 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -993,6 +993,11 @@ BISONPRE_VERSION(3.7,%define api.header.include {"V3ParseBison.h"}) // Blank lines for type insertion // Blank lines for type insertion // Blank lines for type insertion +// Blank lines for type insertion +// Blank lines for type insertion +// Blank lines for type insertion +// Blank lines for type insertion +// Blank lines for type insertion %start source_text @@ -7038,46 +7043,76 @@ hierarchical_btf_identifier: // ==IEEE: hierarchical_btf_identifier randsequence_statement: // ==IEEE: randsequence_statement yRANDSEQUENCE '(' ')' rs_productionList yENDSEQUENCE - { $$ = nullptr; BBUNSUP($1, "Unsupported: randsequence"); DEL($4); } + { $$ = new AstRandSequence{$1, "", $4}; } | yRANDSEQUENCE '(' idAny/*rs_production_identifier*/ ')' rs_productionList yENDSEQUENCE - { $$ = nullptr; BBUNSUP($1, "Unsupported: randsequence"); DEL($5); } + { $$ = new AstRandSequence{$1, *$3, $5}; } ; -rs_productionList: // IEEE: rs_production+ +rs_productionList: // IEEE: rs_production+ rs_production { $$ = $1; } | rs_productionList rs_production { $$ = addNextNull($1, $2); } ; -rs_production: // ==IEEE: rs_production +rs_production: // ==IEEE: rs_production rs_productionFront ':' rs_ruleList ';' - { // TODO makes a function, probably want a new Ast type instead - $$ = nullptr; BBUNSUP($2, "Unsupported: randsequence production"); DEL($1, $3); } + { $$ = $1; $1->addRulesp($3); } ; -rs_productionFront: // IEEE: part of rs_production - funcId/*production_identifier*/ { $$ = $1; } - | funcId '(' tf_port_listE ')' { $$ = $1; $$->addStmtsp($3); } +rs_productionFront: // IEEE: part of rs_production + rs_funcId/*rs_production_identifier*/ { $$ = $1; } + | rs_funcId '(' tf_port_listE ')' { $$ = $1; $$->addPortsp($3); } ; -rs_ruleList: // IEEE: rs_rule+ part of rs_production +rs_funcId: // IEEE: part of rs_production + /**/ rs_fId + { $$ = $1; } // Note is void as default, not logic as default like functions + | signingE rangeList rs_fId + { $$ = $3; + $$->fvarp(new AstVar{$1, VVarType::PORT, $3->name(), VFlagChildDType{}, + GRAMMARP->addRange(new AstBasicDType{$3, LOGIC_IMPLICIT, $1}, $2, true)}); } + | signing rs_fId + { $$ = $2; + $$->fvarp(new AstVar{$1, VVarType::PORT, $2->name(), VFlagChildDType{}, + new AstBasicDType{$2, LOGIC_IMPLICIT, $1}}); } + | data_type rs_fId + { $$ = $2; + $$->fvarp(new AstVar{$1, VVarType::PORT, $2->name(), VFlagChildDType{}, + $1}); } + | yVOID rs_fId + { $$ = $2; } + ; + +rs_fId: // IEEE: part of rs_production + id + { $$ = $1; + $$ = new AstRSProd{$$, *$1, nullptr, nullptr}; } + ; + +rs_ruleList: // IEEE: rs_rule+ part of rs_production rs_rule { $$ = $1; } | rs_ruleList '|' rs_rule { $$ = addNextNull($1, $3); } ; -rs_rule: // ==IEEE: rs_rule - rs_production_list { $$ = $1; } +rs_rule: // ==IEEE: rs_rule + rs_production_list + { $$ = new AstRSRule{$1->fileline(), nullptr, $1, nullptr}; } | rs_production_list yP_COLONEQ rs_weight_specification - { $$ = nullptr; BBUNSUP($1, "Unsupported: randsequence rule"); DEL($1, $3); } + { $$ = new AstRSRule{$1->fileline(), $3, $1, nullptr}; } | rs_production_list yP_COLONEQ rs_weight_specification rs_code_block - { $$ = nullptr; BBUNSUP($1, "Unsupported: randsequence rule"); DEL($1, $3, $4); } + { $$ = new AstRSRule{$1->fileline(), $3, $1, $4}; } ; -rs_production_list: // ==IEEE: rs_production_list - rs_prodList { $$ = $1; } +rs_production_list: // ==IEEE: rs_production_list + rs_prodList + { $$ = new AstRSProdList{CRELINE(), nullptr, $1}; } | yRAND yJOIN rs_production_item rs_production_itemList - { $$ = nullptr; BBUNSUP($1, "Unsupported: randsequence production list"); DEL($3, $4); } + { $$ = new AstRSProdList{$1, new AstConst{$2, AstConst::RealDouble{}, 0.5}, $3}; + $$->randJoin(true); + $$->addProdsp($4); } | yRAND yJOIN '(' expr ')' rs_production_item rs_production_itemList - { $$ = nullptr; BBUNSUP($1, "Unsupported: randsequence production list"); DEL($4, $6, $7); } + { $$ = new AstRSProdList{$1, $4, $6}; + $$->randJoin(true); + $$->addProdsp($7); } ; rs_weight_specification: // ==IEEE: rs_weight_specification @@ -7111,15 +7146,15 @@ rs_prod: // ==IEEE: rs_prod | rs_code_block { $$ = $1; } // // IEEE: rs_if_else | yIF '(' expr ')' rs_production_item %prec prLOWER_THAN_ELSE - { $$ = nullptr; BBUNSUP($1, "Unsupported: randsequence if"); DEL($3, $5); } + { $$ = new AstRSIf{$1, $3, $5, nullptr}; } | yIF '(' expr ')' rs_production_item yELSE rs_production_item - { $$ = nullptr; BBUNSUP($1, "Unsupported: randsequence if"); DEL($3, $5, $7); } + { $$ = new AstRSIf{$1, $3, $5, $7}; } // // IEEE: rs_repeat | yREPEAT '(' expr ')' rs_production_item - { $$ = nullptr; BBUNSUP($1, "Unsupported: randsequence repeat"); DEL($3, $5); } + { $$ = new AstRSRepeat{$1, $3, $5}; } // // IEEE: rs_case | yCASE '(' expr ')' rs_case_itemList yENDCASE - { $$ = nullptr; BBUNSUP($1, "Unsupported: randsequence case"); DEL($3, $5); } + { $$ = new AstRSCase{$1, $3, $5}; } ; rs_production_itemList: // IEEE: rs_production_item+ @@ -7129,23 +7164,23 @@ rs_production_itemList: // IEEE: rs_production_item+ rs_production_item: // ==IEEE: rs_production_item idAny/*production_identifier*/ - { $$ = nullptr; BBUNSUP($1, "Unsupported: randsequence production id"); } + { $$ = new AstRSProdItem{$1, *$1, nullptr}; } | idAny/*production_identifier*/ '(' list_of_argumentsE ')' - { $$ = nullptr; BBUNSUP($1, "Unsupported: randsequence production id"); DEL($3); } + { $$ = new AstRSProdItem{$1, *$1, $3}; } ; -rs_case_itemList: // IEEE: rs_case_item+ +rs_case_itemList: // IEEE: rs_case_item+ rs_case_item { $$ = $1; } | rs_case_itemList rs_case_item { $$ = addNextNull($1, $2); } ; -rs_case_item: // ==IEEE: rs_case_item +rs_case_item: // ==IEEE: rs_case_item caseCondList ':' rs_production_item ';' - { $$ = nullptr; BBUNSUP($2, "Unsupported: randsequence case item"); DEL($1, $3); } + { $$ = new AstCaseItem{$1, $1, $3}; } | yDEFAULT rs_production_item ';' - { $$ = nullptr; BBUNSUP($1, "Unsupported: randsequence case item"); DEL($2); } + { $$ = new AstCaseItem{$1, nullptr, $2}; } | yDEFAULT ':' rs_production_item ';' - { $$ = nullptr; BBUNSUP($1, "Unsupported: randsequence case item"); DEL($3); } + { $$ = new AstCaseItem{$1, nullptr, $3}; } ; //********************************************************************** diff --git a/test_regress/t/t_randsequence.out b/test_regress/t/t_randsequence.out index ea6be47a9..51c2f290f 100644 --- a/test_regress/t/t_randsequence.out +++ b/test_regress/t/t_randsequence.out @@ -1,397 +1,58 @@ -%Error-UNSUPPORTED: t/t_randsequence.v:24:17: Unsupported: randsequence production id - 24 | main : one; - | ^~~ - ... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest -%Error-UNSUPPORTED: t/t_randsequence.v:24:15: Unsupported: randsequence production - 24 | main : one; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:25:14: Unsupported: randsequence production - 25 | one : { o = 1; }; - | ^ %Error-UNSUPPORTED: t/t_randsequence.v:23:7: Unsupported: randsequence 23 | randsequence(main) | ^~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:41:16: Unsupported: randsequence production id - 41 | main: one two three; - | ^~~ -%Error-UNSUPPORTED: t/t_randsequence.v:41:20: Unsupported: randsequence production id - 41 | main: one two three; - | ^~~ -%Error-UNSUPPORTED: t/t_randsequence.v:41:24: Unsupported: randsequence production id - 41 | main: one two three; - | ^~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:41:14: Unsupported: randsequence production - 41 | main: one two three; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:42:13: Unsupported: randsequence production - 42 | two: { do if ((seq) !== (1)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", "t/t_randsequence.v",42, (seq), (1)); $stop; end while(0);; seq = 2; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:43:13: Unsupported: randsequence production - 43 | one: { do if ((seq) !== (0)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", "t/t_randsequence.v",43, (seq), (0)); $stop; end while(0);; seq = 1; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:44:15: Unsupported: randsequence production - 44 | three: { do if ((seq) !== (2)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", "t/t_randsequence.v",44, (seq), (2)); $stop; end while(0);; seq = 3; }; - | ^ + ... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest %Error-UNSUPPORTED: t/t_randsequence.v:40:7: Unsupported: randsequence 40 | randsequence(main) | ^~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:52:17: Unsupported: randsequence production - 52 | unnamed: { seq = 2; }; - | ^ %Error-UNSUPPORTED: t/t_randsequence.v:51:7: Unsupported: randsequence 51 | randsequence() | ^~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:59:17: Unsupported: randsequence production - 59 | unnamed: { }; - | ^ %Error-UNSUPPORTED: t/t_randsequence.v:58:7: Unsupported: randsequence 58 | randsequence() | ^~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:66:19: Unsupported: randsequence production id - 66 | main: one | two | three := 2; - | ^~~ -%Error-UNSUPPORTED: t/t_randsequence.v:66:25: Unsupported: randsequence production id - 66 | main: one | two | three := 2; - | ^~~ -%Error-UNSUPPORTED: t/t_randsequence.v:66:31: Unsupported: randsequence production id - 66 | main: one | two | three := 2; - | ^~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:66:31: Unsupported: randsequence rule - 66 | main: one | two | three := 2; - | ^~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:66:17: Unsupported: randsequence production - 66 | main: one | two | three := 2; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:67:16: Unsupported: randsequence production - 67 | one: { ++counts[0]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:68:16: Unsupported: randsequence production - 68 | two: { ++counts[1]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:69:18: Unsupported: randsequence production - 69 | three: { ++counts[2]; }; - | ^ %Error-UNSUPPORTED: t/t_randsequence.v:65:10: Unsupported: randsequence 65 | randsequence(main) | ^~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:80:19: Unsupported: randsequence production id - 80 | main: one_if; - | ^~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:80:17: Unsupported: randsequence production - 80 | main: one_if; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:81:38: Unsupported: randsequence production id - 81 | one_if: if (i % 10 == 0) count_1 else most; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:81:51: Unsupported: randsequence production id - 81 | one_if: if (i % 10 == 0) count_1 else most; - | ^~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:81:21: Unsupported: randsequence if - 81 | one_if: if (i % 10 == 0) count_1 else most; - | ^~ -%Error-UNSUPPORTED: t/t_randsequence.v:81:19: Unsupported: randsequence production - 81 | one_if: if (i % 10 == 0) count_1 else most; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:82:20: Unsupported: randsequence production - 82 | count_1: { ++counts[1]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:83:20: Unsupported: randsequence production - 83 | count_2: { ++counts[2]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:84:20: Unsupported: randsequence production - 84 | count_3: { ++counts[3]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:85:20: Unsupported: randsequence production - 85 | count_4: { ++counts[4]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:86:16: Unsupported: randsequence production - 86 | bad: { $stop; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:88:24: Unsupported: randsequence production id - 88 | 0: bad; - | ^~~ -%Error-UNSUPPORTED: t/t_randsequence.v:88:22: Unsupported: randsequence case item - 88 | 0: bad; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:89:27: Unsupported: randsequence production id - 89 | 1, 2: count_2; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:89:25: Unsupported: randsequence case item - 89 | 1, 2: count_2; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:90:30: Unsupported: randsequence production id - 90 | 3, 4, 5: count_3; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:90:28: Unsupported: randsequence case item - 90 | 3, 4, 5: count_3; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:91:30: Unsupported: randsequence production id - 91 | default: count_4; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:91:21: Unsupported: randsequence case item - 91 | default: count_4; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:87:19: Unsupported: randsequence case - 87 | most: case (i % 10) - | ^~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:87:17: Unsupported: randsequence production - 87 | most: case (i % 10) - | ^ %Error-UNSUPPORTED: t/t_randsequence.v:79:10: Unsupported: randsequence 79 | randsequence(main) | ^~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:104:19: Unsupported: randsequence production id - 104 | main: one_if; - | ^~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:104:17: Unsupported: randsequence production - 104 | main: one_if; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:105:38: Unsupported: randsequence production id - 105 | one_if: if (i % 10 == 0) count_1 else most; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:105:51: Unsupported: randsequence production id - 105 | one_if: if (i % 10 == 0) count_1 else most; - | ^~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:105:21: Unsupported: randsequence if - 105 | one_if: if (i % 10 == 0) count_1 else most; +%Error-UNSUPPORTED: t/t_randsequence.v:81:21: Unsupported: randsequence if + 81 | one_if: if (i % 10 == 0) count_1 else most; | ^~ -%Error-UNSUPPORTED: t/t_randsequence.v:105:19: Unsupported: randsequence production - 105 | one_if: if (i % 10 == 0) count_1 else most; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:106:20: Unsupported: randsequence production - 106 | count_1: { ++counts[1]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:107:20: Unsupported: randsequence production - 107 | count_2: { ++counts[2]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:108:20: Unsupported: randsequence production - 108 | count_3: { ++counts[3]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:109:20: Unsupported: randsequence production - 109 | count_4: { ++counts[4]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:110:16: Unsupported: randsequence production - 110 | bad: { $stop; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:112:24: Unsupported: randsequence production id - 112 | 0: bad; - | ^~~ -%Error-UNSUPPORTED: t/t_randsequence.v:112:22: Unsupported: randsequence case item - 112 | 0: bad; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:113:27: Unsupported: randsequence production id - 113 | 1, 2: count_2; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:113:25: Unsupported: randsequence case item - 113 | 1, 2: count_2; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:114:30: Unsupported: randsequence production id - 114 | 3, 4, 5: count_3; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:114:28: Unsupported: randsequence case item - 114 | 3, 4, 5: count_3; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:115:29: Unsupported: randsequence production id - 115 | default count_4; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:115:21: Unsupported: randsequence case item - 115 | default count_4; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:111:19: Unsupported: randsequence case - 111 | most: case (i % 10) +%Error-UNSUPPORTED: t/t_randsequence.v:87:19: Unsupported: randsequence case + 87 | most: case (i % 10) | ^~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:111:17: Unsupported: randsequence production - 111 | most: case (i % 10) - | ^ %Error-UNSUPPORTED: t/t_randsequence.v:103:10: Unsupported: randsequence 103 | randsequence(main) | ^~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:127:27: Unsupported: randsequence production id - 127 | main: repeat(10) count_1; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:127:16: Unsupported: randsequence repeat - 127 | main: repeat(10) count_1; - | ^~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:127:14: Unsupported: randsequence production - 127 | main: repeat(10) count_1; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:128:17: Unsupported: randsequence production - 128 | count_1: { ++counts[1]; }; - | ^ +%Error-UNSUPPORTED: t/t_randsequence.v:105:21: Unsupported: randsequence if + 105 | one_if: if (i % 10 == 0) count_1 else most; + | ^~ +%Error-UNSUPPORTED: t/t_randsequence.v:111:19: Unsupported: randsequence case + 111 | most: case (i % 10) + | ^~~~ %Error-UNSUPPORTED: t/t_randsequence.v:126:7: Unsupported: randsequence 126 | randsequence(main) | ^~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:136:29: Unsupported: randsequence production id - 136 | main: rand join count_1 count_2; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:136:37: Unsupported: randsequence production id - 136 | main: rand join count_1 count_2; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:136:19: Unsupported: randsequence production list - 136 | main: rand join count_1 count_2; - | ^~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:136:17: Unsupported: randsequence production - 136 | main: rand join count_1 count_2; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:137:20: Unsupported: randsequence production - 137 | count_1: { ++counts[1]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:138:20: Unsupported: randsequence production - 138 | count_2: { ++counts[2]; }; - | ^ +%Error-UNSUPPORTED: t/t_randsequence.v:127:16: Unsupported: randsequence repeat + 127 | main: repeat(10) count_1; + | ^~~~~~ %Error-UNSUPPORTED: t/t_randsequence.v:135:10: Unsupported: randsequence 135 | randsequence(main) | ^~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:148:35: Unsupported: randsequence production id - 148 | main: rand join (1.0) count_1 count_2; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:148:43: Unsupported: randsequence production id - 148 | main: rand join (1.0) count_1 count_2; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:148:19: Unsupported: randsequence production list - 148 | main: rand join (1.0) count_1 count_2; - | ^~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:148:17: Unsupported: randsequence production - 148 | main: rand join (1.0) count_1 count_2; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:149:20: Unsupported: randsequence production - 149 | count_1: { ++counts[1]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:150:20: Unsupported: randsequence production - 150 | count_2: { ++counts[2]; }; - | ^ %Error-UNSUPPORTED: t/t_randsequence.v:147:10: Unsupported: randsequence 147 | randsequence(main) | ^~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:153:35: Unsupported: randsequence production id - 153 | main: rand join (0.0) count_3 count_4; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:153:43: Unsupported: randsequence production id - 153 | main: rand join (0.0) count_3 count_4; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:153:19: Unsupported: randsequence production list - 153 | main: rand join (0.0) count_3 count_4; - | ^~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:153:17: Unsupported: randsequence production - 153 | main: rand join (0.0) count_3 count_4; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:154:20: Unsupported: randsequence production - 154 | count_3: { ++counts[3]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:155:20: Unsupported: randsequence production - 155 | count_4: { ++counts[4]; }; - | ^ %Error-UNSUPPORTED: t/t_randsequence.v:152:10: Unsupported: randsequence 152 | randsequence(main) | ^~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:168:19: Unsupported: randsequence production id - 168 | main: count_1 check count_2; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:168:27: Unsupported: randsequence production id - 168 | main: count_1 check count_2; - | ^~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:168:33: Unsupported: randsequence production id - 168 | main: count_1 check count_2; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:168:17: Unsupported: randsequence production - 168 | main: count_1 check count_2; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:169:20: Unsupported: randsequence production id - 169 | check: count_3 { if (fiftyfifty) break; } count_4; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:169:55: Unsupported: randsequence production id - 169 | check: count_3 { if (fiftyfifty) break; } count_4; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:169:18: Unsupported: randsequence production - 169 | check: count_3 { if (fiftyfifty) break; } count_4; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:170:20: Unsupported: randsequence production - 170 | count_1: { ++counts[1]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:171:20: Unsupported: randsequence production - 171 | count_2: { ++counts[2]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:172:20: Unsupported: randsequence production - 172 | count_3: { ++counts[3]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:173:20: Unsupported: randsequence production - 173 | count_4: { ++counts[4]; }; - | ^ %Error-UNSUPPORTED: t/t_randsequence.v:167:10: Unsupported: randsequence 167 | randsequence(main) | ^~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:186:19: Unsupported: randsequence production id - 186 | main: count_1 check count_2; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:186:27: Unsupported: randsequence production id - 186 | main: count_1 check count_2; - | ^~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:186:33: Unsupported: randsequence production id - 186 | main: count_1 check count_2; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:186:17: Unsupported: randsequence production - 186 | main: count_1 check count_2; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:187:20: Unsupported: randsequence production id - 187 | check: count_3 { if (fiftyfifty) return; } count_4; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:187:56: Unsupported: randsequence production id - 187 | check: count_3 { if (fiftyfifty) return; } count_4; - | ^~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:187:18: Unsupported: randsequence production - 187 | check: count_3 { if (fiftyfifty) return; } count_4; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:188:20: Unsupported: randsequence production - 188 | count_1: { ++counts[1]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:189:20: Unsupported: randsequence production - 189 | count_2: { ++counts[2]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:190:20: Unsupported: randsequence production - 190 | count_3: { ++counts[3]; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:191:20: Unsupported: randsequence production - 191 | count_4: { ++counts[4]; }; - | ^ %Error-UNSUPPORTED: t/t_randsequence.v:185:10: Unsupported: randsequence 185 | randsequence(main) | ^~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:203:19: Unsupported: randsequence production id - 203 | main: f_1 f_2 f_3; - | ^~~ -%Error-UNSUPPORTED: t/t_randsequence.v:203:23: Unsupported: randsequence production id - 203 | main: f_1 f_2 f_3; - | ^~~ -%Error-UNSUPPORTED: t/t_randsequence.v:203:27: Unsupported: randsequence production id - 203 | main: f_1 f_2 f_3; - | ^~~ -%Error-UNSUPPORTED: t/t_randsequence.v:203:17: Unsupported: randsequence production - 203 | main: f_1 f_2 f_3; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:204:19: Unsupported: randsequence production id - 204 | f_1 : func(10); - | ^~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:204:17: Unsupported: randsequence production - 204 | f_1 : func(10); - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:205:19: Unsupported: randsequence production id - 205 | f_2 : func(20); - | ^~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:205:17: Unsupported: randsequence production - 205 | f_2 : func(20); - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:206:19: Unsupported: randsequence production id - 206 | f_3 : fnoarg; - | ^~~~~~ -%Error-UNSUPPORTED: t/t_randsequence.v:206:17: Unsupported: randsequence production - 206 | f_3 : fnoarg; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:207:30: Unsupported: randsequence production - 207 | void func(int n) : { counts[1] += n; }; - | ^ -%Error-UNSUPPORTED: t/t_randsequence.v:208:25: Unsupported: randsequence production - 208 | void fnoarg : { ++counts[2]; }; - | ^ %Error-UNSUPPORTED: t/t_randsequence.v:202:10: Unsupported: randsequence 202 | randsequence(main) | ^~~~~~~~~~~~ diff --git a/test_regress/t/t_randsequence_bad.out b/test_regress/t/t_randsequence_bad.out index 9cc011c04..bf1205d04 100644 --- a/test_regress/t/t_randsequence_bad.out +++ b/test_regress/t/t_randsequence_bad.out @@ -1,20 +1,11 @@ -%Error-UNSUPPORTED: t/t_randsequence_bad.v:13:25: Unsupported: randsequence production - 13 | such_production: { }; - | ^ - ... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest %Error-UNSUPPORTED: t/t_randsequence_bad.v:12:7: Unsupported: randsequence 12 | randsequence(no_such_production) | ^~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence_bad.v:17:16: Unsupported: randsequence production id - 17 | main: production_bad; - | ^~~~~~~~~~~~~~ -%Error-UNSUPPORTED: t/t_randsequence_bad.v:17:14: Unsupported: randsequence production - 17 | main: production_bad; - | ^ -%Error-UNSUPPORTED: t/t_randsequence_bad.v:18:24: Unsupported: randsequence production - 18 | production_baa: {}; - | ^ + ... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest %Error-UNSUPPORTED: t/t_randsequence_bad.v:16:7: Unsupported: randsequence 16 | randsequence(main) | ^~~~~~~~~~~~ +%Error-UNSUPPORTED: t/t_randsequence_bad.v:21:7: Unsupported: randsequence + 21 | randsequence() + | ^~~~~~~~~~~~ %Error: Exiting due to diff --git a/test_regress/t/t_randsequence_bad.v b/test_regress/t/t_randsequence_bad.v index 9d30e6241..e6e5515bc 100644 --- a/test_regress/t/t_randsequence_bad.v +++ b/test_regress/t/t_randsequence_bad.v @@ -18,6 +18,11 @@ module t; production_baa: {}; endsequence + randsequence() + duplicated_bad: { $display("dup1"); }; + duplicated_bad: { $display("dup2"); }; // Bad + endsequence + $write("*-* All Finished *-*\n"); $finish; end diff --git a/test_regress/t/t_randsequence_recurse.out b/test_regress/t/t_randsequence_recurse.out new file mode 100644 index 000000000..82d3e33fe --- /dev/null +++ b/test_regress/t/t_randsequence_recurse.out @@ -0,0 +1,5 @@ +%Error-UNSUPPORTED: t/t_randsequence_recurse.v:21:7: Unsupported: randsequence + 21 | randsequence(main) + | ^~~~~~~~~~~~ + ... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest +%Error: Exiting due to diff --git a/test_regress/t/t_randsequence_recurse.py b/test_regress/t/t_randsequence_recurse.py new file mode 100755 index 000000000..966dc53da --- /dev/null +++ b/test_regress/t/t_randsequence_recurse.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2024 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +import vltest_bootstrap + +test.scenarios('simulator') + +test.compile(fails=test.vlt_all, expect_filename=test.golden_filename) + +if not test.vlt_all: + test.execute() + +test.passes() diff --git a/test_regress/t/t_randsequence_recurse.v b/test_regress/t/t_randsequence_recurse.v new file mode 100644 index 000000000..e645d2b45 --- /dev/null +++ b/test_regress/t/t_randsequence_recurse.v @@ -0,0 +1,33 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// Copyright 2023 by Wilson Snyder. This program is free software; you can +// redistribute it and/or modify it under the terms of either the GNU +// Lesser General Public License Version 3 or the Perl Artistic License +// Version 2.0. +// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +`define stop $stop +`define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d (%s !== %s)\n", `__FILE__,`__LINE__, (gotv), (expv), `"gotv`", `"expv`"); `stop; end while(0); + +module t(/*AUTOARG*/); + + initial begin + + int o; + int i; + o = 0; + i = 0; + + randsequence(main) + main : recurse recurse; + recurse: { i++; if ((i % 4) == 0) break; } add recurse; + add: { o++; } ; + endsequence + + `checkd(o, 3); + + $write("*-* All Finished *-*\n"); + $finish; + end + +endmodule