aboutsummaryrefslogtreecommitdiffstats
path: root/ice40
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2023-01-29 21:11:54 +0100
committerSylvain Munaut <tnt@246tNt.com>2023-01-29 22:35:19 +0100
commit0cf5006e3bbad476616f09bf1baf8a2953e1c616 (patch)
treee16fb259db8b9ad79cbd88e8dfc5b9cb7fbeb7a2 /ice40
parentf80b871dd54b5215480a8eb00313a7ac16d9e883 (diff)
downloadnextpnr-0cf5006e3bbad476616f09bf1baf8a2953e1c616.tar.gz
nextpnr-0cf5006e3bbad476616f09bf1baf8a2953e1c616.tar.bz2
nextpnr-0cf5006e3bbad476616f09bf1baf8a2953e1c616.zip
ice40: Rework pull-up attribute copy to SB_IO blocks
We try to copy the attribute only when there is a chance for the output driver to not be active. Note that this can _also_ happen when a port is specified as output but has a TBUF, which the previous code wasn't handling. We could copy the attribute "all-the-time" but this would mean if a user specified a `-pullup yes` in the PCF for a permanently driven output pin, we'd be burning power for nothing. Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'ice40')
-rw-r--r--ice40/cells.cc22
1 files changed, 14 insertions, 8 deletions
diff --git a/ice40/cells.cc b/ice40/cells.cc
index fc24caaf..5e3bd139 100644
--- a/ice40/cells.cc
+++ b/ice40/cells.cc
@@ -404,25 +404,23 @@ void dff_to_lc(const Context *ctx, CellInfo *dff, CellInfo *lc, bool pass_thru_l
void nxio_to_sb(Context *ctx, CellInfo *nxio, CellInfo *sbio, pool<IdString> &todelete_cells)
{
+ bool pull_up_attr = false;
+
if (nxio->type == ctx->id("$nextpnr_ibuf")) {
sbio->params[id_PIN_TYPE] = 1;
- auto pu_attr = nxio->attrs.find(id_PULLUP);
- if (pu_attr != nxio->attrs.end())
- sbio->params[id_PULLUP] = pu_attr->second;
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;
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
NetInfo *i = nxio->getPort(id_I);
- if (i == nullptr || i->driver.cell == nullptr)
+ if (i == nullptr || i->driver.cell == nullptr) {
sbio->params[id_PIN_TYPE] = 1;
- else
+ pull_up_attr = true;
+ } else
sbio->params[id_PIN_TYPE] = 25;
- auto pu_attr = nxio->attrs.find(id_PULLUP);
- if (pu_attr != nxio->attrs.end())
- sbio->params[id_PULLUP] = pu_attr->second;
nxio->movePortTo(id_I, sbio, id_D_OUT_0);
nxio->movePortTo(id_O, sbio, id_D_IN_0);
} else {
@@ -465,6 +463,7 @@ void nxio_to_sb(Context *ctx, CellInfo *nxio, CellInfo *sbio, pool<IdString> &to
sbio->params[id_PIN_TYPE] = 41;
tbuf->movePortTo(id_A, sbio, id_D_OUT_0);
tbuf->movePortTo(id_E, sbio, id_OUTPUT_ENABLE);
+ pull_up_attr = true;
if (donet->users.entries() > 1) {
for (auto user : donet->users)
@@ -476,6 +475,13 @@ void nxio_to_sb(Context *ctx, CellInfo *nxio, CellInfo *sbio, pool<IdString> &to
ctx->nets.erase(donet->name);
todelete_cells.insert(tbuf->name);
}
+
+ // Copy pull-up attribute if there's any chance output driver isn't active
+ if (pull_up_attr) {
+ auto pu_attr = nxio->attrs.find(id_PULLUP);
+ if (pu_attr != nxio->attrs.end())
+ sbio->params[id_PULLUP] = pu_attr->second;
+ }
}
uint8_t sb_pll40_type(const BaseCtx *ctx, const CellInfo *cell)