aboutsummaryrefslogtreecommitdiffstats
path: root/fpga_interchange/site_lut_mapping_cache.h
diff options
context:
space:
mode:
authorMaciej Kurc <mkurc@antmicro.com>2021-07-16 13:55:19 +0200
committerMaciej Kurc <mkurc@antmicro.com>2021-07-16 13:55:19 +0200
commit0336f55b16373874cf4ac5661d9724d0a358454c (patch)
treefd02b86d6a98eb890ab6ee4c6fa07e92a9b96cd4 /fpga_interchange/site_lut_mapping_cache.h
parent044c9ba2d4e66cf34214fdfd62fb90a872da64b1 (diff)
downloadnextpnr-0336f55b16373874cf4ac5661d9724d0a358454c.tar.gz
nextpnr-0336f55b16373874cf4ac5661d9724d0a358454c.tar.bz2
nextpnr-0336f55b16373874cf4ac5661d9724d0a358454c.zip
LUT mapping ceche optimizations 2
Signed-off-by: Maciej Kurc <mkurc@antmicro.com>
Diffstat (limited to 'fpga_interchange/site_lut_mapping_cache.h')
-rw-r--r--fpga_interchange/site_lut_mapping_cache.h21
1 files changed, 13 insertions, 8 deletions
diff --git a/fpga_interchange/site_lut_mapping_cache.h b/fpga_interchange/site_lut_mapping_cache.h
index b07e3e77..df1ce474 100644
--- a/fpga_interchange/site_lut_mapping_cache.h
+++ b/fpga_interchange/site_lut_mapping_cache.h
@@ -28,7 +28,7 @@ NEXTPNR_NAMESPACE_BEGIN
// Key structure used in site LUT mapping cache
struct SiteLutMappingKey {
- // Maximum number of LUT cells
+ // Maximum number of LUT cells per site
static constexpr size_t MAX_LUT_CELLS = 8;
// Maximum number of LUT inputs per cell
static constexpr size_t MAX_LUT_INPUTS = 6;
@@ -44,18 +44,21 @@ struct SiteLutMappingKey {
int32_t conns [MAX_LUT_INPUTS];
};
- int32_t tileType; // Tile type
- int32_t siteType; // Site type in that tile type
- std::vector<Cell> cells; // LUT cell data
+ int32_t tileType; // Tile type
+ int32_t siteType; // Site type in that tile type
+ size_t numCells; // LUT cell count
+ Cell cells[MAX_LUT_CELLS]; // LUT cell data
- unsigned int hash_; // Precomputed hash
+ unsigned int hash_; // Precomputed hash
static SiteLutMappingKey create (const SiteInformation& siteInfo);
void computeHash () {
hash_ = mkhash(0, tileType);
hash_ = mkhash(hash_, siteType);
- for (const auto& cell : cells) {
+ hash_ = mkhash(hash_, numCells);
+ for (size_t j=0; j<numCells; ++j) {
+ const auto& cell = cells[j];
hash_ = mkhash(hash_, cell.type.index);
hash_ = mkhash(hash_, cell.belIndex);
for (size_t i=0; i<MAX_LUT_INPUTS; ++i) {
@@ -68,14 +71,16 @@ struct SiteLutMappingKey {
return (hash_ == other.hash_) &&
(tileType == other.tileType) &&
(siteType == other.siteType) &&
- (cells == other.cells);
+ (numCells == other.numCells) &&
+ (!memcmp(cells, other.cells, sizeof(Cell) * numCells));
}
bool operator != (const SiteLutMappingKey &other) const {
return (hash_ != other.hash_) ||
(tileType != other.tileType) ||
(siteType != other.siteType) ||
- (cells != other.cells);
+ (numCells != other.numCells) ||
+ (memcmp(cells, other.cells, sizeof(Cell) * numCells));
}
unsigned int hash () const {