aboutsummaryrefslogtreecommitdiffstats
path: root/ice40/bitstream.cc
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2018-07-21 17:04:24 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2018-07-21 17:04:47 +0200
commit7beb4739d4fad287d562a7861d3c83458cfa22fc (patch)
treedb1672849d5354a98acda14dd290d01ab5feb601 /ice40/bitstream.cc
parent80097526eef823a475d3cc0955721ffe13d995be (diff)
downloadnextpnr-7beb4739d4fad287d562a7861d3c83458cfa22fc.tar.gz
nextpnr-7beb4739d4fad287d562a7861d3c83458cfa22fc.tar.bz2
nextpnr-7beb4739d4fad287d562a7861d3c83458cfa22fc.zip
Add used cells and attach them to bels
Diffstat (limited to 'ice40/bitstream.cc')
-rw-r--r--ice40/bitstream.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/ice40/bitstream.cc b/ice40/bitstream.cc
index eef96eb2..37425539 100644
--- a/ice40/bitstream.cc
+++ b/ice40/bitstream.cc
@@ -20,6 +20,7 @@
#include "bitstream.h"
#include <cctype>
#include <vector>
+#include "cells.h"
#include "log.h"
NEXTPNR_NAMESPACE_BEGIN
@@ -51,6 +52,20 @@ std::tuple<int8_t, int8_t, int8_t> get_ieren(const BitstreamInfoPOD &bi, int8_t
return std::make_tuple(-1, -1, -1);
};
+bool get_config(const TileInfoPOD &ti, std::vector<std::vector<int8_t>> &tile_cfg, const std::string &name,
+ int index = -1)
+{
+ const ConfigEntryPOD &cfg = find_config(ti, name);
+ if (index == -1) {
+ for (int i = 0; i < cfg.num_bits; i++) {
+ return tile_cfg.at(cfg.bits[i].row).at(cfg.bits[i].col);
+ }
+ } else {
+ return tile_cfg.at(cfg.bits[index].row).at(cfg.bits[index].col);
+ }
+ return false;
+}
+
void set_config(const TileInfoPOD &ti, std::vector<std::vector<int8_t>> &tile_cfg, const std::string &name, bool value,
int index = -1)
{
@@ -652,6 +667,30 @@ bool read_asc(Context *ctx, std::istream &in)
ctx->bindPip(pip, net, STRENGTH_WEAK);
}
}
+ for (auto bel : ctx->getBels()) {
+ if (ctx->getBelType(bel) == TYPE_ICESTORM_LC) {
+ const TileInfoPOD &ti = bi.tiles_nonrouting[TILE_LOGIC];
+ const BelInfoPOD &beli = ci.bel_data[bel.index];
+ int x = beli.x, y = beli.y, z = beli.z;
+ std::vector<bool> lc(20, false);
+ bool isUsed = false;
+ for (int i = 0; i < 20; i++) {
+ lc.at(i) = get_config(ti, config.at(y).at(x), "LC_" + std::to_string(z), i);
+ isUsed |= lc.at(i);
+ }
+ bool neg_clk = get_config(ti, config.at(y).at(x), "NegClk");
+ isUsed |= neg_clk;
+ bool carry_set = get_config(ti, config.at(y).at(x), "CarryInSet");
+ isUsed |= carry_set;
+
+ if (isUsed) {
+ std::unique_ptr<CellInfo> created = create_ice_cell(ctx, ctx->id("ICESTORM_LC"));
+ IdString name = created->name;
+ ctx->cells[name] = std::move(created);
+ ctx->bindBel(bel, name, STRENGTH_WEAK);
+ }
+ }
+ }
return true;
} catch (log_execution_error_exception) {
return false;