Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from verilator:master #661

Merged
merged 3 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Verilator 5.035 devel
* Add check for `let` misused in statement context (#5733).
* Add used language to `--preproc-resolve` output (#5795). [Kamil Rakoczy, Antmicro Ltd.]
* Fix reset of automatic function variables (#5747). [Augustin Fabre]
* Fix invalid code motion over branches (#5811) (#5814). [Geza Lore]
* Fix sorting of wide SenItems (#5816). [Geza Lore]
* Fix tcmalloc static link and non-22.04 builds (#5817) (#5818). [Geza Lore]
* Fix UNOPTFLAT warnings with `--coverage-trace` and always_comb (#5821).
* Fix function locals in SenExprBuilder (#5822). [Geza Lore]


Verilator 5.034 2025-02-24
Expand Down
3 changes: 3 additions & 0 deletions docs/spelling.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Asciidoc
Ashutosh
Ast
Atmel
Augustin
Aurelien
Badáň
Bagri
Expand Down Expand Up @@ -109,6 +110,7 @@ Embecosm
Engstrom
Enzo
Eugen
Fabre
Fabrizio
Faucher
Faure
Expand Down Expand Up @@ -1018,6 +1020,7 @@ swrite
synthesizeable
sys
systemc
tcmalloc
tenghtt
testbench
threadsafe
Expand Down
6 changes: 3 additions & 3 deletions src/V3Active.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class ActiveNamer final : public VNVisitor {

// Make a new AstActive sensitive to the given sentree and return it
AstActive* makeActive(FileLine* const fl, AstSenTree* const senTreep) {
auto* const activep = new AstActive{fl, "", senTreep};
AstActive* const activep = new AstActive{fl, "", senTreep};
activep->sensesStorep(activep->sensesp());
addActive(activep);
return activep;
Expand Down Expand Up @@ -572,8 +572,8 @@ class ActiveVisitor final : public VNVisitor {
m_clockedProcess = true;
if (nodep->edgeType() != VEdgeType::ET_CHANGED) m_allChanged = false;

if (const auto* const dtypep = nodep->sensp()->dtypep()) {
if (const auto* const basicp = dtypep->basicp()) {
if (const AstNodeDType* const dtypep = nodep->sensp()->dtypep()) {
if (const AstBasicDType* const basicp = dtypep->basicp()) {
if (basicp->isEvent()) nodep->edgeType(VEdgeType::ET_EVENT);
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/V3Assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class AssertVisitor final : public VNVisitor {
}
}
AstSampled* newSampledExpr(AstNodeExpr* nodep) {
const auto sampledp = new AstSampled{nodep->fileline(), nodep};
AstSampled* const sampledp = new AstSampled{nodep->fileline(), nodep};
sampledp->dtypeFrom(nodep);
return sampledp;
}
Expand All @@ -153,7 +153,7 @@ class AssertVisitor final : public VNVisitor {
nodep->findUInt64DType()};
v3Global.rootp()->dollarUnitPkgAddp()->addStmtsp(m_monitorNumVarp);
}
const auto varrefp = new AstVarRef{nodep->fileline(), m_monitorNumVarp, access};
AstVarRef* const varrefp = new AstVarRef{nodep->fileline(), m_monitorNumVarp, access};
varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp());
return varrefp;
}
Expand All @@ -163,7 +163,7 @@ class AssertVisitor final : public VNVisitor {
nodep->findBitDType()};
v3Global.rootp()->dollarUnitPkgAddp()->addStmtsp(m_monitorOffVarp);
}
const auto varrefp = new AstVarRef{nodep->fileline(), m_monitorOffVarp, access};
AstVarRef* const varrefp = new AstVarRef{nodep->fileline(), m_monitorOffVarp, access};
varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp());
return varrefp;
}
Expand Down Expand Up @@ -528,7 +528,7 @@ class AssertVisitor final : public VNVisitor {
replaceDisplay(nodep, "%%Fatal");
} else if (nodep->displayType() == VDisplayType::DT_MONITOR) {
nodep->displayType(VDisplayType::DT_DISPLAY);
const auto fl = nodep->fileline();
FileLine* const fl = nodep->fileline();
AstNode* monExprsp = nodep->fmtp()->exprsp();
AstSenItem* monSenItemsp = nullptr;
while (monExprsp) {
Expand All @@ -548,8 +548,8 @@ class AssertVisitor final : public VNVisitor {
AstSenTree* const monSenTree = new AstSenTree{fl, monSenItemsp};
const auto monNum = ++m_monitorNum;
// Where $monitor was we do "__VmonitorNum = N;"
const auto newsetp = new AstAssign{fl, newMonitorNumVarRefp(nodep, VAccess::WRITE),
new AstConst{fl, monNum}};
AstAssign* const newsetp = new AstAssign{
fl, newMonitorNumVarRefp(nodep, VAccess::WRITE), new AstConst{fl, monNum}};
nodep->replaceWith(newsetp);
// Add "always_comb if (__VmonitorOn && __VmonitorNum==N) $display(...);"
AstNode* const stmtsp = nodep;
Expand All @@ -566,14 +566,14 @@ class AssertVisitor final : public VNVisitor {
} else if (nodep->displayType() == VDisplayType::DT_STROBE) {
nodep->displayType(VDisplayType::DT_DISPLAY);
// Need one-shot
const auto fl = nodep->fileline();
const auto varp
FileLine* const fl = nodep->fileline();
AstVar* const varp
= new AstVar{fl, VVarType::MODULETEMP, "__Vstrobe" + cvtToStr(m_modStrobeNum++),
nodep->findBitDType()};
m_modp->addStmtsp(varp);
// Where $strobe was we do "__Vstrobe = '1;"
const auto newsetp = new AstAssign{fl, new AstVarRef{fl, varp, VAccess::WRITE},
new AstConst{fl, AstConst::BitTrue{}}};
AstAssign* const newsetp = new AstAssign{fl, new AstVarRef{fl, varp, VAccess::WRITE},
new AstConst{fl, AstConst::BitTrue{}}};
nodep->replaceWith(newsetp);
// Add "always_comb if (__Vstrobe) begin $display(...); __Vstrobe = '0; end"
AstNode* const stmtsp = nodep;
Expand All @@ -587,7 +587,7 @@ class AssertVisitor final : public VNVisitor {
}
}
void visit(AstMonitorOff* nodep) override {
const auto newp
AstAssign* const newp
= new AstAssign{nodep->fileline(), newMonitorOffVarRefp(nodep, VAccess::WRITE),
new AstConst{nodep->fileline(), AstConst::BitTrue{}, nodep->off()}};
nodep->replaceWith(newp);
Expand Down
4 changes: 4 additions & 0 deletions src/V3AstNodeOther.h
Original file line number Diff line number Diff line change
Expand Up @@ -1878,6 +1878,7 @@ class AstVar final : public AstNode {
bool m_isWrittenByDpi : 1; // This variable can be written by a DPI Export
bool m_isWrittenBySuspendable : 1; // This variable can be written by a suspendable process
bool m_ignorePostWrite : 1; // Ignore writes in 'Post' blocks during ordering
bool m_ignoreSchedWrite : 1; // Ignore writes in scheduling (for coverage increments)

void init() {
m_ansi = false;
Expand Down Expand Up @@ -1923,6 +1924,7 @@ class AstVar final : public AstNode {
m_isWrittenByDpi = false;
m_isWrittenBySuspendable = false;
m_ignorePostWrite = false;
m_ignoreSchedWrite = false;
m_attrClocker = VVarAttrClocker::CLOCKER_UNKNOWN;
}

Expand Down Expand Up @@ -2080,6 +2082,8 @@ class AstVar final : public AstNode {
void setWrittenBySuspendable() { m_isWrittenBySuspendable = true; }
bool ignorePostWrite() const { return m_ignorePostWrite; }
void setIgnorePostWrite() { m_ignorePostWrite = true; }
bool ignoreSchedWrite() const { return m_ignoreSchedWrite; }
void setIgnoreSchedWrite() { m_ignoreSchedWrite = true; }

// METHODS
void name(const string& name) override { m_name = name; }
Expand Down
6 changes: 5 additions & 1 deletion src/V3AstNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2547,6 +2547,8 @@ void AstVar::dump(std::ostream& str) const {
str << " [FUNC]";
}
if (isDpiOpenArray()) str << " [DPIOPENA]";
if (ignorePostWrite()) str << " [IGNPWR]";
if (ignoreSchedWrite()) str << " [IGNWR]";
if (!attrClocker().unknown()) str << " [" << attrClocker().ascii() << "] ";
if (!lifetime().isNone()) str << " [" << lifetime().ascii() << "] ";
str << " " << varType();
Expand Down Expand Up @@ -2579,6 +2581,8 @@ void AstVar::dumpJson(std::ostream& str) const {
dumpJsonBoolFunc(str, isParam);
dumpJsonBoolFunc(str, attrScBv);
dumpJsonBoolFunc(str, attrSFormat);
dumpJsonBoolFunc(str, ignorePostWrite);
dumpJsonBoolFunc(str, ignoreSchedWrite);
dumpJsonGen(str);
}
bool AstVar::sameNode(const AstNode* samep) const {
Expand Down Expand Up @@ -3064,7 +3068,7 @@ AstAlways* AstAssignW::convertToAlways() {
if (hasTimingControl) {
// If there's a timing control, put the assignment in a fork..join_none. This process won't
// get marked as suspendable and thus will be scheduled normally
auto* forkp = new AstFork{flp, "", bodysp};
AstFork* forkp = new AstFork{flp, "", bodysp};
forkp->joinType(VJoinType::JOIN_NONE);
bodysp = forkp;
}
Expand Down
5 changes: 3 additions & 2 deletions src/V3Begin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,9 @@ AstNode* V3Begin::convertToWhile(AstForeach* nodep) {
AstNode* const first_clearp
= new AstAssign{fl, new AstVarRef{fl, first_varp, VAccess::WRITE},
new AstConst{fl, AstConst::BitFalse{}}};
auto* const orp = new AstLogOr{fl, new AstVarRef{fl, first_varp, VAccess::READ},
new AstNeq{fl, new AstConst{fl, 0}, nextp}};
AstLogOr* const orp
= new AstLogOr{fl, new AstVarRef{fl, first_varp, VAccess::READ},
new AstNeq{fl, new AstConst{fl, 0}, nextp}};
AstNode* const whilep = new AstWhile{fl, orp, first_clearp};
first_clearp->addNext(bodyPointp);
AstNode* const ifbodyp
Expand Down
1 change: 1 addition & 0 deletions src/V3Coverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class CoverageVisitor final : public VNVisitor {
fl_nowarn->modifyWarnOff(V3ErrorCode::UNUSEDSIGNAL, true);
AstVar* const varp = new AstVar{fl_nowarn, VVarType::MODULETEMP, trace_var_name,
incp->findUInt32DType()};
varp->setIgnoreSchedWrite(); // Ignore the increment output, so no UNOPTFLAT
varp->trace(true);
m_modp->addStmtsp(varp);
UINFO(5, "New coverage trace: " << varp << endl);
Expand Down
9 changes: 5 additions & 4 deletions src/V3LinkDot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1714,10 +1714,11 @@ class LinkDotFindVisitor final : public VNVisitor {
}
// Type depends on the method used, let V3Width figure it out later
if (nodep->exprsp()) { // Else empty expression and pretend no "with"
const auto indexArgRefp = new AstLambdaArgRef{argFl, name + "__DOT__index", true};
const auto valueArgRefp = new AstLambdaArgRef{argFl, name, false};
const auto newp = new AstWith{nodep->fileline(), indexArgRefp, valueArgRefp,
nodep->exprsp()->unlinkFrBackWithNext()};
AstLambdaArgRef* const indexArgRefp
= new AstLambdaArgRef{argFl, name + "__DOT__index", true};
AstLambdaArgRef* const valueArgRefp = new AstLambdaArgRef{argFl, name, false};
AstWith* const newp = new AstWith{nodep->fileline(), indexArgRefp, valueArgRefp,
nodep->exprsp()->unlinkFrBackWithNext()};
funcrefp->addPinsp(newp);
}
funcrefp->addPinsp(argp);
Expand Down
2 changes: 1 addition & 1 deletion src/V3LinkParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class LinkParseVisitor final : public VNVisitor {
newfl->warnOff(V3ErrorCode::PROCASSWIRE, true);
// Create a ParseRef to the wire. We cannot use the var as it may be deleted if
// it's a port (see t_var_set_link.v)
auto* const assp = new AstAssign{
AstAssign* const assp = new AstAssign{
newfl, new AstParseRef{newfl, VParseRefExp::PX_TEXT, nodep->name()},
VN_AS(nodep->valuep()->unlinkFrBack(), NodeExpr)};
if (nodep->lifetime().isAutomatic()) {
Expand Down
3 changes: 2 additions & 1 deletion src/V3OrderGraphBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ class OrderGraphBuilder final : public VNVisitor {
const bool prevCon = varscp->user2() & VU_CON;

// Compute whether the variable is produced (written) here
bool gen = !prevGen && nodep->access().isWriteOrRW();
const bool gen
= !prevGen && nodep->access().isWriteOrRW() && !varscp->varp()->ignoreSchedWrite();

// Compute whether the value is consumed (read) here
bool con = false;
Expand Down
3 changes: 2 additions & 1 deletion src/V3SchedAcyclic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ std::unique_ptr<Graph> buildGraph(const LogicByScope& lbs) {
// We want to cut the narrowest signals
const int weight = vscp->width() / 8 + 1;
// If written, add logic -> var edge
if (refp->access().isWriteOrRW() && !vscp->user2SetOnce())
if (refp->access().isWriteOrRW() && !refp->varp()->ignoreSchedWrite()
&& !vscp->user2SetOnce())
addEdge(lvtxp, vvtxp, weight, true);
// If read, add var -> logic edge
// Note: Use same heuristic as ordering does to ignore written variables
Expand Down
5 changes: 3 additions & 2 deletions src/V3SchedPartition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class SchedGraphBuilder final : public VNVisitor {
if (vrefp->access().isReadOrRW() && m_readTriggersThisLogic(vscp)) {
new V3GraphEdge{m_graphp, getVarVertex(vscp), logicVtxp, 10};
}
if (vrefp->access().isWriteOrRW()) {
if (vrefp->access().isWriteOrRW() && !vrefp->varp()->ignoreSchedWrite()) {
new V3GraphEdge{m_graphp, logicVtxp, getVarVertex(vscp), 10};
}
});
Expand Down Expand Up @@ -362,7 +362,8 @@ LogicRegions partition(LogicByScope& clockedLogic, LogicByScope& combinationalLo
nodep->foreach([](const AstNodeVarRef* vrefp) {
AstVarScope* const vscp = vrefp->varScopep();
if (vrefp->access().isReadOrRW()) vscp->user1(true);
if (vrefp->access().isWriteOrRW()) vscp->user2(true);
if (vrefp->access().isWriteOrRW() && !vrefp->varp()->ignoreSchedWrite())
vscp->user2(true);
});
};

Expand Down
4 changes: 2 additions & 2 deletions src/V3SchedReplicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ std::unique_ptr<Graph> buildGraph(const LogicRegions& logicRegions) {
// If written, add logic -> var edge
// Note: See V3Order for why AlwaysPostponed is safe to be ignored. We ignore it
// as otherwise we would end up with a false cycle.
if (refp->access().isWriteOrRW() && !vscp->user2SetOnce()
&& !VN_IS(nodep, AlwaysPostponed)) { //
if (refp->access().isWriteOrRW() && !refp->varp()->ignoreSchedWrite()
&& !vscp->user2SetOnce() && !VN_IS(nodep, AlwaysPostponed)) { //
addEdge(lvtxp, vvtxp);
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/V3SchedTiming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ TimingKit prepareTiming(AstNetlist* const netlistp) {
}
}
void visit(AstNodeVarRef* nodep) override {
if (m_gatherVars && nodep->access().isWriteOrRW()
if (m_gatherVars && nodep->access().isWriteOrRW() && !nodep->varp()->ignoreSchedWrite()
&& !nodep->varScopep()->user2SetOnce()) {
m_writtenBySuspendable.push_back(nodep->varScopep());
}
Expand Down Expand Up @@ -338,6 +338,7 @@ void transformForks(AstNetlist* const netlistp) {
iterateChildren(nodep);
}
void visit(AstCFunc* nodep) override {
VL_RESTORER(m_funcp);
m_funcp = nodep;
m_awaitMoved = false;
iterateChildren(nodep);
Expand All @@ -346,7 +347,6 @@ void transformForks(AstNetlist* const netlistp) {
// co_return at the end (either that or a co_await is required in a coroutine
nodep->addStmtsp(new AstCStmt{nodep->fileline(), "co_return;\n"});
}
m_funcp = nullptr;
}
void visit(AstVar* nodep) override {
if (!m_forkp) nodep->user1(true);
Expand Down
1 change: 1 addition & 0 deletions src/V3Undriven.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ class UndrivenVisitor final : public VNVisitorConst {
void warnAlwCombOrder(AstNodeVarRef* nodep) {
AstVar* const varp = nodep->varp();
if (!varp->isParam() && !varp->isGenVar() && !varp->isUsedLoopIdx()
&& !varp->ignoreSchedWrite()
&& !m_inBBox // We may have falsely considered a SysIgnore as a driver
&& !VN_IS(nodep, VarXRef) // Xrefs might point at two different instances
&& !varp->fileline()->warnIsOff(
Expand Down
9 changes: 5 additions & 4 deletions src/V3Width.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ class WidthVisitor final : public VNVisitor {
return;
}
if (VN_IS(vdtypep, UnpackArrayDType)) {
auto* const newp = new AstPattern{nodep->fileline(), nullptr};
AstPattern* const newp = new AstPattern{nodep->fileline(), nullptr};
patConcatConvertRecurse(newp, nodep);
nodep->replaceWith(newp);
VL_DO_DANGLING(pushDeletep(nodep), nodep);
Expand Down Expand Up @@ -796,7 +796,7 @@ class WidthVisitor final : public VNVisitor {
VL_DO_DANGLING(pushDeletep(nodep), nodep);
return;
} else { // int a[] = {lhs} -> same as '{lhs}
auto* const newp = new AstPattern{
AstPattern* const newp = new AstPattern{
nodep->fileline(),
new AstPatMember{nodep->srcp()->fileline(), nodep->srcp()->unlinkFrBack(),
nullptr, nullptr}};
Expand Down Expand Up @@ -4192,7 +4192,8 @@ class WidthVisitor final : public VNVisitor {
if (AstQueueDType* const queuep = m_queueDTypeIndexed[indexDTypep]) {
return queuep;
} else {
auto* const newp = new AstQueueDType{indexDTypep->fileline(), indexDTypep, nullptr};
AstQueueDType* const newp
= new AstQueueDType{indexDTypep->fileline(), indexDTypep, nullptr};
v3Global.rootp()->typeTablep()->addTypesp(newp);
m_queueDTypeIndexed[indexDTypep] = newp;
return newp;
Expand Down Expand Up @@ -5068,7 +5069,7 @@ class WidthVisitor final : public VNVisitor {
iterateCheckAssign(nodep, "Assign RHS", nodep->rhsp(), FINAL, lhsDTypep);
// if (debug()) nodep->dumpTree("- AssignOut: ");
}
if (auto* const controlp = nodep->timingControlp()) {
if (AstNode* const controlp = nodep->timingControlp()) {
if (VN_IS(m_ftaskp, Func)) {
controlp->v3error("Timing controls are not legal in functions. Suggest use a task "
"(IEEE 1800-2023 13.4.4)");
Expand Down
4 changes: 2 additions & 2 deletions src/V3WidthSel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ class WidthSelVisitor final : public VNVisitor {
std::string name = (qleftBacknessp ? "sliceBackBack"
: qrightBacknessp ? "sliceFrontBack"
: "slice");
auto* const newp = new AstCMethodHard{nodep->fileline(), fromp, name,
qleftBacknessp ? qleftBacknessp : qleftp};
AstCMethodHard* const newp = new AstCMethodHard{
nodep->fileline(), fromp, name, qleftBacknessp ? qleftBacknessp : qleftp};
newp->addPinsp(qrightBacknessp ? qrightBacknessp : qrightp);
newp->dtypep(ddtypep);
newp->didWidth(true);
Expand Down
Loading
Loading