ice40: Add better stats on LC packing

Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
David Shah 2019-08-08 20:56:30 +01:00
parent e0a114fcb3
commit eed85cda83
2 changed files with 15 additions and 1 deletions

View File

@ -32,6 +32,7 @@ NEXTPNR_NAMESPACE_BEGIN
class ChainConstrainer class ChainConstrainer
{ {
private: private:
int feedio_lcs = 0;
Context *ctx; Context *ctx;
// Split a carry chain into multiple legal chains // Split a carry chain into multiple legal chains
std::vector<CellChain> split_carry_chain(CellChain &carryc) std::vector<CellChain> split_carry_chain(CellChain &carryc)
@ -55,6 +56,7 @@ class ChainConstrainer
CellInfo *feedin = make_carry_feed_in(cell, cell->ports.at(ctx->id("CIN"))); CellInfo *feedin = make_carry_feed_in(cell, cell->ports.at(ctx->id("CIN")));
chains.back().cells.push_back(feedin); chains.back().cells.push_back(feedin);
tile.push_back(feedin); tile.push_back(feedin);
++feedio_lcs;
} }
} }
tile.push_back(cell); tile.push_back(cell);
@ -78,6 +80,7 @@ class ChainConstrainer
at_end ? nullptr : *(curr_cell + 1)); at_end ? nullptr : *(curr_cell + 1));
chains.back().cells.push_back(passout); chains.back().cells.push_back(passout);
tile.push_back(passout); tile.push_back(passout);
++feedio_lcs;
} }
} }
++curr_cell; ++curr_cell;
@ -281,6 +284,7 @@ class ChainConstrainer
chain.cells.at(0)->constr_children.push_back(chain.cells.at(i)); chain.cells.at(0)->constr_children.push_back(chain.cells.at(i));
} }
} }
log_info(" %4d LCs used to legalise carry chains.\n", feedio_lcs);
} }
public: public:

View File

@ -34,7 +34,7 @@ NEXTPNR_NAMESPACE_BEGIN
static void pack_lut_lutffs(Context *ctx) static void pack_lut_lutffs(Context *ctx)
{ {
log_info("Packing LUT-FFs..\n"); log_info("Packing LUT-FFs..\n");
int lut_only = 0, lut_and_ff = 0;
std::unordered_set<IdString> packed_cells; std::unordered_set<IdString> packed_cells;
std::vector<std::unique_ptr<CellInfo>> new_cells; std::vector<std::unique_ptr<CellInfo>> new_cells;
for (auto cell : sorted(ctx->cells)) { for (auto cell : sorted(ctx->cells)) {
@ -62,6 +62,7 @@ static void pack_lut_lutffs(Context *ctx)
} else { } else {
lut_to_lc(ctx, ci, packed.get(), false); lut_to_lc(ctx, ci, packed.get(), false);
dff_to_lc(ctx, dff, packed.get(), false); dff_to_lc(ctx, dff, packed.get(), false);
++lut_and_ff;
ctx->nets.erase(o->name); ctx->nets.erase(o->name);
if (dff_bel != dff->attrs.end()) if (dff_bel != dff->attrs.end())
packed->attrs[ctx->id("BEL")] = dff_bel->second; packed->attrs[ctx->id("BEL")] = dff_bel->second;
@ -73,6 +74,7 @@ static void pack_lut_lutffs(Context *ctx)
} }
if (!packed_dff) { if (!packed_dff) {
lut_to_lc(ctx, ci, packed.get(), true); lut_to_lc(ctx, ci, packed.get(), true);
++lut_only;
} }
new_cells.push_back(std::move(packed)); new_cells.push_back(std::move(packed));
} }
@ -83,6 +85,8 @@ static void pack_lut_lutffs(Context *ctx)
for (auto &ncell : new_cells) { for (auto &ncell : new_cells) {
ctx->cells[ncell->name] = std::move(ncell); ctx->cells[ncell->name] = std::move(ncell);
} }
log_info(" %4d LCs used as LUT4 only\n", lut_only);
log_info(" %4d LCs used as LUT4 and DFF\n", lut_and_ff);
} }
// Pack FFs not packed as LUTFFs // Pack FFs not packed as LUTFFs
@ -92,6 +96,7 @@ static void pack_nonlut_ffs(Context *ctx)
std::unordered_set<IdString> packed_cells; std::unordered_set<IdString> packed_cells;
std::vector<std::unique_ptr<CellInfo>> new_cells; std::vector<std::unique_ptr<CellInfo>> new_cells;
int ff_only = 0;
for (auto cell : sorted(ctx->cells)) { for (auto cell : sorted(ctx->cells)) {
CellInfo *ci = cell.second; CellInfo *ci = cell.second;
@ -104,6 +109,7 @@ static void pack_nonlut_ffs(Context *ctx)
packed_cells.insert(ci->name); packed_cells.insert(ci->name);
dff_to_lc(ctx, ci, packed.get(), true); dff_to_lc(ctx, ci, packed.get(), true);
new_cells.push_back(std::move(packed)); new_cells.push_back(std::move(packed));
++ff_only;
} }
} }
for (auto pcell : packed_cells) { for (auto pcell : packed_cells) {
@ -112,6 +118,7 @@ static void pack_nonlut_ffs(Context *ctx)
for (auto &ncell : new_cells) { for (auto &ncell : new_cells) {
ctx->cells[ncell->name] = std::move(ncell); ctx->cells[ncell->name] = std::move(ncell);
} }
log_info(" %4d LCs used as DFF only\n", ff_only);
} }
static bool net_is_constant(const Context *ctx, NetInfo *net, bool &value) static bool net_is_constant(const Context *ctx, NetInfo *net, bool &value)
@ -133,6 +140,7 @@ static void pack_carries(Context *ctx)
std::unordered_set<IdString> exhausted_cells; std::unordered_set<IdString> exhausted_cells;
std::unordered_set<IdString> packed_cells; std::unordered_set<IdString> packed_cells;
std::vector<std::unique_ptr<CellInfo>> new_cells; std::vector<std::unique_ptr<CellInfo>> new_cells;
int carry_only = 0;
for (auto cell : sorted(ctx->cells)) { for (auto cell : sorted(ctx->cells)) {
CellInfo *ci = cell.second; CellInfo *ci = cell.second;
@ -209,6 +217,7 @@ static void pack_carries(Context *ctx)
i1_net->users.push_back(pr); i1_net->users.push_back(pr);
} }
new_cells.push_back(std::move(created_lc)); new_cells.push_back(std::move(created_lc));
++carry_only;
} }
carry_lc->params[ctx->id("CARRY_ENABLE")] = Property::State::S1; carry_lc->params[ctx->id("CARRY_ENABLE")] = Property::State::S1;
replace_port(ci, ctx->id("CI"), carry_lc, ctx->id("CIN")); replace_port(ci, ctx->id("CI"), carry_lc, ctx->id("CIN"));
@ -250,6 +259,7 @@ static void pack_carries(Context *ctx)
for (auto &ncell : new_cells) { for (auto &ncell : new_cells) {
ctx->cells[ncell->name] = std::move(ncell); ctx->cells[ncell->name] = std::move(ncell);
} }
log_info(" %4d LCs used as CARRY only\n", carry_only);
} }
// "Pack" RAMs // "Pack" RAMs