mirror of
https://github.com/verilator/verilator.git
synced 2026-09-04 00:30:34 +02:00
Add mnemonic to parameter constants in JSON for FSM Coverage (#7531)
This commit is contained in:
@@ -543,6 +543,22 @@ AstNetlist::AstNetlist()
|
||||
addMiscsp(m_constPoolp);
|
||||
}
|
||||
|
||||
string AstNetlist::astConstOrigParamName(const AstConst* nodep) const {
|
||||
if (!nodep->num().hasOrigParamName()) return "";
|
||||
const auto it = m_constOrigParamNames.find(nodep);
|
||||
UASSERT_OBJ(it != m_constOrigParamNames.end(), nodep, "Missing originating parameter name");
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void AstNetlist::astConstOrigParamName(const AstConst* nodep, const string& name) {
|
||||
UASSERT(!name.empty(), "Empty originating parameter name");
|
||||
m_constOrigParamNames[nodep] = name;
|
||||
}
|
||||
|
||||
void AstNetlist::astConstOrigParamNameErase(const AstConst* nodep) {
|
||||
m_constOrigParamNames.erase(nodep);
|
||||
}
|
||||
|
||||
void AstNetlist::timeprecisionMerge(FileLine*, const VTimescale& value) {
|
||||
const VTimescale prec = v3Global.opt.timeComputePrec(value);
|
||||
if (prec.isNone() || prec == m_timeprecision) {
|
||||
@@ -1819,6 +1835,46 @@ string AstBasicDType::prettyDTypeName(bool) const {
|
||||
void AstNodeExpr::dump(std::ostream& str) const { this->AstNode::dump(str); }
|
||||
void AstNodeExpr::dumpJson(std::ostream& str) const { dumpJsonGen(str); }
|
||||
|
||||
AstConst::~AstConst() {
|
||||
// Only rare constants carry originating parameter-name metadata. For all other AstConst nodes,
|
||||
// the V3Number bit keeps this destructor from touching AstNetlist's side table. When the bit is
|
||||
// set, erase the entry before this AstConst address can be reused by a different node.
|
||||
if (m_num.hasOrigParamName()) v3Global.rootp()->astConstOrigParamNameErase(this);
|
||||
}
|
||||
|
||||
string AstConst::origParamName() const {
|
||||
if (!m_num.hasOrigParamName()) return "";
|
||||
return v3Global.rootp()->astConstOrigParamName(this);
|
||||
}
|
||||
|
||||
void AstConst::origParamName(const string& name) {
|
||||
UASSERT(!name.empty(), "Empty originating parameter name");
|
||||
v3Global.rootp()->astConstOrigParamName(this, name);
|
||||
m_num.hasOrigParamName(true);
|
||||
}
|
||||
|
||||
void AstConst::cloneRelink() {
|
||||
// Preserve parameter-origin metadata across AST clones; the side-table key must be this
|
||||
// new AstConst, not the original node.
|
||||
if (const AstConst* const oldp = clonep()) {
|
||||
const string name = oldp->origParamName();
|
||||
m_num.hasOrigParamName(false);
|
||||
if (!name.empty()) origParamName(name);
|
||||
}
|
||||
m_num.nodep(this);
|
||||
}
|
||||
|
||||
void AstConst::dump(std::ostream& str) const {
|
||||
this->AstNodeExpr::dump(str);
|
||||
const string name = origParamName();
|
||||
if (!name.empty()) str << " origParamName=" << name;
|
||||
}
|
||||
void AstConst::dumpJson(std::ostream& str) const {
|
||||
const string name = origParamName();
|
||||
if (!name.empty()) dumpJsonStr(str, "origParamName", name);
|
||||
dumpJsonGen(str);
|
||||
}
|
||||
|
||||
bool AstNodeExpr::isLValue() const {
|
||||
if (const AstNodeVarRef* const varrefp = VN_CAST(this, NodeVarRef)) {
|
||||
return varrefp->access().isWriteOrRW();
|
||||
|
||||
Reference in New Issue
Block a user