Skip to content

Commit

Permalink
test_cell: add -noopt, add stats for failed cells
Browse files Browse the repository at this point in the history
  • Loading branch information
widlarizer committed May 13, 2024
1 parent ccfed6e commit 30bda9e
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions passes/tests/test_cell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,9 @@ struct TestCellPass : public Pass {
log(" -noeval\n");
log(" do not check const-eval models\n");
log("\n");
log(" -noopt\n");
log(" do not opt tecchmapped design\n");
log("\n");
log(" -edges\n");
log(" test cell edges db creator against sat-based implementation\n");
log("\n");
Expand Down Expand Up @@ -782,6 +785,7 @@ struct TestCellPass : public Pass {
bool constmode = false;
bool nosat = false;
bool noeval = false;
bool noopt = false;
bool edges = false;
bool check_cost = false;

Expand Down Expand Up @@ -837,6 +841,10 @@ struct TestCellPass : public Pass {
noeval = true;
continue;
}
if (args[argidx] == "-noopt") {
noopt = true;
continue;
}
if (args[argidx] == "-edges") {
edges = true;
continue;
Expand Down Expand Up @@ -982,7 +990,13 @@ struct TestCellPass : public Pass {

std::vector<std::string> uut_names;

for (auto cell_type : selected_cell_types)
for (auto cell_type : selected_cell_types) {
// Cells that failed cell cost check
int failed = 0;
// How much bigger is the worst offender than estimated?
int worst_abs = 0;
// How many times is it bigger than estimated?
float worst_rel = 0.0;
for (int i = 0; i < num_iter; i++)
{
Cell* uut = nullptr;
Expand All @@ -997,7 +1011,9 @@ struct TestCellPass : public Pass {
Pass::call(design, "dump gold");
run_edges_test(design, verbose);
} else {
Pass::call(design, stringf("copy gold gate; cd gate; %s; cd ..; opt -fast gate", techmap_cmd.c_str()));
Pass::call(design, stringf("copy gold gate; cd gate; %s; cd ..", techmap_cmd.c_str()));
if (!noopt)
Pass::call(design, "opt -fast gate");
if (!nosat)
Pass::call(design, "miter -equiv -flatten -make_outputs -ignore_gold_x gold gate miter");
if (verbose)
Expand Down Expand Up @@ -1032,17 +1048,23 @@ struct TestCellPass : public Pass {
// Expected to run once
int num_cells_estimate = costs.get(uut);
if (num_cells <= num_cells_estimate) {
// correct
log_debug("Correct upper bound for %s: %d <= %d\n", cell_type.c_str(), num_cells, num_cells_estimate);
} else {
failed++;
worst_abs = num_cells - num_cells_estimate;
worst_rel = (num_cells - num_cells_estimate) / num_cells;
log_warning("Upper bound violated for %s: %d > %d\n", cell_type.c_str(), num_cells, num_cells_estimate);
}
}
}
}
delete design;
}

if (check_cost && failed) {
log_warning("Cell type %s failed in %.1f%% cases with worse offender being by %d (%.1f%%)\n", cell_type.c_str(),
100 * (float)failed / (float)num_iter, worst_abs, 100 * worst_rel);
}
}
if (vlog_file.is_open()) {
vlog_file << "\nmodule testbench;\n";
for (auto &uut : uut_names)
Expand Down

0 comments on commit 30bda9e

Please sign in to comment.