From f50d4c1ed13142471505e0233e7985052d868ac2 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Sun, 29 Jan 2023 22:04:13 +0100 Subject: [PATCH] ice40: Support for undriven / unconnected output ports If a port specified as output (and thus had a $nextpnr_obuf inserted) is undriven (const `z` or const `x`), we make sure to not enable the output driver. Also enable pull-ups if it was requested by the user. Signed-off-by: Sylvain Munaut --- ice40/cells.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ice40/cells.cc b/ice40/cells.cc index 5e3bd139..10964f3c 100644 --- a/ice40/cells.cc +++ b/ice40/cells.cc @@ -411,7 +411,12 @@ void nxio_to_sb(Context *ctx, CellInfo *nxio, CellInfo *sbio, pool &to nxio->movePortTo(id_O, sbio, id_D_IN_0); pull_up_attr = true; } else if (nxio->type == ctx->id("$nextpnr_obuf")) { - sbio->params[id_PIN_TYPE] = 25; + NetInfo *i = nxio->getPort(id_I); + if (i == nullptr || i->driver.cell == nullptr) { + sbio->params[id_PIN_TYPE] = 1; + pull_up_attr = true; + } else + sbio->params[id_PIN_TYPE] = 25; nxio->movePortTo(id_I, sbio, id_D_OUT_0); } else if (nxio->type == ctx->id("$nextpnr_iobuf")) { // N.B. tristate will be dealt with below