Skip to content

Commit

Permalink
sim: Add -assert option to fail on failed assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
povik committed Sep 5, 2023
1 parent e995ddd commit d4d9516
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions passes/sat/sim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ struct SimShared
int next_output_id = 0;
int step = 0;
std::vector<TriggeredAssertion> triggered_assertions;
bool serious_asserts = false;
};

void zinit(State &v)
Expand Down Expand Up @@ -781,8 +782,12 @@ struct SimInstance
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());

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 (cell->type == ID($assert) && en == State::S1 && a != State::S1) {
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());
}
}
}

Expand Down Expand Up @@ -2497,6 +2502,10 @@ struct SimPass : public Pass {
log(" -sim-gate\n");
log(" co-simulation, x in FST can match any value in simulation\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(" disable per-cycle/sample log message\n");
log("\n");
Expand Down Expand Up @@ -2651,6 +2660,10 @@ struct SimPass : public Pass {
worker.sim_mode = SimulationMode::gate;
continue;
}
if (args[argidx] == "-assert") {
worker.serious_asserts = true;
continue;
}
if (args[argidx] == "-x") {
worker.ignore_x = true;
continue;
Expand Down

0 comments on commit d4d9516

Please sign in to comment.