diff options
Diffstat (limited to 'common/design_utils.cc')
-rw-r--r-- | common/design_utils.cc | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/common/design_utils.cc b/common/design_utils.cc index 85895a75..ae6e21ed 100644 --- a/common/design_utils.cc +++ b/common/design_utils.cc @@ -2,6 +2,7 @@ * nextpnr -- Next Generation Place and Route * * Copyright (C) 2018 Clifford Wolf <clifford@clifford.at> + * Copyright (C) 2018 David Shah <david@symbioticeda.com> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -18,7 +19,9 @@ */ #include "design_utils.h" - +#include <map> +#include "log.h" +#include "util.h" NEXTPNR_NAMESPACE_BEGIN void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell, @@ -49,4 +52,23 @@ void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell, } } +// Print utilisation of a design +void print_utilisation(const Design *design) +{ + // Sort by Bel type + std::map<BelType, int> used_types; + for (auto cell : design->cells) { + used_types[belTypeFromId(cell.second->type)]++; + } + std::map<BelType, int> available_types; + for (auto bel : design->chip.getBels()) { + available_types[design->chip.getBelType(bel)]++; + } + log("\nDesign utilisation:\n"); + for (auto type : available_types) { + log("\t%20s: %5d/%5d\n", belTypeToId(type.first).c_str(), + get_or_default(used_types, type.first, 0), type.second); + } +} + NEXTPNR_NAMESPACE_END |