Fix 'with' operator with type casting (#3387).

This commit is contained in:
Wilson Snyder 2022-05-15 09:53:48 -04:00
parent ae8d8ee1ac
commit 3c4131d45d
4 changed files with 6 additions and 5 deletions

View File

@ -15,6 +15,7 @@ Verilator 4.223 devel
* Support compile time trace signal selection with tracing_on/off (#3323). [Shunyao CAD]
* Fix hang with large case statement optimization (#3405). [Mike Urbach]
* Fix 'with' operator with type casting (#3387). [xiak95]
Verilator 4.222 2022-05-02

View File

@ -1729,7 +1729,6 @@ class LinkDotScopeVisitor final : public VNVisitor {
// Note we allow AstNodeStmt's as generates may be under them
virtual void visit(AstCell*) override {}
virtual void visit(AstVar*) override {}
virtual void visit(AstNodeMath*) override {}
virtual void visit(AstNode* nodep) override { iterateChildren(nodep); }
public:

View File

@ -2725,7 +2725,7 @@ private:
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ);
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(),
"r_" + nodep->name(), withp);
newp->dtypeFrom(adtypep->subDTypep());
newp->dtypeFrom(withp ? withp->dtypep() : adtypep->subDTypep());
if (!nodep->firstAbovep()) newp->makeStatement();
} else if (nodep->name() == "min" || nodep->name() == "max" || nodep->name() == "unique"
|| nodep->name() == "unique_index") {
@ -2949,7 +2949,7 @@ private:
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ);
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(),
"r_" + nodep->name(), withp);
newp->dtypeFrom(adtypep->subDTypep());
newp->dtypeFrom(withp ? withp->dtypep() : adtypep->subDTypep());
if (!nodep->firstAbovep()) newp->makeStatement();
} else if (nodep->name() == "reverse" || nodep->name() == "shuffle"
|| nodep->name() == "sort" || nodep->name() == "rsort") {

View File

@ -16,6 +16,7 @@ module t (/*AUTOARG*/);
int aliases[$];
int found[$];
int i;
byte byteq[$] = {2, -1, 127};
aliases = '{ 1, 4, 6, 8};
tofind = 6;
@ -35,8 +36,8 @@ module t (/*AUTOARG*/);
// bug3387
i = aliases.sum();
`checkh(i, 'h13);
i = aliases.sum() with (2'(item));
`checkh(i, 'h3);
i = byteq.sum() with (int'(item));
`checkh(i, 128);
// Unique (array method)
tofind = 4;