aboutsummaryrefslogtreecommitdiffstats
path: root/ice40
diff options
context:
space:
mode:
authorStefan Riesenberger <stefan.riesenberger@gmail.com>2022-03-14 12:43:19 +0100
committerStefan Riesenberger <stefan.riesenberger@gmail.com>2022-03-14 12:43:19 +0100
commite9ce55bfd020a05b93fae5be8fe431876ae9c742 (patch)
tree3dccd1e9e7b0108c283a7646310a34c4faf53bc0 /ice40
parentb852df3260a19aad40607c7520e3ed19895e636f (diff)
downloadnextpnr-e9ce55bfd020a05b93fae5be8fe431876ae9c742.tar.gz
nextpnr-e9ce55bfd020a05b93fae5be8fe431876ae9c742.tar.bz2
nextpnr-e9ce55bfd020a05b93fae5be8fe431876ae9c742.zip
ice40: fix crash when packing LUTs with no output
Diffstat (limited to 'ice40')
-rw-r--r--ice40/pack.cc51
1 files changed, 27 insertions, 24 deletions
diff --git a/ice40/pack.cc b/ice40/pack.cc
index c32e346f..f533941d 100644
--- a/ice40/pack.cc
+++ b/ice40/pack.cc
@@ -49,32 +49,35 @@ static void pack_lut_lutffs(Context *ctx)
log_info("packed cell %s into %s\n", ci->name.c_str(ctx), packed->name.c_str(ctx));
// See if we can pack into a DFF
// TODO: LUT cascade
- NetInfo *o = ci->ports.at(id_O).net;
- CellInfo *dff = net_only_drives(ctx, o, is_ff, id_D, true);
- auto lut_bel = ci->attrs.find(id_BEL);
+ auto port = ci->ports.find(id_O);
bool packed_dff = false;
- if (dff) {
- if (ctx->verbose)
- log_info("found attached dff %s\n", dff->name.c_str(ctx));
- auto dff_bel = dff->attrs.find(id_BEL);
- if (lut_bel != ci->attrs.end() && dff_bel != dff->attrs.end() && lut_bel->second != dff_bel->second) {
- // Locations don't match, can't pack
- } else {
- lut_to_lc(ctx, ci, packed.get(), false);
- dff_to_lc(ctx, dff, packed.get(), false);
- ++lut_and_ff;
- ctx->nets.erase(o->name);
- if (dff_bel != dff->attrs.end())
- packed->attrs[id_BEL] = dff_bel->second;
- for (const auto &attr : dff->attrs) {
- // BEL is dealt with specially
- if (attr.first != id_BEL)
- packed->attrs[attr.first] = attr.second;
- }
- packed_cells.insert(dff->name);
+ if (port != ci->ports.end()) {
+ NetInfo *o = port->second.net;
+ CellInfo *dff = net_only_drives(ctx, o, is_ff, id_D, true);
+ auto lut_bel = ci->attrs.find(id_BEL);
+ if (dff) {
if (ctx->verbose)
- log_info("packed cell %s into %s\n", dff->name.c_str(ctx), packed->name.c_str(ctx));
- packed_dff = true;
+ log_info("found attached dff %s\n", dff->name.c_str(ctx));
+ auto dff_bel = dff->attrs.find(id_BEL);
+ if (lut_bel != ci->attrs.end() && dff_bel != dff->attrs.end() && lut_bel->second != dff_bel->second) {
+ // Locations don't match, can't pack
+ } else {
+ lut_to_lc(ctx, ci, packed.get(), false);
+ dff_to_lc(ctx, dff, packed.get(), false);
+ ++lut_and_ff;
+ ctx->nets.erase(o->name);
+ if (dff_bel != dff->attrs.end())
+ packed->attrs[id_BEL] = dff_bel->second;
+ for (const auto &attr : dff->attrs) {
+ // BEL is dealt with specially
+ if (attr.first != id_BEL)
+ packed->attrs[attr.first] = attr.second;
+ }
+ packed_cells.insert(dff->name);
+ if (ctx->verbose)
+ log_info("packed cell %s into %s\n", dff->name.c_str(ctx), packed->name.c_str(ctx));
+ packed_dff = true;
+ }
}
}
if (!packed_dff) {