mirror of https://github.com/YosysHQ/yosys.git
sim: Add `-assert` option to fail on failed assertions
This commit is contained in:
parent
e995dddeaa
commit
d4d951657f
|
@ -109,6 +109,7 @@ struct SimShared
|
||||||
int next_output_id = 0;
|
int next_output_id = 0;
|
||||||
int step = 0;
|
int step = 0;
|
||||||
std::vector<TriggeredAssertion> triggered_assertions;
|
std::vector<TriggeredAssertion> triggered_assertions;
|
||||||
|
bool serious_asserts = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
void zinit(State &v)
|
void zinit(State &v)
|
||||||
|
@ -781,8 +782,12 @@ struct SimInstance
|
||||||
if (cell->type == ID($assume) && en == State::S1 && a != State::S1)
|
if (cell->type == ID($assume) && en == State::S1 && a != State::S1)
|
||||||
log("Assumption %s.%s (%s) failed.\n", hiername().c_str(), log_id(cell), label.c_str());
|
log("Assumption %s.%s (%s) failed.\n", hiername().c_str(), log_id(cell), label.c_str());
|
||||||
|
|
||||||
if (cell->type == ID($assert) && en == State::S1 && a != State::S1)
|
if (cell->type == ID($assert) && en == State::S1 && a != State::S1) {
|
||||||
log_warning("Assert %s.%s (%s) failed.\n", hiername().c_str(), log_id(cell), label.c_str());
|
if (shared->serious_asserts)
|
||||||
|
log_error("Assert %s.%s (%s) failed.\n", hiername().c_str(), log_id(cell), label.c_str());
|
||||||
|
else
|
||||||
|
log_warning("Assert %s.%s (%s) failed.\n", hiername().c_str(), log_id(cell), label.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2497,6 +2502,10 @@ struct SimPass : public Pass {
|
||||||
log(" -sim-gate\n");
|
log(" -sim-gate\n");
|
||||||
log(" co-simulation, x in FST can match any value in simulation\n");
|
log(" co-simulation, x in FST can match any value in simulation\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
|
log(" -assert\n");
|
||||||
|
log(" fail the simulation command if, in the course of simulating,\n");
|
||||||
|
log(" any of the asserts in the design fail\n");
|
||||||
|
log("\n");
|
||||||
log(" -q\n");
|
log(" -q\n");
|
||||||
log(" disable per-cycle/sample log message\n");
|
log(" disable per-cycle/sample log message\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
|
@ -2651,6 +2660,10 @@ struct SimPass : public Pass {
|
||||||
worker.sim_mode = SimulationMode::gate;
|
worker.sim_mode = SimulationMode::gate;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (args[argidx] == "-assert") {
|
||||||
|
worker.serious_asserts = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (args[argidx] == "-x") {
|
if (args[argidx] == "-x") {
|
||||||
worker.ignore_x = true;
|
worker.ignore_x = true;
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue