mirror of
https://github.com/verilator/verilator.git
synced 2026-09-01 10:27:04 +02:00
@@ -367,7 +367,26 @@ void VlRandomizer::randomConstraint(std::ostream& os, VlRNG& rngr, int bits) {
|
||||
}
|
||||
|
||||
bool VlRandomizer::next(VlRNG& rngr) {
|
||||
if (m_vars.empty()) return true;
|
||||
if (m_vars.empty() && m_unique_arrays.empty()) return true;
|
||||
for (const std::string& baseName : m_unique_arrays) {
|
||||
const auto it = m_vars.find(baseName);
|
||||
|
||||
// Look up the actual size we stored earlier
|
||||
// const uint32_t size = m_unique_array_sizes[baseName];
|
||||
const uint32_t size = m_unique_array_sizes.at(baseName);
|
||||
|
||||
if (it != m_vars.end()) {
|
||||
std::string distinctExpr = "(__Vbv (distinct";
|
||||
for (uint32_t i = 0; i < size; ++i) {
|
||||
char hexIdx[12];
|
||||
sprintf(hexIdx, "#x%08x", i);
|
||||
distinctExpr += " (select " + it->first + " " + hexIdx + ")";
|
||||
}
|
||||
distinctExpr += "))";
|
||||
m_constraints.push_back(distinctExpr);
|
||||
}
|
||||
}
|
||||
|
||||
std::iostream& os = getSolver();
|
||||
if (!os) return false;
|
||||
|
||||
@@ -384,6 +403,7 @@ bool VlRandomizer::next(VlRNG& rngr) {
|
||||
var.second->emitType(os);
|
||||
os << ")\n";
|
||||
}
|
||||
|
||||
for (const std::string& constraint : m_constraints) {
|
||||
os << "(assert (= #b1 " << constraint << "))\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user