diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index 880b5608a..ef3746a76 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -325,3 +325,4 @@ Yogish Sekhar 24bit-xjkp Zubin Jain Muzaffer Kal +Yilin Li diff --git a/src/V3EmitCFunc.cpp b/src/V3EmitCFunc.cpp index 8eb82b31f..ed4a55c3a 100644 --- a/src/V3EmitCFunc.cpp +++ b/src/V3EmitCFunc.cpp @@ -463,7 +463,9 @@ void EmitCFunc::emitVarReset(const string& prefix, AstVar* varp, bool constructi // 'constructing' indicates that the object was just constructed, so if it is a string or // something that starts off clear already, no need to clear it again AstNodeDType* const dtypep = varp->dtypep()->skipRefp(); - const string vlSelf = VSelfPointerText::replaceThis(m_useSelfForThis, "this->"); + const string vlSelf = m_cfuncp && m_cfuncp->isStatic() ? + "vlSymsp->TOP__" + m_modp->name() + "." : + VSelfPointerText::replaceThis(m_useSelfForThis, "this->"); const string varNameProtected = ((VN_IS(m_modp, Class) || varp->isFuncLocal()) || !prefix.empty()) ? varp->nameProtect() diff --git a/test_regress/t/t_dpi_export_unpack.py b/test_regress/t/t_dpi_export_unpack.py new file mode 100755 index 000000000..72cdc721b --- /dev/null +++ b/test_regress/t/t_dpi_export_unpack.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# DESCRIPTION: Verilator: Verilog Test for dpi unpack array +# +# author: Yilin Li + +import vltest_bootstrap + +test.scenarios('simulator') + +test.compile(verilator_flags2=["--binary"]) + +test.execute() + +test.passes() diff --git a/test_regress/t/t_dpi_export_unpack.v b/test_regress/t/t_dpi_export_unpack.v new file mode 100644 index 000000000..e8d5073c3 --- /dev/null +++ b/test_regress/t/t_dpi_export_unpack.v @@ -0,0 +1,23 @@ +export "DPI-C" task readHEX; +export "DPI-C" task loadHEX; + +task readHEX; + input string file; + output logic [7:0] stimuli[32'h00010000]; + $readmemh(file, stimuli); +endtask + +task loadHEX; + input string file; + logic [7:0] stimuli[32'h00010000]; + readHEX(file, stimuli); +endtask + +module tb(); + + logic [7:0] result[32'h00010000]; + initial begin + loadHEX("dummy"); + end + +endmodule \ No newline at end of file