mirror of
https://github.com/verilator/verilator.git
synced 2024-12-29 10:47:34 +00:00
Support vpiDefName (#5572)
This commit is contained in:
parent
833c215c45
commit
1d06364284
@ -126,6 +126,7 @@ Krzysztof Bieganski
|
|||||||
Krzysztof Boronski
|
Krzysztof Boronski
|
||||||
Krzysztof Boroński
|
Krzysztof Boroński
|
||||||
Krzysztof Obłonczek
|
Krzysztof Obłonczek
|
||||||
|
Krzysztof Starecki
|
||||||
Kuba Ober
|
Kuba Ober
|
||||||
Larry Doolittle
|
Larry Doolittle
|
||||||
Liam Braun
|
Liam Braun
|
||||||
|
@ -3326,7 +3326,7 @@ VerilatedScope::~VerilatedScope() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedScope::configure(VerilatedSyms* symsp, const char* prefixp, const char* suffixp,
|
void VerilatedScope::configure(VerilatedSyms* symsp, const char* prefixp, const char* suffixp,
|
||||||
const char* identifier, int8_t timeunit,
|
const char* identifier, const char* defnamep, int8_t timeunit,
|
||||||
const Type& type) VL_MT_UNSAFE {
|
const Type& type) VL_MT_UNSAFE {
|
||||||
// Slowpath - called once/scope at construction
|
// Slowpath - called once/scope at construction
|
||||||
// We don't want the space and reference-count access overhead of strings.
|
// We don't want the space and reference-count access overhead of strings.
|
||||||
@ -3343,6 +3343,7 @@ void VerilatedScope::configure(VerilatedSyms* symsp, const char* prefixp, const
|
|||||||
m_namep = namep;
|
m_namep = namep;
|
||||||
}
|
}
|
||||||
m_identifierp = identifier;
|
m_identifierp = identifier;
|
||||||
|
m_defnamep = defnamep;
|
||||||
Verilated::threadContextp()->impp()->scopeInsert(this);
|
Verilated::threadContextp()->impp()->scopeInsert(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,6 +714,7 @@ private:
|
|||||||
VerilatedVarNameMap* m_varsp = nullptr; // Variable map
|
VerilatedVarNameMap* m_varsp = nullptr; // Variable map
|
||||||
const char* m_namep = nullptr; // Scope name (Slowpath)
|
const char* m_namep = nullptr; // Scope name (Slowpath)
|
||||||
const char* m_identifierp = nullptr; // Identifier of scope (with escapes removed)
|
const char* m_identifierp = nullptr; // Identifier of scope (with escapes removed)
|
||||||
|
const char* m_defnamep = nullptr; // Definition name (SCOPE_MODULE only)
|
||||||
int8_t m_timeunit = 0; // Timeunit in negative power-of-10
|
int8_t m_timeunit = 0; // Timeunit in negative power-of-10
|
||||||
Type m_type = SCOPE_OTHER; // Type of the scope
|
Type m_type = SCOPE_OTHER; // Type of the scope
|
||||||
|
|
||||||
@ -721,13 +722,15 @@ public: // But internals only - called from VerilatedModule's
|
|||||||
VerilatedScope() = default;
|
VerilatedScope() = default;
|
||||||
~VerilatedScope();
|
~VerilatedScope();
|
||||||
void configure(VerilatedSyms* symsp, const char* prefixp, const char* suffixp,
|
void configure(VerilatedSyms* symsp, const char* prefixp, const char* suffixp,
|
||||||
const char* identifier, int8_t timeunit, const Type& type) VL_MT_UNSAFE;
|
const char* identifier, const char* defnamep, int8_t timeunit,
|
||||||
|
const Type& type) VL_MT_UNSAFE;
|
||||||
void exportInsert(int finalize, const char* namep, void* cb) VL_MT_UNSAFE;
|
void exportInsert(int finalize, const char* namep, void* cb) VL_MT_UNSAFE;
|
||||||
void varInsert(int finalize, const char* namep, void* datap, bool isParam,
|
void varInsert(int finalize, const char* namep, void* datap, bool isParam,
|
||||||
VerilatedVarType vltype, int vlflags, int dims, ...) VL_MT_UNSAFE;
|
VerilatedVarType vltype, int vlflags, int dims, ...) VL_MT_UNSAFE;
|
||||||
// ACCESSORS
|
// ACCESSORS
|
||||||
const char* name() const VL_MT_SAFE_POSTINIT { return m_namep; }
|
const char* name() const VL_MT_SAFE_POSTINIT { return m_namep; }
|
||||||
const char* identifier() const VL_MT_SAFE_POSTINIT { return m_identifierp; }
|
const char* identifier() const VL_MT_SAFE_POSTINIT { return m_identifierp; }
|
||||||
|
const char* defname() const VL_MT_SAFE_POSTINIT { return m_defnamep; }
|
||||||
int8_t timeunit() const VL_MT_SAFE_POSTINIT { return m_timeunit; }
|
int8_t timeunit() const VL_MT_SAFE_POSTINIT { return m_timeunit; }
|
||||||
VerilatedSyms* symsp() const VL_MT_SAFE_POSTINIT { return m_symsp; }
|
VerilatedSyms* symsp() const VL_MT_SAFE_POSTINIT { return m_symsp; }
|
||||||
VerilatedVar* varFind(const char* namep) const VL_MT_SAFE_POSTINIT;
|
VerilatedVar* varFind(const char* namep) const VL_MT_SAFE_POSTINIT;
|
||||||
|
@ -268,6 +268,7 @@ protected:
|
|||||||
bool m_toplevel = false;
|
bool m_toplevel = false;
|
||||||
const char* m_name;
|
const char* m_name;
|
||||||
const char* m_fullname;
|
const char* m_fullname;
|
||||||
|
const char* m_defname;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VerilatedVpioScope(const VerilatedScope* scopep)
|
explicit VerilatedVpioScope(const VerilatedScope* scopep)
|
||||||
@ -275,6 +276,7 @@ public:
|
|||||||
m_fullname = m_scopep->name();
|
m_fullname = m_scopep->name();
|
||||||
if (std::strncmp(m_fullname, "TOP.", 4) == 0) m_fullname += 4;
|
if (std::strncmp(m_fullname, "TOP.", 4) == 0) m_fullname += 4;
|
||||||
m_name = m_scopep->identifier();
|
m_name = m_scopep->identifier();
|
||||||
|
m_defname = m_scopep->defname();
|
||||||
}
|
}
|
||||||
~VerilatedVpioScope() override = default;
|
~VerilatedVpioScope() override = default;
|
||||||
static VerilatedVpioScope* castp(vpiHandle h) {
|
static VerilatedVpioScope* castp(vpiHandle h) {
|
||||||
@ -284,6 +286,7 @@ public:
|
|||||||
const VerilatedScope* scopep() const { return m_scopep; }
|
const VerilatedScope* scopep() const { return m_scopep; }
|
||||||
const char* name() const override { return m_name; }
|
const char* name() const override { return m_name; }
|
||||||
const char* fullname() const override { return m_fullname; }
|
const char* fullname() const override { return m_fullname; }
|
||||||
|
const char* defname() const override { return m_defname; }
|
||||||
bool toplevel() const { return m_toplevel; }
|
bool toplevel() const { return m_toplevel; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,13 +43,15 @@ class EmitCSyms final : EmitCBaseVisitorConst {
|
|||||||
const AstNode* m_nodep;
|
const AstNode* m_nodep;
|
||||||
const string m_symName;
|
const string m_symName;
|
||||||
const string m_prettyName;
|
const string m_prettyName;
|
||||||
|
const string m_defName;
|
||||||
const int m_timeunit;
|
const int m_timeunit;
|
||||||
string m_type;
|
string m_type;
|
||||||
ScopeData(const AstNode* nodep, const string& symName, const string& prettyName,
|
ScopeData(const AstNode* nodep, const string& symName, const string& prettyName,
|
||||||
int timeunit, const string& type)
|
const string& defName, int timeunit, const string& type)
|
||||||
: m_nodep{nodep}
|
: m_nodep{nodep}
|
||||||
, m_symName{symName}
|
, m_symName{symName}
|
||||||
, m_prettyName{prettyName}
|
, m_prettyName{prettyName}
|
||||||
|
, m_defName{defName}
|
||||||
, m_timeunit{timeunit}
|
, m_timeunit{timeunit}
|
||||||
, m_type{type} {}
|
, m_type{type} {}
|
||||||
};
|
};
|
||||||
@ -242,8 +244,8 @@ class EmitCSyms final : EmitCBaseVisitorConst {
|
|||||||
if (v3Global.opt.vpi()) varHierarchyScopes(scpName);
|
if (v3Global.opt.vpi()) varHierarchyScopes(scpName);
|
||||||
if (m_scopeNames.find(scpSym) == m_scopeNames.end()) {
|
if (m_scopeNames.find(scpSym) == m_scopeNames.end()) {
|
||||||
// cppcheck-suppress stlFindInsert
|
// cppcheck-suppress stlFindInsert
|
||||||
m_scopeNames.emplace(scpSym,
|
m_scopeNames.emplace(scpSym, ScopeData{varp, scpSym, scpPretty, "<null>",
|
||||||
ScopeData{varp, scpSym, scpPretty, 0, "SCOPE_OTHER"});
|
0, "SCOPE_OTHER"});
|
||||||
}
|
}
|
||||||
m_scopeVars.emplace(scpSym + " " + varp->name(),
|
m_scopeVars.emplace(scpSym + " " + varp->name(),
|
||||||
ScopeVarData{scpSym, varBasePretty, varp, modp, scopep});
|
ScopeVarData{scpSym, varBasePretty, varp, modp, scopep});
|
||||||
@ -312,7 +314,9 @@ class EmitCSyms final : EmitCBaseVisitorConst {
|
|||||||
const int timeunit = m_modp->timeunit().powerOfTen();
|
const int timeunit = m_modp->timeunit().powerOfTen();
|
||||||
m_vpiScopeCandidates.emplace(
|
m_vpiScopeCandidates.emplace(
|
||||||
scopeSymString(name),
|
scopeSymString(name),
|
||||||
ScopeData{nodep, scopeSymString(name), name_pretty, timeunit, type});
|
ScopeData{nodep, scopeSymString(name), name_pretty,
|
||||||
|
type == "SCOPE_MODULE" ? nodep->origModName() : "<null>", timeunit,
|
||||||
|
type});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstScope* nodep) override {
|
void visit(AstScope* nodep) override {
|
||||||
@ -325,9 +329,9 @@ class EmitCSyms final : EmitCBaseVisitorConst {
|
|||||||
const string type = VN_IS(nodep->modp(), Package) ? "SCOPE_PACKAGE" : "SCOPE_MODULE";
|
const string type = VN_IS(nodep->modp(), Package) ? "SCOPE_PACKAGE" : "SCOPE_MODULE";
|
||||||
const string name_pretty = AstNode::vpiName(nodep->shortName());
|
const string name_pretty = AstNode::vpiName(nodep->shortName());
|
||||||
const int timeunit = m_modp->timeunit().powerOfTen();
|
const int timeunit = m_modp->timeunit().powerOfTen();
|
||||||
m_vpiScopeCandidates.emplace(
|
m_vpiScopeCandidates.emplace(scopeSymString(nodep->name()),
|
||||||
scopeSymString(nodep->name()),
|
ScopeData{nodep, scopeSymString(nodep->name()),
|
||||||
ScopeData{nodep, scopeSymString(nodep->name()), name_pretty, timeunit, type});
|
name_pretty, "<null>", timeunit, type});
|
||||||
}
|
}
|
||||||
iterateChildrenConst(nodep);
|
iterateChildrenConst(nodep);
|
||||||
}
|
}
|
||||||
@ -336,8 +340,8 @@ class EmitCSyms final : EmitCBaseVisitorConst {
|
|||||||
// UINFO(9, "scnameins sp " << nodep->name() << " sp " << nodep->scopePrettySymName()
|
// UINFO(9, "scnameins sp " << nodep->name() << " sp " << nodep->scopePrettySymName()
|
||||||
// << " ss" << name << endl);
|
// << " ss" << name << endl);
|
||||||
const int timeunit = m_modp ? m_modp->timeunit().powerOfTen() : 0;
|
const int timeunit = m_modp ? m_modp->timeunit().powerOfTen() : 0;
|
||||||
m_scopeNames.emplace(
|
m_scopeNames.emplace(name, ScopeData{nodep, name, nodep->scopePrettySymName(), "<null>",
|
||||||
name, ScopeData{nodep, name, nodep->scopePrettySymName(), timeunit, "SCOPE_OTHER"});
|
timeunit, "SCOPE_OTHER"});
|
||||||
if (nodep->dpiExport()) {
|
if (nodep->dpiExport()) {
|
||||||
UASSERT_OBJ(m_cfuncp, nodep, "ScopeName not under DPI function");
|
UASSERT_OBJ(m_cfuncp, nodep, "ScopeName not under DPI function");
|
||||||
m_scopeFuncs.emplace(name + " " + m_cfuncp->name(),
|
m_scopeFuncs.emplace(name + " " + m_cfuncp->name(),
|
||||||
@ -345,9 +349,10 @@ class EmitCSyms final : EmitCBaseVisitorConst {
|
|||||||
} else {
|
} else {
|
||||||
if (m_scopeNames.find(nodep->scopeDpiName()) == m_scopeNames.end()) {
|
if (m_scopeNames.find(nodep->scopeDpiName()) == m_scopeNames.end()) {
|
||||||
// cppcheck-suppress stlFindInsert
|
// cppcheck-suppress stlFindInsert
|
||||||
m_scopeNames.emplace(nodep->scopeDpiName(), ScopeData{nodep, nodep->scopeDpiName(),
|
m_scopeNames.emplace(nodep->scopeDpiName(),
|
||||||
nodep->scopePrettyDpiName(),
|
ScopeData{nodep, nodep->scopeDpiName(),
|
||||||
timeunit, "SCOPE_OTHER"});
|
nodep->scopePrettyDpiName(), "<null>", timeunit,
|
||||||
|
"SCOPE_OTHER"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -885,6 +890,8 @@ void EmitCSyms::emitSymImp() {
|
|||||||
puts(", ");
|
puts(", ");
|
||||||
putsQuoted(protect(scopeDecodeIdentifier(it->second.m_prettyName)));
|
putsQuoted(protect(scopeDecodeIdentifier(it->second.m_prettyName)));
|
||||||
puts(", ");
|
puts(", ");
|
||||||
|
putsQuoted(it->second.m_defName);
|
||||||
|
puts(", ");
|
||||||
puts(cvtToStr(it->second.m_timeunit));
|
puts(cvtToStr(it->second.m_timeunit));
|
||||||
puts(", VerilatedScope::" + it->second.m_type + ");\n");
|
puts(", VerilatedScope::" + it->second.m_type + ");\n");
|
||||||
++m_numStmts;
|
++m_numStmts;
|
||||||
|
@ -132,7 +132,7 @@ int _mon_check_iter() {
|
|||||||
TEST_CHECK_CSTR(p, "\\mod.with_dot ");
|
TEST_CHECK_CSTR(p, "\\mod.with_dot ");
|
||||||
if (TestSimulator::is_verilator()) {
|
if (TestSimulator::is_verilator()) {
|
||||||
p = vpi_get_str(vpiDefName, vh2);
|
p = vpi_get_str(vpiDefName, vh2);
|
||||||
TEST_CHECK_CSTR(p, "<null>"); // Unsupported
|
TEST_CHECK_CSTR(p, "sub");
|
||||||
}
|
}
|
||||||
|
|
||||||
TestVpiHandle vh_null_name = MY_VPI_HANDLE("___0_");
|
TestVpiHandle vh_null_name = MY_VPI_HANDLE("___0_");
|
||||||
|
@ -443,7 +443,7 @@ int _mon_check_varlist() {
|
|||||||
CHECK_RESULT_CSTR(p, "sub");
|
CHECK_RESULT_CSTR(p, "sub");
|
||||||
if (TestSimulator::is_verilator()) {
|
if (TestSimulator::is_verilator()) {
|
||||||
p = vpi_get_str(vpiDefName, vh2);
|
p = vpi_get_str(vpiDefName, vh2);
|
||||||
CHECK_RESULT_CSTR(p, "<null>"); // Unsupported
|
CHECK_RESULT_CSTR(p, "sub");
|
||||||
}
|
}
|
||||||
|
|
||||||
TestVpiHandle vh10 = vpi_iterate(vpiReg, vh2);
|
TestVpiHandle vh10 = vpi_iterate(vpiReg, vh2);
|
||||||
|
Loading…
Reference in New Issue
Block a user