Merge pull request #488 from YosysHQ/dave/port_fanin_fix

timing: Fix counting of fanin in out-of-context mode
This commit is contained in:
David Shah 2020-08-12 16:38:46 +01:00 committed by GitHub
commit b0dedf1a22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -132,6 +132,18 @@ struct Timing
std::vector<IdString> input_ports; std::vector<IdString> input_ports;
std::vector<const PortInfo *> output_ports; std::vector<const PortInfo *> output_ports;
std::unordered_set<IdString> ooc_port_nets;
// In out-of-context mode, top-level inputs look floating but aren't
if (bool_or_default(ctx->settings, ctx->id("arch.ooc"))) {
for (auto &p : ctx->ports) {
if (p.second.type != PORT_IN || p.second.net == nullptr)
continue;
ooc_port_nets.insert(p.second.net->name);
}
}
for (auto &cell : ctx->cells) { for (auto &cell : ctx->cells) {
input_ports.clear(); input_ports.clear();
output_ports.clear(); output_ports.clear();
@ -177,7 +189,8 @@ struct Timing
// the current output port, increment fanin counter // the current output port, increment fanin counter
for (auto i : input_ports) { for (auto i : input_ports) {
DelayInfo comb_delay; DelayInfo comb_delay;
if (cell.second->ports[i].net->driver.cell == nullptr) NetInfo *i_net = cell.second->ports[i].net;
if (i_net->driver.cell == nullptr && !ooc_port_nets.count(i_net->name))
continue; continue;
bool is_path = ctx->getCellDelay(cell.second.get(), i, o->name, comb_delay); bool is_path = ctx->getCellDelay(cell.second.get(), i, o->name, comb_delay);
if (is_path) if (is_path)
@ -232,7 +245,9 @@ struct Timing
// Decrement the fanin count, and only add to topological order if all its fanins have already // Decrement the fanin count, and only add to topological order if all its fanins have already
// been visited // been visited
auto it = port_fanin.find(&port.second); auto it = port_fanin.find(&port.second);
NPNR_ASSERT(it != port_fanin.end()); if (it == port_fanin.end())
log_error("Timing counted negative fanin count for port %s.%s (net %s), please report this error.\n",
ctx->nameOf(usr.cell), ctx->nameOf(port.first), ctx->nameOf(port.second.net));
if (--it->second == 0) { if (--it->second == 0) {
topological_order.emplace_back(port.second.net); topological_order.emplace_back(port.second.net);
queue.emplace_back(port.second.net); queue.emplace_back(port.second.net);