mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 01:54:01 +02:00
Fix parameter passing to ports (#4723)
Signed-off-by: Ryszard Rozak <[email protected]>
This commit is contained in:
+15
-12
@@ -283,7 +283,7 @@ class InlineRelinkVisitor final : public VNVisitor {
|
||||
// user2p is either a const or a var.
|
||||
FileLine* const flp = nodep->fileline();
|
||||
AstConst* const exprconstp = VN_CAST(nodep->user2p(), Const);
|
||||
const AstVarRef* const exprvarrefp = VN_CAST(nodep->user2p(), VarRef);
|
||||
AstVarRef* exprvarrefp = VN_CAST(nodep->user2p(), VarRef);
|
||||
UINFO(8, "connectto: " << nodep->user2p() << endl);
|
||||
UASSERT_OBJ(exprconstp || exprvarrefp, nodep,
|
||||
"Unknown interconnect type; pinReconnectSimple should have cleared up");
|
||||
@@ -296,30 +296,32 @@ class InlineRelinkVisitor final : public VNVisitor {
|
||||
// remove the change detection on the output variable.
|
||||
UINFO(9, "public pin assign: " << exprvarrefp << endl);
|
||||
UASSERT_OBJ(!nodep->isNonOutput(), nodep, "Outputs only - inputs use AssignAlias");
|
||||
m_modp->addStmtsp(
|
||||
new AstAssignW{flp, new AstVarRef{flp, exprvarrefp->varp(), VAccess::WRITE},
|
||||
new AstVarRef{flp, nodep, VAccess::READ}});
|
||||
m_modp->addStmtsp(new AstAssignW{flp, exprvarrefp->cloneTree(false),
|
||||
new AstVarRef{flp, nodep, VAccess::READ}});
|
||||
} else if (nodep->isSigPublic() && VN_IS(nodep->dtypep(), UnpackArrayDType)) {
|
||||
// Public variable at this end and it is an unpacked array. We need to assign
|
||||
// instead of aliased, because otherwise it will pass V3Slice and invalid
|
||||
// code will be emitted.
|
||||
UINFO(9, "assign to public and unpacked: " << nodep << endl);
|
||||
exprvarrefp = exprvarrefp->cloneTree(false);
|
||||
exprvarrefp->access(VAccess::READ);
|
||||
m_modp->addStmtsp(
|
||||
new AstAssignW{flp, new AstVarRef{flp, nodep, VAccess::WRITE},
|
||||
new AstVarRef{flp, exprvarrefp->varp(), VAccess::READ}});
|
||||
new AstAssignW{flp, new AstVarRef{flp, nodep, VAccess::WRITE}, exprvarrefp});
|
||||
} else if (nodep->isIfaceRef()) {
|
||||
m_modp->addStmtsp(
|
||||
new AstAssignVarScope{flp, new AstVarRef{flp, nodep, VAccess::WRITE},
|
||||
new AstVarRef{flp, exprvarrefp->varp(), VAccess::READ}});
|
||||
exprvarrefp = exprvarrefp->cloneTree(false);
|
||||
exprvarrefp->access(VAccess::READ);
|
||||
m_modp->addStmtsp(new AstAssignVarScope{
|
||||
flp, new AstVarRef{flp, nodep, VAccess::WRITE}, exprvarrefp});
|
||||
FileLine* const flbp = exprvarrefp->varp()->fileline();
|
||||
flp->modifyStateInherit(flbp);
|
||||
flbp->modifyStateInherit(flp);
|
||||
} else {
|
||||
// Do to inlining child's variable now within the same
|
||||
// module, so a AstVarRef not AstVarXRef below
|
||||
m_modp->addStmtsp(
|
||||
new AstAssignAlias{flp, new AstVarRef{flp, nodep, VAccess::WRITE},
|
||||
new AstVarRef{flp, exprvarrefp->varp(), VAccess::READ}});
|
||||
exprvarrefp = exprvarrefp->cloneTree(false);
|
||||
exprvarrefp->access(VAccess::READ);
|
||||
m_modp->addStmtsp(new AstAssignAlias{
|
||||
flp, new AstVarRef{flp, nodep, VAccess::WRITE}, exprvarrefp});
|
||||
FileLine* const flbp = exprvarrefp->varp()->fileline();
|
||||
flp->modifyStateInherit(flbp);
|
||||
flbp->modifyStateInherit(flp);
|
||||
@@ -376,6 +378,7 @@ class InlineRelinkVisitor final : public VNVisitor {
|
||||
return;
|
||||
} else if (const AstVarRef* const vrefp = VN_CAST(varp->user2p(), VarRef)) {
|
||||
nodep->varp(vrefp->varp());
|
||||
nodep->classOrPackagep(vrefp->classOrPackagep());
|
||||
} else {
|
||||
nodep->v3fatalSrc("Null connection?");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user