Internals: Fix marking `AstVar`s as class members (#7070)
This commit is contained in:
parent
3dd2b762e7
commit
64511d30b6
|
|
@ -73,6 +73,11 @@ class LinkResolveVisitor final : public VNVisitor {
|
||||||
void visit(AstClass* nodep) override {
|
void visit(AstClass* nodep) override {
|
||||||
VL_RESTORER(m_classp);
|
VL_RESTORER(m_classp);
|
||||||
m_classp = nodep;
|
m_classp = nodep;
|
||||||
|
for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
|
||||||
|
if (AstVar* const varp = VN_CAST(stmtp, Var)) {
|
||||||
|
if (!varp->isParam()) varp->varType(VVarType::MEMBER);
|
||||||
|
}
|
||||||
|
}
|
||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstConstraint* nodep) override {
|
void visit(AstConstraint* nodep) override {
|
||||||
|
|
@ -120,7 +125,6 @@ class LinkResolveVisitor final : public VNVisitor {
|
||||||
}
|
}
|
||||||
void visit(AstVar* nodep) override {
|
void visit(AstVar* nodep) override {
|
||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
if (m_classp && !nodep->isParam()) nodep->varType(VVarType::MEMBER);
|
|
||||||
if (m_ftaskp) nodep->funcLocal(true);
|
if (m_ftaskp) nodep->funcLocal(true);
|
||||||
if (nodep->isSigModPublic()) {
|
if (nodep->isSigModPublic()) {
|
||||||
nodep->sigModPublic(false); // We're done with this attribute
|
nodep->sigModPublic(false); // We're done with this attribute
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ class Cls;
|
||||||
task bar;
|
task bar;
|
||||||
static int qux;
|
static int qux;
|
||||||
qux <= '1;
|
qux <= '1;
|
||||||
|
// Use qux to prevent V3Dead optimizations
|
||||||
|
$display("qux = %d\n", qux);
|
||||||
endtask
|
endtask
|
||||||
endclass
|
endclass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,11 @@
|
||||||
{"type":"VAR","name":"state","addr":"(Z)","loc":"d,17:11,17:16","dtypep":"(M)","origName":"state","verilogName":"state","direction":"NONE","lifetime":"VAUTOMI","varType":"MEMBER","dtypeName":"string","sensIfacep":"UNLINKED","childDTypep": [],"delayp": [],"valuep": [],"attrsp": []},
|
{"type":"VAR","name":"state","addr":"(Z)","loc":"d,17:11,17:16","dtypep":"(M)","origName":"state","verilogName":"state","direction":"NONE","lifetime":"VAUTOMI","varType":"MEMBER","dtypeName":"string","sensIfacep":"UNLINKED","childDTypep": [],"delayp": [],"valuep": [],"attrsp": []},
|
||||||
{"type":"FUNC","name":"strings_equal","addr":"(AB)","loc":"d,61:17,61:30","dtypep":"(U)","method":true,"cname":"strings_equal",
|
{"type":"FUNC","name":"strings_equal","addr":"(AB)","loc":"d,61:17,61:30","dtypep":"(U)","method":true,"cname":"strings_equal",
|
||||||
"fvarp": [
|
"fvarp": [
|
||||||
{"type":"VAR","name":"strings_equal","addr":"(BB)","loc":"d,61:17,61:30","dtypep":"(U)","origName":"strings_equal","verilogName":"strings_equal","direction":"OUTPUT","noCReset":true,"isFuncReturn":true,"isFuncLocal":true,"lifetime":"VAUTOM","varType":"MEMBER","dtypeName":"bit","sensIfacep":"UNLINKED","childDTypep": [],"delayp": [],"valuep": [],"attrsp": []}
|
{"type":"VAR","name":"strings_equal","addr":"(BB)","loc":"d,61:17,61:30","dtypep":"(U)","origName":"strings_equal","verilogName":"strings_equal","direction":"OUTPUT","noCReset":true,"isFuncReturn":true,"isFuncLocal":true,"lifetime":"VAUTOM","varType":"VAR","dtypeName":"bit","sensIfacep":"UNLINKED","childDTypep": [],"delayp": [],"valuep": [],"attrsp": []}
|
||||||
],"classOrPackagep": [],
|
],"classOrPackagep": [],
|
||||||
"stmtsp": [
|
"stmtsp": [
|
||||||
{"type":"VAR","name":"a","addr":"(CB)","loc":"d,61:38,61:39","dtypep":"(M)","origName":"a","verilogName":"a","direction":"INPUT","isFuncLocal":true,"lifetime":"VAUTOMI","varType":"MEMBER","dtypeName":"string","sensIfacep":"UNLINKED","childDTypep": [],"delayp": [],"valuep": [],"attrsp": []},
|
{"type":"VAR","name":"a","addr":"(CB)","loc":"d,61:38,61:39","dtypep":"(M)","origName":"a","verilogName":"a","direction":"INPUT","isFuncLocal":true,"lifetime":"VAUTOMI","varType":"PORT","dtypeName":"string","sensIfacep":"UNLINKED","childDTypep": [],"delayp": [],"valuep": [],"attrsp": []},
|
||||||
{"type":"VAR","name":"b","addr":"(DB)","loc":"d,61:48,61:49","dtypep":"(M)","origName":"b","verilogName":"b","direction":"INPUT","isFuncLocal":true,"lifetime":"VAUTOMI","varType":"MEMBER","dtypeName":"string","sensIfacep":"UNLINKED","childDTypep": [],"delayp": [],"valuep": [],"attrsp": []},
|
{"type":"VAR","name":"b","addr":"(DB)","loc":"d,61:48,61:49","dtypep":"(M)","origName":"b","verilogName":"b","direction":"INPUT","isFuncLocal":true,"lifetime":"VAUTOMI","varType":"PORT","dtypeName":"string","sensIfacep":"UNLINKED","childDTypep": [],"delayp": [],"valuep": [],"attrsp": []},
|
||||||
{"type":"ASSIGN","name":"","addr":"(EB)","loc":"d,61:17,61:30","dtypep":"(U)",
|
{"type":"ASSIGN","name":"","addr":"(EB)","loc":"d,61:17,61:30","dtypep":"(U)",
|
||||||
"rhsp": [
|
"rhsp": [
|
||||||
{"type":"CRESET","name":"","addr":"(FB)","loc":"d,61:17,61:30","dtypep":"(U)"}
|
{"type":"CRESET","name":"","addr":"(FB)","loc":"d,61:17,61:30","dtypep":"(U)"}
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,11 @@ parameter int LEN = 32;
|
||||||
|
|
||||||
class A;
|
class A;
|
||||||
rand int x;
|
rand int x;
|
||||||
|
rand int array[5];
|
||||||
constraint a_c {
|
constraint a_c {
|
||||||
x <= LEN;
|
x <= LEN;
|
||||||
x >= LEN;
|
x >= LEN;
|
||||||
|
foreach (array[i]) {array[i] == array[i-1];}
|
||||||
}
|
}
|
||||||
endclass
|
endclass
|
||||||
|
|
||||||
|
|
@ -25,6 +27,9 @@ module t;
|
||||||
b.a = new;
|
b.a = new;
|
||||||
if (b.randomize() == 0) $stop;
|
if (b.randomize() == 0) $stop;
|
||||||
if (b.a.x != LEN) $stop;
|
if (b.a.x != LEN) $stop;
|
||||||
|
for (int i = 0; i < 4; i++) begin
|
||||||
|
if (b.a.array[i] != b.a.array[i+1]) $stop;
|
||||||
|
end
|
||||||
$write("*-* All finished *-*\n");
|
$write("*-* All finished *-*\n");
|
||||||
$finish;
|
$finish;
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue