From 857961a6bb9302847ecf605971015f1610dae476 Mon Sep 17 00:00:00 2001 From: Maciej Kurc Date: Fri, 16 Jul 2021 14:55:45 +0200 Subject: [PATCH] Migrated C arrays to std::array containers. Signed-off-by: Maciej Kurc --- fpga_interchange/site_lut_mapping_cache.cc | 3 +- fpga_interchange/site_lut_mapping_cache.h | 37 ++++++++++++++++++---- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/fpga_interchange/site_lut_mapping_cache.cc b/fpga_interchange/site_lut_mapping_cache.cc index 44a72772..3796d7ab 100644 --- a/fpga_interchange/site_lut_mapping_cache.cc +++ b/fpga_interchange/site_lut_mapping_cache.cc @@ -75,8 +75,7 @@ SiteLutMappingKey SiteLutMappingKey::create (const SiteInformation& siteInfo) { cell.type = cellInfo->type; cell.belIndex = cellInfo->bel.index; - memset((void*)cell.conns, 0, - sizeof(int32_t) * SiteLutMappingKey::MAX_LUT_INPUTS); + cell.conns.fill(0); size_t portId = 0; for (const auto& port : cellInfo->ports) { diff --git a/fpga_interchange/site_lut_mapping_cache.h b/fpga_interchange/site_lut_mapping_cache.h index df1ce474..42a10ba7 100644 --- a/fpga_interchange/site_lut_mapping_cache.h +++ b/fpga_interchange/site_lut_mapping_cache.h @@ -41,13 +41,25 @@ struct SiteLutMappingKey { // Port to net assignments. These are local net ids generated during // key creation. This is to abstract connections from actual design // net names. the Id 0 means unconnected. - int32_t conns [MAX_LUT_INPUTS]; + std::array conns; + + bool operator == (const Cell& other) const { + return (type == other.type) && + (belIndex == other.belIndex) && + (conns == other.conns); + } + + bool operator != (const Cell& other) const { + return (type != other.type) || + (belIndex != other.belIndex) || + (conns != other.conns); + } }; 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 + std::array cells; // LUT cell data unsigned int hash_; // Precomputed hash @@ -66,21 +78,32 @@ struct SiteLutMappingKey { } } } - + + bool compareCells (const SiteLutMappingKey &other) const { + if (numCells != other.numCells) { + return false; + } + + for (size_t i=0; i