nexus: IO packing fix

Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
David Shah 2020-10-12 13:58:58 +01:00
parent df3866a800
commit 10ad7d9cfe

View File

@ -494,7 +494,7 @@ struct NexusPacker
if (o == nullptr) if (o == nullptr)
; ;
else if (o->users.size() > 1) else if (o->users.size() > 1)
log_error("Top level '%s' has multiple input buffers\n", ctx->nameOf(port.first)); log_error("Top level pin '%s' has multiple input buffers\n", ctx->nameOf(port.first));
else if (o->users.size() == 1) else if (o->users.size() == 1)
top_port = o->users.at(0); top_port = o->users.at(0);
} }
@ -504,9 +504,22 @@ struct NexusPacker
NetInfo *i = get_net_or_empty(ci, id_I); NetInfo *i = get_net_or_empty(ci, id_I);
if (i != nullptr && i->driver.cell != nullptr) { if (i != nullptr && i->driver.cell != nullptr) {
if (top_port.cell != nullptr) if (top_port.cell != nullptr)
log_error("Top level '%s' has multiple input/output buffers\n", ctx->nameOf(port.first)); log_error("Top level pin '%s' has multiple input/output buffers\n", ctx->nameOf(port.first));
top_port = i->driver; top_port = i->driver;
} }
// Edge case of a bidirectional buffer driving an output pin
if (i->users.size() > 2) {
log_error("Top level pin '%s' has illegal buffer configuration\n", ctx->nameOf(port.first));
} else if (i->users.size() == 2) {
if (top_port.cell != nullptr)
log_error("Top level pin '%s' has illegal buffer configuration\n", ctx->nameOf(port.first));
for (auto &usr : i->users) {
if (usr.cell->type == ctx->id("$nextpnr_obuf") || usr.cell->type == ctx->id("$nextpnr_iobuf"))
continue;
top_port = usr;
break;
}
}
} }
if (!is_npnr_iob) if (!is_npnr_iob)
log_error("Port '%s' doesn't seem to have a corresponding top level IO (internal cell type mismatch)\n", log_error("Port '%s' doesn't seem to have a corresponding top level IO (internal cell type mismatch)\n",