From a8071a418ddb35698cf1b9958c6caddc2e839cb2 Mon Sep 17 00:00:00 2001 From: David Shah Date: Tue, 19 Jun 2018 14:10:28 +0200 Subject: ice40: Improve error reporting for invalid tristate usage Signed-off-by: David Shah --- ice40/cells.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'ice40/cells.cc') diff --git a/ice40/cells.cc b/ice40/cells.cc index 6a8e7b5e..582e5c14 100644 --- a/ice40/cells.cc +++ b/ice40/cells.cc @@ -37,7 +37,7 @@ CellInfo *create_ice_cell(Context *ctx, IdString type, std::string name) CellInfo *new_cell = new CellInfo(); if (name.empty()) { new_cell->name = IdString(ctx, "$nextpnr_" + type.str() + "_" + - std::to_string(auto_idx++)); + std::to_string(auto_idx++)); } else { new_cell->name = ctx->id(name); } @@ -200,8 +200,8 @@ void nxio_to_sb(Context *ctx, CellInfo *nxio, CellInfo *sbio) } NetInfo *donet = sbio->ports.at(ctx->id("D_OUT_0")).net; CellInfo *tbuf = - net_driven_by(ctx, donet, [] - (const Context *ctx, const CellInfo *cell) { + net_driven_by(ctx, donet, + [](const Context *ctx, const CellInfo *cell) { return cell->type == ctx->id("$_TBUF_"); }, "Y"); @@ -210,6 +210,10 @@ void nxio_to_sb(Context *ctx, CellInfo *nxio, CellInfo *sbio) replace_port(tbuf, "A", sbio, "D_OUT_0"); replace_port(tbuf, "E", sbio, "OUTPUT_ENABLE"); ctx->nets.erase(donet->name); + if (!donet->users.empty()) + log_error("unsupported tristate IO pattern for IO buffer '%s', " + "instantiate SB_IO manually to ensure correct behaviour\n", + nxio->name.c_str(ctx)); ctx->cells.erase(tbuf->name); } } @@ -251,7 +255,8 @@ bool is_enable_port(const Context *ctx, const PortRef &port) bool is_global_net(const Context *ctx, const NetInfo *net) { - return bool(net_driven_by(ctx, net, is_gbuf, ctx->id("GLOBAL_BUFFER_OUTPUT"))); + return bool( + net_driven_by(ctx, net, is_gbuf, ctx->id("GLOBAL_BUFFER_OUTPUT"))); } NEXTPNR_NAMESPACE_END -- cgit v1.2.3