Revert 'Fix --x-initial and --x-assign random stability (#2662) (#5958).' See (#6018).

Reverts 4581023805 plus line in Changes file
This commit is contained in:
Wilson Snyder
2025-05-17 20:27:03 -04:00
parent 647404ec1e
commit 640339ec36
36 changed files with 45 additions and 675 deletions
+5 -34
View File
@@ -753,9 +753,7 @@ string EmitCFunc::emitVarResetRecurse(const AstVar* varp, bool constructing,
|| varp->isFuncLocal() // Randomization too slow
|| (basicp && basicp->isZeroInit())
|| (v3Global.opt.underlineZero() && !varp->name().empty() && varp->name()[0] == '_')
|| (varp->isXTemp()
? (v3Global.opt.xAssign() != "unique")
: (v3Global.opt.xInitial() == "fast" || v3Global.opt.xInitial() == "0")));
|| (v3Global.opt.xInitial() == "fast" || v3Global.opt.xInitial() == "0"));
const bool slow = !varp->isFuncLocal() && !varp->isClassMember();
splitSizeInc(1);
if (dtypep->isWide()) { // Handle unpacked; not basicp->isWide
@@ -768,20 +766,9 @@ string EmitCFunc::emitVarResetRecurse(const AstVar* varp, bool constructing,
out += cvtToStr(constp->num().edataWord(w)) + "U;\n";
}
} else {
out += zeroit ? (slow ? "VL_ZERO_RESET_W(" : "VL_ZERO_W(")
: "VL_SCOPED_RAND_RESET_W(";
out += zeroit ? (slow ? "VL_ZERO_RESET_W(" : "VL_ZERO_W(") : "VL_RAND_RESET_W(";
out += cvtToStr(dtypep->widthMin());
out += ", " + varNameProtected + suffix;
if (!zeroit) {
emitVarResetScopeHash();
const uint64_t salt = VString::hashMurmur(varp->prettyName());
out += ", ";
out += m_classOrPackage ? m_classOrPackageHash : "__VscopeHash";
out += ", ";
out += std::to_string(salt);
out += "ull";
}
out += ");\n";
out += ", " + varNameProtected + suffix + ");\n";
}
return out;
} else {
@@ -794,13 +781,9 @@ string EmitCFunc::emitVarResetRecurse(const AstVar* varp, bool constructing,
if (zeroit || (v3Global.opt.xInitialEdge() && varp->isUsedClock())) {
out += " = 0;\n";
} else {
emitVarResetScopeHash();
const uint64_t salt = VString::hashMurmur(varp->prettyName());
out += " = VL_SCOPED_RAND_RESET_";
out += " = VL_RAND_RESET_";
out += dtypep->charIQWN();
out += "(" + cvtToStr(dtypep->widthMin()) + ", "
+ (m_classOrPackage ? m_classOrPackageHash : "__VscopeHash") + ", "
+ std::to_string(salt) + "ull);\n";
out += "(" + cvtToStr(dtypep->widthMin()) + ");\n";
}
return out;
}
@@ -809,15 +792,3 @@ string EmitCFunc::emitVarResetRecurse(const AstVar* varp, bool constructing,
}
return "";
}
void EmitCFunc::emitVarResetScopeHash() {
if (VL_LIKELY(m_createdScopeHash)) { return; }
if (m_classOrPackage) {
m_classOrPackageHash
= std::to_string(VString::hashMurmur(m_classOrPackage->name())) + "ULL";
} else {
puts(string("const uint64_t __VscopeHash = VL_HASH(")
+ (m_useSelfForThis ? "vlSelf" : "this") + "->name());\n");
}
m_createdScopeHash = true;
}