Skip to content

Commit

Permalink
flatten: add -insertbarriers flag
Browse files Browse the repository at this point in the history
* This uses $barrier optimization barriers to connect wires into the
  flattened module instead of connections
  • Loading branch information
georgerennie committed Nov 20, 2024
1 parent f27bf7a commit f01e37c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion passes/techmap/flatten.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct FlattenWorker
bool ignore_wb = false;
bool create_scopeinfo = true;
bool create_scopename = false;
bool insert_barriers = false;

template<class T>
void map_attributes(RTLIL::Cell *cell, T *object, IdString orig_object_name)
Expand Down Expand Up @@ -246,7 +247,11 @@ struct FlattenWorker
log_error("Cell port %s.%s.%s is driving constant bits: %s <= %s\n",
log_id(module), log_id(cell), log_id(port_it.first), log_signal(new_conn.first), log_signal(new_conn.second));

module->connect(new_conn);
if (insert_barriers)
module->addBarrier(NEW_ID, new_conn.second, new_conn.first);
else
module->connect(new_conn);

sigmap.add(new_conn.first, new_conn.second);
}

Expand Down Expand Up @@ -345,6 +350,11 @@ struct FlattenPass : public Pass {
log(" with a public name the enclosing scope can be found via their\n");
log(" 'hdlname' attribute.\n");
log("\n");
log(" -insertbarriers\n");
log(" Use $barrier cells to connect flattened modules to their surrounding\n");
log(" scope instead of connections. This prevents optimization passes\n");
log(" optimizing through the connection.\n");
log("\n");
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
Expand All @@ -367,6 +377,10 @@ struct FlattenPass : public Pass {
worker.create_scopename = true;
continue;
}
if (args[argidx] == "-insertbarriers") {
worker.insert_barriers = true;
continue;
}
break;
}
extra_args(args, argidx, design);
Expand Down

0 comments on commit f01e37c

Please sign in to comment.