From 9aa22433ff12d8e0d8edd7bba7d6fa27f097198f Mon Sep 17 00:00:00 2001 From: David Shah Date: Tue, 25 Feb 2020 14:26:47 +0000 Subject: Improve handling of unused inout port bits Signed-off-by: David Shah --- ecp5/cells.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'ecp5') diff --git a/ecp5/cells.cc b/ecp5/cells.cc index c630c2c3..7f9f1579 100644 --- a/ecp5/cells.cc +++ b/ecp5/cells.cc @@ -432,7 +432,13 @@ void nxio_to_tr(Context *ctx, CellInfo *nxio, CellInfo *trio, std::vectorid("I"), trio, ctx->id("I")); } else if (nxio->type == ctx->id("$nextpnr_iobuf")) { // N.B. tristate will be dealt with below - trio->params[ctx->id("DIR")] = std::string("BIDIR"); + NetInfo *i = get_net_or_empty(nxio, ctx->id("I")); + if (i == nullptr || i->driver.cell == nullptr) + trio->params[ctx->id("DIR")] = std::string("INPUT"); + else { + log_info("%s: %s.%s\n", ctx->nameOf(i), ctx->nameOf(i->driver.cell), ctx->nameOf(i->driver.port)); + trio->params[ctx->id("DIR")] = std::string("BIDIR"); + } replace_port(nxio, ctx->id("I"), trio, ctx->id("I")); replace_port(nxio, ctx->id("O"), trio, ctx->id("O")); } else { @@ -446,6 +452,15 @@ void nxio_to_tr(Context *ctx, CellInfo *nxio, CellInfo *trio, std::vectorname == nxio->name) rename_net(ctx, dinet, ctx->id(dinet->name.str(ctx) + "$TRELLIS_IO_IN")); + if (ctx->nets.count(nxio->name)) { + int i = 0; + IdString new_name; + do { + new_name = ctx->id(nxio->name.str(ctx) + "$rename$" + std::to_string(i++)); + } while (ctx->nets.count(new_name)); + rename_net(ctx, ctx->nets.at(nxio->name).get(), new_name); + } + // 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; -- cgit v1.2.3