ice40: A slightly nicer way to do this.

This commit is contained in:
Sergiusz Bazanski 2018-07-24 01:36:55 +01:00
parent 065ea95eab
commit dbf79d78bb

View File

@ -444,26 +444,19 @@ void write_asc(const Context *ctx, std::ostream &out)
if (port.second.net == nullptr) if (port.second.net == nullptr)
continue; continue;
// Find SB_IO Bel in net that's driving a wire. That's the one // Get IO Bel that this PLL port goes through.
// we're routing the signal through. // We navigate one pip downhill to the next wire (there should
// TODO(q3k): Is there a nicer way to do this? // be only one). Then, the bel that drives that wire should be
bool found = false; // the SB_IO that we're looking for.
auto wire = ctx->getBelPinWire(cell.second->bel, ctx->portPinFromId(port.second.name));
// For every wire in the PLLOUT net... auto pips = ctx->getPipsDownhill(wire).begin();
for (auto wp : port.second.net->wires) { auto driven_wire = ctx->getPipDstWire(*pips);
// ... get its' uphill bel ... auto io_bel = ctx->chip_info->wire_data[driven_wire.index].bel_uphill.bel_index;
auto bel = ctx->getBelPinUphill(wp.first).bel; auto io_beli = ctx->chip_info->bel_data[io_bel];
if (bel == BelId()) { NPNR_ASSERT(io_beli.type == TYPE_SB_IO);
continue;
}
// ... and check if it's an SB_IO.
if (ctx->getBelType(bel) != TYPE_SB_IO)
continue;
// Check that this SB_IO is either unused or just used as an output. // Check that this SB_IO is either unused or just used as an output.
const BelInfoPOD &io_beli = ci.bel_data[bel.index];
auto io_loc = Loc(io_beli.x, io_beli.y, io_beli.z); auto io_loc = Loc(io_beli.x, io_beli.y, io_beli.z);
if (sb_io_used_by_user.count(io_loc)) { if (sb_io_used_by_user.count(io_loc)) {
log_error("SB_IO '%s' already in use, cannot route PLL through\n", log_error("SB_IO '%s' already in use, cannot route PLL through\n",
ctx->getBelName(bel).c_str(ctx)); ctx->getBelName(bel).c_str(ctx));
@ -485,14 +478,6 @@ void write_asc(const Context *ctx, std::ostream &out)
// PINTYPE[0] passes the PLL through to the fabric. // PINTYPE[0] passes the PLL through to the fabric.
set_config(ti, config.at(io_beli.y).at(io_beli.x), "IOB_" + std::to_string(io_beli.z) + ".PINTYPE_0", true); set_config(ti, config.at(io_beli.y).at(io_beli.x), "IOB_" + std::to_string(io_beli.z) + ".PINTYPE_0", true);
found = true;
break;
}
if (!found) {
log_error("Could not find SB_IO forwarding PLL '%s' %s signal\n",
cell.second->name.c_str(ctx), port.second.name.c_str(ctx));
}
} }
} else { } else {