mirror of
https://github.com/verilator/verilator.git
synced 2026-10-07 02:23:19 +02:00
Support soft foreach in constraint (#8174)
This commit is contained in:
+8
-2
@@ -1675,10 +1675,16 @@ public:
|
||||
// === AstNodeForeach ===
|
||||
class AstConstraintForeach final : public AstNodeForeach {
|
||||
// Constraint foreach statement
|
||||
bool m_soft; // is soft foreach, non-standard extension
|
||||
public:
|
||||
AstConstraintForeach(FileLine* fl, AstForeachHeader* headerp, AstNode* bodyp)
|
||||
: ASTGEN_SUPER_ConstraintForeach(fl, headerp, bodyp) {}
|
||||
AstConstraintForeach(FileLine* fl, AstForeachHeader* headerp, AstNode* bodyp,
|
||||
bool soft = false)
|
||||
: ASTGEN_SUPER_ConstraintForeach(fl, headerp, bodyp)
|
||||
, m_soft{soft} {}
|
||||
ASTGEN_MEMBERS_AstConstraintForeach;
|
||||
bool isSoft() const { return m_soft; }
|
||||
void dump(std::ostream& str) const override;
|
||||
void dumpJson(std::ostream& str) const override;
|
||||
};
|
||||
class AstForeach final : public AstNodeForeach {
|
||||
public:
|
||||
|
||||
@@ -2307,6 +2307,14 @@ void AstCover::dumpJson(std::ostream& str) const {
|
||||
dumpJsonBoolFuncIf(str, isSeqEvent);
|
||||
this->AstNodeCoverOrAssert::dumpJson(str);
|
||||
}
|
||||
void AstConstraintForeach::dump(std::ostream& str) const {
|
||||
this->AstNodeForeach::dump(str);
|
||||
if (isSoft()) str << "[SOFT]";
|
||||
}
|
||||
void AstConstraintForeach::dumpJson(std::ostream& str) const {
|
||||
dumpJsonBoolFuncIf(str, isSoft);
|
||||
dumpJsonGen(str);
|
||||
}
|
||||
void AstClocking::dump(std::ostream& str) const {
|
||||
this->AstNode::dump(str);
|
||||
if (isDefault()) str << " [DEFAULT]";
|
||||
|
||||
@@ -298,6 +298,12 @@ class LinkParseVisitor final : public VNVisitor {
|
||||
v3Global.useRandomizeMethods(true);
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
void visit(AstConstraintForeach* nodep) override {
|
||||
if (nodep->isSoft()) {
|
||||
nodep->v3warn(NONSTD, "Non-standard soft foreach");
|
||||
nodep->foreach([](AstConstraintExpr* exprp) { exprp->isSoft(true); });
|
||||
}
|
||||
}
|
||||
void visit(AstEnumDType* nodep) override {
|
||||
if (nodep->name() == "") {
|
||||
nodep->name(nameFromTypedef(nodep)); // Might still remain ""
|
||||
|
||||
@@ -8166,6 +8166,9 @@ constraint_expression<nodep>: // ==IEEE: constraint_expression
|
||||
// // IEEE says array_identifier here, but dotted accepted in VMM + 1800-2009
|
||||
| yFOREACH '(' idClassSelForeach ')' constraint_set
|
||||
{ $$ = new AstConstraintForeach{$1, $3, $5}; }
|
||||
// // Non-IEEE extension, soft foreach
|
||||
| ySOFT yFOREACH '(' idClassSelForeach ')' constraint_set
|
||||
{ $$ = new AstConstraintForeach{$2, $4, $6, true}; }
|
||||
// // soft is 1800-2012
|
||||
| yDISABLE ySOFT constraint_primary ';'
|
||||
{ AstConstraintExpr* const newp = new AstConstraintExpr{$1, $3};
|
||||
|
||||
Reference in New Issue
Block a user