Fix $c() inside a DPI export (#8402). [Nazar Zibilyuk]

Fixes #8402.
This commit is contained in:
Wilson Snyder
2026-09-29 19:17:34 -04:00
parent 0993179e7e
commit a419e91574
5 changed files with 14 additions and 4 deletions
+1
View File
@@ -106,6 +106,7 @@ Verilator 5.053 devel
* Fix error on non-existent interface ports (#8393). [Andrii Andrieiev, Antmicro Ltd.]
* Fix compile-time blowup forcing large unpacked arrays (#8395). [Jonathan Drolet]
* Fix false MULTIDRIVEN for writes in tasks never executed (#8401). [Artur Bieniek, Antmicro Ltd.]
* Fix $c() inside a DPI export (#8402). [Nazar Zibilyuk]
* Fix covergroup constructor initialization (#8410). [Marco Bartoli]
* Fix issues with configuring flex during build on MacOS (#8412). [Kaleb Barrett]
* Fix interface modport resolution against non-scope symbol tables (#8420). [Geza Lore, Testorrent USA, Inc.]
+4 -1
View File
@@ -110,7 +110,10 @@ class DepthVisitor final : public VNVisitor {
// (Here instead of new visitor after V3Descope just to avoid another visitor)
void needNonStaticFunc(AstNode* nodep) {
UASSERT_OBJ(m_cfuncp, nodep, "Non-static accessor not under a function");
if (m_cfuncp->isStatic()) {
// DPI export implementations are always invoked via the generic DPI dispatcher,
// which can only ever supply the symbol table pointer, never a scope-specific
// "this", so they must remain static regardless of what they contain.
if (m_cfuncp->isStatic() && !m_cfuncp->dpiExportImpl()) {
UINFO(5, "Mark non-public due to " << nodep);
m_cfuncp->isStatic(false);
}
-2
View File
@@ -31,8 +31,6 @@ class EmitCModel final : public EmitCFunc {
using CFuncVector = std::vector<const AstCFunc*>;
// MEMBERS
// Needed to emit references to functions of the model, e.g. entry points
const EmitCParentModule m_emitCParentModule;
V3UniqueNames m_uniqueNames; // For generating unique file names
// METHODS
+3
View File
@@ -48,6 +48,7 @@
#include "V3DfgOptimizer.h"
#include "V3DiagSarif.h"
#include "V3EmitC.h"
#include "V3EmitCBase.h"
#include "V3EmitCMain.h"
#include "V3EmitMk.h"
#include "V3EmitMkJson.h"
@@ -628,6 +629,8 @@ static void process() {
// Output the text
if (!v3Global.opt.lintOnly() && !v3Global.opt.serializeOnly()
&& !v3Global.opt.dpiHdrOnly()) {
// Make parent module pointers available for all Emit stages below
const EmitCParentModule emitCParentModule;
// emitcInlines is first, as it may set needHInlines which other emitters read
V3EmitC::emitcInlines();
V3EmitC::emitcSyms();
+6 -1
View File
@@ -23,7 +23,12 @@ module t;
import "DPI-C" context function int dpix_run_tests();
export "DPI-C" task dpix_t_int;
task dpix_t_int(input int i, output int o); o = ~i; endtask
task dpix_t_int(input int i, output int o);
`ifdef VERILATOR
$c(";"); // Test issue #8402
`endif
o = ~i;
endtask
export "DPI-C" dpix_t_renamed = task dpix_t_ren;
task dpix_t_ren(input int i, output int o); o = i+2; endtask