aboutsummaryrefslogtreecommitdiffstats
path: root/ice40/cells.cc
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2019-10-18 16:32:55 +0100
committerDavid Shah <dave@ds0.me>2019-10-19 13:01:00 +0100
commita22f86f86192bbd782cc2fd430b2900ddb6740cc (patch)
tree43af43110d3e837fcff3deb2bbbb1e90074f4cc9 /ice40/cells.cc
parentcf5cbd1153c3ebaf6bcff98f2d936e1663407dff (diff)
downloadnextpnr-a22f86f86192bbd782cc2fd430b2900ddb6740cc.tar.gz
nextpnr-a22f86f86192bbd782cc2fd430b2900ddb6740cc.tar.bz2
nextpnr-a22f86f86192bbd782cc2fd430b2900ddb6740cc.zip
ice40: Preserve top level IO properly
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'ice40/cells.cc')
-rw-r--r--ice40/cells.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/ice40/cells.cc b/ice40/cells.cc
index c4e93d5b..3f1a0fbf 100644
--- a/ice40/cells.cc
+++ b/ice40/cells.cc
@@ -426,7 +426,25 @@ void nxio_to_sb(Context *ctx, CellInfo *nxio, CellInfo *sbio, std::unordered_set
} else {
NPNR_ASSERT(false);
}
- NetInfo *donet = sbio->ports.at(ctx->id("D_OUT_0")).net;
+ NetInfo *donet = sbio->ports.at(ctx->id("D_OUT_0")).net, *dinet = sbio->ports.at(ctx->id("D_IN_0")).net;
+
+ // Rename I/O nets to avoid conflicts
+ if (donet != nullptr && donet->name == nxio->name)
+ rename_net(ctx, donet, ctx->id(donet->name.str(ctx) + "$SB_IO_OUT"));
+ if (dinet != nullptr && dinet->name == nxio->name)
+ rename_net(ctx, dinet, ctx->id(dinet->name.str(ctx) + "$SB_IO_IN"));
+
+ // Create a new top port net for accurate IO timing analysis and simulation netlists
+ if (ctx->ports.count(nxio->name)) {
+ IdString tn_netname = nxio->name;
+ NPNR_ASSERT(!ctx->nets.count(tn_netname));
+ std::unique_ptr<NetInfo> toplevel_net{new NetInfo};
+ toplevel_net->name = tn_netname;
+ connect_port(ctx, toplevel_net.get(), sbio, ctx->id("PACKAGE_PIN"));
+ ctx->ports[nxio->name].net = toplevel_net.get();
+ ctx->nets[tn_netname] = std::move(toplevel_net);
+ }
+
CellInfo *tbuf = net_driven_by(
ctx, donet, [](const Context *ctx, const CellInfo *cell) { return cell->type == ctx->id("$_TBUF_"); },
ctx->id("Y"));