Fix packages with `--public-depth 1` (#5708)
This commit is contained in:
parent
dcaf6476e8
commit
0d34f56b74
|
|
@ -983,7 +983,8 @@ void EmitCSyms::emitSymImp() {
|
||||||
varName += protect(varp->name());
|
varName += protect(varp->name());
|
||||||
|
|
||||||
if (varp->isParam()) {
|
if (varp->isParam()) {
|
||||||
if (varp->vlEnumType() == "VLVT_STRING") {
|
if (varp->vlEnumType() == "VLVT_STRING"
|
||||||
|
&& !VN_IS(varp->subDTypep(), UnpackArrayDType)) {
|
||||||
puts(", const_cast<void*>(static_cast<const void*>(");
|
puts(", const_cast<void*>(static_cast<const void*>(");
|
||||||
puts(varName);
|
puts(varName);
|
||||||
puts(".c_str())), ");
|
puts(".c_str())), ");
|
||||||
|
|
|
||||||
|
|
@ -340,22 +340,20 @@ class LinkParseVisitor final : public VNVisitor {
|
||||||
// Maybe this variable has a signal attribute
|
// Maybe this variable has a signal attribute
|
||||||
V3Config::applyVarAttr(m_modp, m_ftaskp, nodep);
|
V3Config::applyVarAttr(m_modp, m_ftaskp, nodep);
|
||||||
|
|
||||||
if (v3Global.opt.publicFlatRW()
|
if (v3Global.opt.anyPublicFlat() && nodep->varType().isVPIAccessible()) {
|
||||||
|| (v3Global.opt.publicDepth() && m_modp
|
if (v3Global.opt.publicFlatRW()) {
|
||||||
&& (m_modp->level() - 1) <= v3Global.opt.publicDepth())) {
|
nodep->sigUserRWPublic(true);
|
||||||
|
} else if (v3Global.opt.publicParams() && nodep->isParam()) {
|
||||||
switch (nodep->varType()) {
|
nodep->sigUserRWPublic(true);
|
||||||
case VVarType::VAR: // FALLTHRU
|
} else if (m_modp && v3Global.opt.publicDepth()) {
|
||||||
case VVarType::GPARAM: // FALLTHRU
|
if ((m_modp->level() - 1) <= v3Global.opt.publicDepth()) {
|
||||||
case VVarType::LPARAM: // FALLTHRU
|
nodep->sigUserRWPublic(true);
|
||||||
case VVarType::PORT: // FALLTHRU
|
} else if (VN_IS(m_modp, Package) && nodep->isParam()) {
|
||||||
case VVarType::WIRE: nodep->sigUserRWPublic(true); break;
|
nodep->sigUserRWPublic(true);
|
||||||
default: break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v3Global.opt.publicParams() && nodep->isParam()) nodep->sigUserRWPublic(true);
|
|
||||||
|
|
||||||
// We used modTrace before leveling, and we may now
|
// We used modTrace before leveling, and we may now
|
||||||
// want to turn it off now that we know the levelizations
|
// want to turn it off now that we know the levelizations
|
||||||
if (v3Global.opt.traceDepth() && m_modp
|
if (v3Global.opt.traceDepth() && m_modp
|
||||||
|
|
|
||||||
|
|
@ -543,6 +543,8 @@ public:
|
||||||
bool allPublic() const { return m_public; }
|
bool allPublic() const { return m_public; }
|
||||||
bool publicParams() const { return m_public_params; }
|
bool publicParams() const { return m_public_params; }
|
||||||
bool publicFlatRW() const { return m_publicFlatRW; }
|
bool publicFlatRW() const { return m_publicFlatRW; }
|
||||||
|
int publicDepth() const { return m_publicDepth; }
|
||||||
|
bool anyPublicFlat() const { return m_public_params || m_publicFlatRW || m_publicDepth; }
|
||||||
bool lintOnly() const VL_MT_SAFE { return m_lintOnly; }
|
bool lintOnly() const VL_MT_SAFE { return m_lintOnly; }
|
||||||
bool ignc() const { return m_ignc; }
|
bool ignc() const { return m_ignc; }
|
||||||
bool quietExit() const VL_MT_SAFE { return m_quietExit; }
|
bool quietExit() const VL_MT_SAFE { return m_quietExit; }
|
||||||
|
|
@ -577,7 +579,6 @@ public:
|
||||||
int outputSplitCTrace() const { return m_outputSplitCTrace; }
|
int outputSplitCTrace() const { return m_outputSplitCTrace; }
|
||||||
int outputGroups() const { return m_outputGroups; }
|
int outputGroups() const { return m_outputGroups; }
|
||||||
int pinsBv() const VL_MT_SAFE { return m_pinsBv; }
|
int pinsBv() const VL_MT_SAFE { return m_pinsBv; }
|
||||||
int publicDepth() const { return m_publicDepth; }
|
|
||||||
int reloopLimit() const { return m_reloopLimit; }
|
int reloopLimit() const { return m_reloopLimit; }
|
||||||
VOptionBool skipIdentical() const { return m_skipIdentical; }
|
VOptionBool skipIdentical() const { return m_skipIdentical; }
|
||||||
bool stopFail() const { return m_stopFail; }
|
bool stopFail() const { return m_stopFail; }
|
||||||
|
|
|
||||||
|
|
@ -116,10 +116,12 @@ int mon_check() {
|
||||||
|
|
||||||
CHECK_RESULT_Z(count_params(unitHandle, 1));
|
CHECK_RESULT_Z(count_params(unitHandle, 1));
|
||||||
CHECK_RESULT_Z(count_params(pkgHandle, 2));
|
CHECK_RESULT_Z(count_params(pkgHandle, 2));
|
||||||
CHECK_RESULT_Z(count_params(tHandle, 3));
|
CHECK_RESULT_Z(count_params(tHandle, 6));
|
||||||
|
|
||||||
CHECK_RESULT_Z(check_handle(const_cast<PLI_BYTE8*>("someOtherInt"), tHandle))
|
CHECK_RESULT_Z(check_handle(const_cast<PLI_BYTE8*>("someOtherInt"), tHandle))
|
||||||
CHECK_RESULT_Z(check_handle(const_cast<PLI_BYTE8*>("t.someOtherInt"), NULL))
|
CHECK_RESULT_Z(check_handle(const_cast<PLI_BYTE8*>("t.someOtherInt"), NULL))
|
||||||
|
CHECK_RESULT_Z(check_handle(const_cast<PLI_BYTE8*>("someString"), tHandle))
|
||||||
|
CHECK_RESULT_Z(check_handle(const_cast<PLI_BYTE8*>("t.someString"), NULL))
|
||||||
CHECK_RESULT_Z(check_handle(const_cast<PLI_BYTE8*>("someInt"), pkgHandle))
|
CHECK_RESULT_Z(check_handle(const_cast<PLI_BYTE8*>("someInt"), pkgHandle))
|
||||||
CHECK_RESULT_Z(check_handle(const_cast<PLI_BYTE8*>("somepackage::someInt"), NULL))
|
CHECK_RESULT_Z(check_handle(const_cast<PLI_BYTE8*>("somepackage::someInt"), NULL))
|
||||||
CHECK_RESULT_Z(check_handle(const_cast<PLI_BYTE8*>("dollarUnitInt"), unitHandle))
|
CHECK_RESULT_Z(check_handle(const_cast<PLI_BYTE8*>("dollarUnitInt"), unitHandle))
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ test.scenarios('simulator')
|
||||||
test.compile(make_top_shell=False,
|
test.compile(make_top_shell=False,
|
||||||
make_main=False,
|
make_main=False,
|
||||||
make_pli=True,
|
make_pli=True,
|
||||||
verilator_flags2=["--exe --vpi --no-l2name", test.pli_filename])
|
verilator_flags2=["--exe --vpi --no-l2name --public-depth 1", test.pli_filename])
|
||||||
|
|
||||||
test.execute(use_libvpi=True)
|
test.execute(use_libvpi=True)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,19 +8,24 @@
|
||||||
|
|
||||||
import "DPI-C" context function int mon_check();
|
import "DPI-C" context function int mon_check();
|
||||||
|
|
||||||
parameter int dollarUnitInt /*verilator public_flat_rd*/ = 3;
|
parameter int dollarUnitInt = 3;
|
||||||
|
|
||||||
package somepackage;
|
package somepackage;
|
||||||
parameter int someInt /*verilator public_flat_rd*/ = 5;
|
parameter int someInt = 5;
|
||||||
parameter int anotherInt /*verilator public_flat_rd*/ = 6;
|
parameter int anotherInt = 6;
|
||||||
endpackage
|
endpackage
|
||||||
|
|
||||||
module t (/*AUTOARG*/
|
module t (/*AUTOARG*/
|
||||||
); /*verilator public_module*/
|
);
|
||||||
|
|
||||||
parameter int someOtherInt /* verilator public_flat_rd*/ = 7;
|
parameter int someOtherInt = 7;
|
||||||
parameter int yetAnotherInt /* verilator public_flat_rd*/ = 9;
|
parameter int yetAnotherInt = 9;
|
||||||
parameter int stillAnotherInt /* verilator public_flat_rd*/ = 17;
|
parameter int stillAnotherInt = 17;
|
||||||
|
parameter int register = 0;
|
||||||
|
parameter int n_str = 2;
|
||||||
|
// Edge case with pvi code generation
|
||||||
|
parameter string someString [n_str] = '{default: ""};
|
||||||
|
logic reference;
|
||||||
|
|
||||||
integer status;
|
integer status;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue