mirror of https://github.com/YosysHQ/yosys.git
sim.cc: Check eval err
Some cells (e.g. $macc_v2) are marked evaluable, but will raise an abort if called with `CellTypes::eval()`. Instead of falling through to the abort, we can pass a pointer to a boolean to check for errors. Use said check to catch `CellTypes::eval()` errors and treat them as unevaluable but otherwise continue. Reflows the series of if checks into `if ... else if ... else` so that we can check for errors and set state in one place.
This commit is contained in:
parent
2833a44503
commit
5b317ee03c
|
|
@ -549,31 +549,27 @@ struct SimInstance
|
||||||
if (shared->debug)
|
if (shared->debug)
|
||||||
log("[%s] eval %s (%s)\n", hiername(), log_id(cell), log_id(cell->type));
|
log("[%s] eval %s (%s)\n", hiername(), log_id(cell), log_id(cell->type));
|
||||||
|
|
||||||
// Simple (A -> Y) and (A,B -> Y) cells
|
bool err = false;
|
||||||
if (has_a && !has_c && !has_d && !has_s && has_y) {
|
RTLIL::Const eval_state;
|
||||||
set_state(sig_y, CellTypes::eval(cell, get_state(sig_a), get_state(sig_b)));
|
if (has_a && !has_c && !has_d && !has_s && has_y)
|
||||||
return;
|
// Simple (A -> Y) and (A,B -> Y) cells
|
||||||
}
|
eval_state = CellTypes::eval(cell, get_state(sig_a), get_state(sig_b), &err);
|
||||||
|
else if (has_a && has_b && has_c && !has_d && !has_s && has_y)
|
||||||
|
// (A,B,C -> Y) cells
|
||||||
|
eval_state = CellTypes::eval(cell, get_state(sig_a), get_state(sig_b), get_state(sig_c), &err);
|
||||||
|
else if (has_a && !has_b && !has_c && !has_d && has_s && has_y)
|
||||||
|
// (A,S -> Y) cells
|
||||||
|
eval_state = CellTypes::eval(cell, get_state(sig_a), get_state(sig_s), &err);
|
||||||
|
else if (has_a && has_b && !has_c && !has_d && has_s && has_y)
|
||||||
|
// (A,B,S -> Y) cells
|
||||||
|
eval_state = CellTypes::eval(cell, get_state(sig_a), get_state(sig_b), get_state(sig_s), &err);
|
||||||
|
else
|
||||||
|
err = true;
|
||||||
|
|
||||||
// (A,B,C -> Y) cells
|
if (err)
|
||||||
if (has_a && has_b && has_c && !has_d && !has_s && has_y) {
|
log_warning("Unsupported evaluable cell type: %s (%s.%s)\n", log_id(cell->type), log_id(module), log_id(cell));
|
||||||
set_state(sig_y, CellTypes::eval(cell, get_state(sig_a), get_state(sig_b), get_state(sig_c)));
|
else
|
||||||
return;
|
set_state(sig_y, eval_state);
|
||||||
}
|
|
||||||
|
|
||||||
// (A,S -> Y) cells
|
|
||||||
if (has_a && !has_b && !has_c && !has_d && has_s && has_y) {
|
|
||||||
set_state(sig_y, CellTypes::eval(cell, get_state(sig_a), get_state(sig_s)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// (A,B,S -> Y) cells
|
|
||||||
if (has_a && has_b && !has_c && !has_d && has_s && has_y) {
|
|
||||||
set_state(sig_y, CellTypes::eval(cell, get_state(sig_a), get_state(sig_b), get_state(sig_s)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_warning("Unsupported evaluable cell type: %s (%s.%s)\n", log_id(cell->type), log_id(module), log_id(cell));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue