From a631f4308c21c7c37fcfba5ac60ad106db64cd15 Mon Sep 17 00:00:00 2001 From: Igor Zaworski Date: Wed, 17 Dec 2025 12:51:01 +0100 Subject: [PATCH] Removal of reuse mechanizm Signed-off-by: Igor Zaworski --- src/V3SchedVirtIface.cpp | 140 +++------------------------------------ 1 file changed, 8 insertions(+), 132 deletions(-) diff --git a/src/V3SchedVirtIface.cpp b/src/V3SchedVirtIface.cpp index 2528b36f4..cbd0c9fc3 100644 --- a/src/V3SchedVirtIface.cpp +++ b/src/V3SchedVirtIface.cpp @@ -42,10 +42,7 @@ class VirtIfaceVisitor final : public VNVisitor { private: // NODE STATE // AstIface::user1() -> AstVarScope*. Trigger var for this interface - // AstCFunc::user1() -> bool. Is visited - // AstCFunc::user2() -> bool. Has timing control const VNUser1InUse m_user1InUse; - const VNUser2InUse m_user2InUse; // TYPES using OnWriteToVirtIface = std::function; @@ -54,15 +51,10 @@ private: // STATE AstNetlist* const m_netlistp; // Root node - AstAssign* m_trigAssignp = nullptr; // Previous/current trigger assignment - AstIface* m_trigAssignIfacep = nullptr; // Interface type whose trigger is assigned - // by m_trigAssignp - AstVar* m_trigAssignMemberVarp = nullptr; // Member pointer whose trigger is assigned V3UniqueNames m_vifTriggerNames{"__VvifTrigger"}; // Unique names for virt iface // triggers VirtIfaceTriggers m_triggers; // Interfaces and corresponding trigger vars AstNodeStmt* m_curStmt = nullptr; // Current statement - bool m_hasTimingControl = false; // Whether current CFunc has timing control // METHODS // For each write across a virtual interface boundary @@ -117,12 +109,6 @@ private: // VISITORS void visit(AstNodeProcedure* nodep) override { - VL_RESTORER(m_trigAssignp); - m_trigAssignp = nullptr; - VL_RESTORER(m_trigAssignIfacep); - m_trigAssignIfacep = nullptr; - VL_RESTORER(m_trigAssignMemberVarp); - m_trigAssignMemberVarp = nullptr; // Not sure if needed, but be paranoid to match previous behavior as didn't optimize // before .. if (VN_IS(nodep, AlwaysPost) && writesToVirtIface(nodep)) { @@ -130,110 +116,18 @@ private: } iterateChildren(nodep); } - void visit(AstCFunc* nodep) override { - if (nodep->user1SetOnce()) return; - // By default set hasTiming to true - it may generate some false positives but it is better - // than generating false negatives. - // False positive may occur when there are are two funcs and they both call each other - nodep->user2(v3Global.usesTiming()); - VL_RESTORER(m_trigAssignp); - m_trigAssignp = nullptr; - VL_RESTORER(m_trigAssignIfacep); - m_trigAssignIfacep = nullptr; - VL_RESTORER(m_trigAssignMemberVarp); - m_trigAssignMemberVarp = nullptr; - VL_RESTORER(m_hasTimingControl); - m_hasTimingControl = false; - iterateChildren(nodep); - nodep->user2(m_hasTimingControl); - } - void visit(AstNodeCCall* nodep) override { - iterate(nodep->funcp()); - if (nodep->funcp()->user2()) { - m_trigAssignp = nullptr; - m_trigAssignIfacep = nullptr; - m_trigAssignMemberVarp = nullptr; - m_hasTimingControl = true; - } - iterateChildren(nodep); - } - void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* const nodep) override { unsupportedWriteToVirtIface(nodep->condp(), "if condition"); - iterateAndNextNull(nodep->condp()); - bool hasTimingControl; - { - VL_RESTORER(m_trigAssignp); - VL_RESTORER(m_trigAssignIfacep); - VL_RESTORER(m_trigAssignMemberVarp); - VL_RESTORER(m_hasTimingControl); - m_hasTimingControl = false; - iterateAndNextNull(nodep->thensp()); - hasTimingControl = m_hasTimingControl; - } - { - VL_RESTORER(m_trigAssignp); - VL_RESTORER(m_trigAssignIfacep); - VL_RESTORER(m_trigAssignMemberVarp); - VL_RESTORER(m_hasTimingControl); - m_hasTimingControl = false; - iterateAndNextNull(nodep->elsesp()); - hasTimingControl |= m_hasTimingControl; - } - if (hasTimingControl) { - // Clear the trigger assignment, as there could have been timing controls in either - // branch - m_trigAssignp = nullptr; - m_trigAssignIfacep = nullptr; - m_trigAssignMemberVarp = nullptr; - m_hasTimingControl = true; - } + iterateChildren(nodep); } - void visit(AstLoop* nodep) override { + void visit(AstLoop* const nodep) override { UASSERT_OBJ(!nodep->contsp(), nodep, "'contsp' only used before LinkJump"); - iterateAndNextNull(nodep->contsp()); - bool hasTimingControl; - { - VL_RESTORER(m_trigAssignp); - VL_RESTORER(m_trigAssignIfacep); - VL_RESTORER(m_trigAssignMemberVarp); - VL_RESTORER(m_hasTimingControl); - m_hasTimingControl = false; - iterateAndNextNull(nodep->stmtsp()); - hasTimingControl = m_hasTimingControl; - } - if (hasTimingControl) { - // Clear the trigger assignment, as there could have been timing controls in the loop - m_trigAssignp = nullptr; - m_trigAssignIfacep = nullptr; - m_trigAssignMemberVarp = nullptr; - m_hasTimingControl = true; - } + iterateChildren(nodep); } void visit(AstLoopTest* nodep) override { unsupportedWriteToVirtIface(nodep->condp(), "loop condition"); } - void visit(AstJumpBlock* nodep) override { - { - VL_RESTORER(m_trigAssignp); - VL_RESTORER(m_trigAssignIfacep); - VL_RESTORER(m_trigAssignMemberVarp); - iterateChildren(nodep); - } - if (v3Global.usesTiming()) { - // Clear the trigger assignment, as there could have been timing controls in the jump - // block - m_trigAssignp = nullptr; - m_trigAssignIfacep = nullptr; - m_trigAssignMemberVarp = nullptr; - } - } void visit(AstNodeStmt* nodep) override { - if (v3Global.usesTiming() && nodep->isTimingControl()) { - m_trigAssignp = nullptr; - m_trigAssignIfacep = nullptr; - m_trigAssignMemberVarp = nullptr; - m_hasTimingControl = true; - } VL_RESTORER(m_curStmt); m_curStmt = nodep; iterateChildren(nodep); @@ -261,31 +155,13 @@ private: } } - FileLine* const flp = nodep->fileline(); if (ifacep && memberVarp) { - if (ifacep != m_trigAssignIfacep || memberVarp != m_trigAssignMemberVarp) { - // Write to different interface member than before - need new trigger assignment - m_trigAssignIfacep = ifacep; - m_trigAssignMemberVarp = memberVarp; - m_trigAssignp = nullptr; - } - if (!m_trigAssignp) { - m_trigAssignp - = new AstAssign{flp, createVirtIfaceMemberTriggerRefp(flp, ifacep, memberVarp), - new AstConst{flp, AstConst::BitTrue{}}}; - m_curStmt->addNextHere(m_trigAssignp); - } + FileLine* const flp = nodep->fileline(); + m_curStmt->addNextHere( + new AstAssign{flp, createVirtIfaceMemberTriggerRefp(flp, ifacep, memberVarp), + new AstConst{flp, AstConst::BitTrue{}}}); } } - void visit(AstNodeExpr* const nodep) override { - if (v3Global.usesTiming() && nodep->isTimingControl()) { - m_trigAssignp = nullptr; - m_trigAssignIfacep = nullptr; - m_trigAssignMemberVarp = nullptr; - m_hasTimingControl = true; - } - iterateChildren(nodep); - } void visit(AstNode* nodep) override { iterateChildren(nodep); } public: