Fix unsupported if virtual interface warning (#6558) (#6861)

This commit is contained in:
Krzysztof Bieganski
2025-12-23 10:12:34 -05:00
committed by GitHub
parent 742c0b134c
commit a2fcd37c08
9 changed files with 68 additions and 17 deletions
+6
View File
@@ -2185,6 +2185,12 @@ public:
&& !isSc() && !isPrimaryIO() && !isConst() && !isDouble() && !isString());
}
bool isClassMember() const { return varType() == VVarType::MEMBER; }
bool isVirtIface() const {
if (AstIfaceRefDType* const dtp = VN_CAST(dtypep(), IfaceRefDType)) {
return dtp->isVirtual();
}
return false;
}
bool isStatementTemp() const { return varType() == VVarType::STMTTEMP; }
bool isXTemp() const { return varType() == VVarType::XTEMP; }
bool isParam() const { return varType().isParam(); }
+2 -2
View File
@@ -156,8 +156,8 @@ public:
UINFO(6, "New vertex " << vscp);
vVtxp = new GateVarVertex{this, vscp};
vscp->user1p(vVtxp);
if (vscp->varp()->sensIfacep()) {
// Can be used in a class method, which cannot be tracked statically
if (vscp->varp()->sensIfacep() || vscp->varp()->isVirtIface()) {
// Can be read/written to via the referenced actual interface
vVtxp->clearReducibleAndDedupable("VirtIface");
vVtxp->setConsumed("VirtIface");
}
+1
View File
@@ -192,6 +192,7 @@ class LocalizeVisitor final : public VNVisitor {
&& !nodep->varp()->isStatic() // Not a static variable
&& !nodep->varp()->isClassMember() // Statically exists in design hierarchy
&& !nodep->varp()->sensIfacep() // Not sensitive to an interface
&& !nodep->varp()->isVirtIface() // Not interface pointer
&& !nodep->varp()->valuep() // Does not have an initializer
) {
UINFO(4, "Consider for localization: " << nodep);
+8 -7
View File
@@ -104,12 +104,13 @@ private:
});
}
// Error on write across a virtual interface boundary
static void unsupportedWriteToVirtIface(AstNode* nodep, const char* locationp) {
static void unsupportedWriteToVirtIfaceMember(AstNode* nodep, const char* locationp) {
if (!nodep) return;
foreachWrittenVirtIface(nodep, [locationp](AstVarRef* const selp, AstIface*) {
selp->v3warn(E_UNSUPPORTED,
"Unsupported: Write to virtual interface in " << locationp);
});
foreachWrittenVirtIfaceMember(
nodep, [locationp](AstVarRef* const selp, AstIface*, AstVar* varp) {
selp->v3warn(E_UNSUPPORTED,
"Unsupported: Write to virtual interface in " << locationp);
});
}
// Create trigger var for the given interface if it doesn't exist; return a write ref to it
AstVarRef* createVirtIfaceTriggerRefp(FileLine* const flp, AstIface* ifacep) {
@@ -164,7 +165,7 @@ private:
iterateChildren(nodep);
}
void visit(AstNodeIf* nodep) override {
unsupportedWriteToVirtIface(nodep->condp(), "if condition");
unsupportedWriteToVirtIfaceMember(nodep->condp(), "if condition");
{
VL_RESTORER(m_trigAssignp);
VL_RESTORER(m_trigAssignIfacep);
@@ -201,7 +202,7 @@ private:
}
}
void visit(AstLoopTest* nodep) override {
unsupportedWriteToVirtIface(nodep->condp(), "loop condition");
unsupportedWriteToVirtIfaceMember(nodep->condp(), "loop condition");
}
void visit(AstJumpBlock* nodep) override {
{
-2
View File
@@ -3371,8 +3371,6 @@ class WidthVisitor final : public VNVisitor {
nodep->varp(varp);
AstIface* const ifacep = adtypep->ifacep();
varp->sensIfacep(ifacep);
nodep->fromp()->foreach(
[ifacep](AstVarRef* const refp) { refp->varp()->sensIfacep(ifacep); });
nodep->didWidth(true);
return;
}