diff --git a/src/V3Task.cpp b/src/V3Task.cpp index bb0c00032..0238f89cb 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -1405,6 +1405,13 @@ class TaskVisitor final : public VNVisitor { unlinkAndClone(nodep, portp, false); portp->funcLocal(true); cfuncp->addArgsp(portp); + // Pass inputs to DPI import wrappers by reference, unless fits in register + if (cfuncp->dpiImportWrapper() && portp->isReadOnly()) { + AstNodeDType* const dtypep = portp->dtypep()->skipRefp(); + if (dtypep->isCompound() || dtypep->isWide()) { + portp->direction(VDirection::CONSTREF); + } + } } else { // "Normal" variable, mark inside function portp->funcLocal(true);