Implement 'forceable' attribute

Using the 'forceable' directive in a configuration file, or the /*
verilator forceable */ metacomment on a variable declaration will
generate additional public signals that allow the specified signals to
be forced/released from the C++ code.
This commit is contained in:
Geza Lore
2022-01-16 15:31:37 +00:00
parent 539c9d4c63
commit f8c0169e82
27 changed files with 1196 additions and 6 deletions
+19 -5
View File
@@ -87,6 +87,9 @@ class V3ConfigVarAttr final {
public:
VAttrType m_type; // Type of attribute
AstSenTree* m_sentreep; // Sensitivity tree for public_flat_rw
explicit V3ConfigVarAttr(VAttrType type)
: m_type{type}
, m_sentreep{nullptr} {}
V3ConfigVarAttr(VAttrType type, AstSenTree* sentreep)
: m_type{type}
, m_sentreep{sentreep} {}
@@ -455,14 +458,25 @@ void V3Config::addVarAttr(FileLine* fl, const string& module, const string& ftas
V3ConfigResolver::s().modules().at(module).ftasks().at(ftask).setPublic(true);
}
} else {
fl->v3error("missing -signal");
fl->v3error("missing -var");
}
} else {
V3ConfigModule& mod = V3ConfigResolver::s().modules().at(module);
if (ftask.empty()) {
mod.vars().at(var).push_back(V3ConfigVarAttr(attr, sensep));
if (attr == VAttrType::VAR_FORCEABLE) {
if (module.empty()) {
fl->v3error("missing -module");
} else if (!ftask.empty()) {
fl->v3error("Signals inside functions/tasks cannot be marked forceable");
} else {
V3ConfigResolver::s().modules().at(module).vars().at(var).push_back(
V3ConfigVarAttr(attr));
}
} else {
mod.ftasks().at(ftask).vars().at(var).push_back(V3ConfigVarAttr(attr, sensep));
V3ConfigModule& mod = V3ConfigResolver::s().modules().at(module);
if (ftask.empty()) {
mod.vars().at(var).push_back(V3ConfigVarAttr(attr, sensep));
} else {
mod.ftasks().at(ftask).vars().at(var).push_back(V3ConfigVarAttr(attr, sensep));
}
}
}
}