From 7ef8a7415d40d3c93662c0cc13bf79f6728d73fd Mon Sep 17 00:00:00 2001 From: David Shah Date: Wed, 3 Oct 2018 12:14:49 +0100 Subject: ice40: Add error for bad PACKAGE_PIN connections Signed-off-by: David Shah --- ice40/pack.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'ice40') diff --git a/ice40/pack.cc b/ice40/pack.cc index 35503298..3c9112a0 100644 --- a/ice40/pack.cc +++ b/ice40/pack.cc @@ -391,6 +391,8 @@ static bool is_nextpnr_iob(Context *ctx, CellInfo *cell) static void pack_io(Context *ctx) { std::unordered_set packed_cells; + std::unordered_set delete_nets; + std::vector> new_cells; log_info("Packing IOs..\n"); @@ -410,14 +412,20 @@ static void pack_io(Context *ctx) log_info("%s feeds SB_IO %s, removing %s %s.\n", ci->name.c_str(ctx), sb->name.c_str(ctx), ci->type.c_str(ctx), ci->name.c_str(ctx)); NetInfo *net = sb->ports.at(ctx->id("PACKAGE_PIN")).net; + if (((ci->type == ctx->id("$nextpnr_ibuf") || ci->type == ctx->id("$nextpnr_iobuf")) && + net->users.size() > 1) || + (ci->type == ctx->id("$nextpnr_obuf") && (net->users.size() > 2 || net->driver.cell != nullptr))) + log_error("PACKAGE_PIN of SB_IO '%s' connected to more than a single top level IO.\n", + sb->name.c_str(ctx)); + if (net != nullptr) { - ctx->nets.erase(net->name); + delete_nets.insert(net->name); sb->ports.at(ctx->id("PACKAGE_PIN")).net = nullptr; } if (ci->type == ctx->id("$nextpnr_iobuf")) { NetInfo *net2 = ci->ports.at(ctx->id("I")).net; if (net2 != nullptr) { - ctx->nets.erase(net2->name); + delete_nets.insert(net2->name); } } } else { @@ -435,6 +443,9 @@ static void pack_io(Context *ctx) for (auto pcell : packed_cells) { ctx->cells.erase(pcell); } + for (auto dnet : delete_nets) { + ctx->nets.erase(dnet); + } for (auto &ncell : new_cells) { ctx->cells[ncell->name] = std::move(ncell); } -- cgit v1.2.3