Rename port variable

Signed-off-by: Kamil Danecki <kdanecki@internships.antmicro.com>
This commit is contained in:
Kamil Danecki 2026-03-26 09:22:34 +01:00
parent 4926fbd369
commit 8eaf171135
1 changed files with 7 additions and 6 deletions

View File

@ -306,20 +306,21 @@ class BeginVisitor final : public VNVisitor {
const std::string newName
= m_ftaskp->name() + "__Vstatic__" + dot(m_unnamedScope, nodep->name());
if (nodep->isIO()) {
AstVar* keepAsPort = nodep->cloneTreePure(false);
nodep->replaceWith(keepAsPort);
m_statep->userMarkChanged(keepAsPort);
// Create a port that is used for passing value between argument and static variable
AstVar* const portp = nodep->cloneTreePure(false);
portp->user1(true);
nodep->replaceWith(portp);
if (nodep->isInput() || nodep->isInout()) {
AstAssign* initAssignp = new AstAssign{nodep->fileline(),
new AstVarRef{nodep->fileline(), nodep, VAccess::WRITE},
new AstVarRef{keepAsPort->fileline(), keepAsPort, VAccess::READ}};
keepAsPort->addNextHere(initAssignp);
new AstVarRef{portp->fileline(), portp, VAccess::READ}};
portp->addNextHere(initAssignp);
}
if (nodep->isWritable()) {
AstAssign* endAssignp = new AstAssign{nodep->fileline(),
new AstVarRef{keepAsPort->fileline(), keepAsPort, VAccess::WRITE},
new AstVarRef{portp->fileline(), portp, VAccess::WRITE},
new AstVarRef{nodep->fileline(), nodep, VAccess::READ}};
m_ftaskp->addStmtsp(endAssignp);
}