diff options
author | William D. Jones <thor0505@comcast.net> | 2020-12-06 22:50:15 -0500 |
---|---|---|
committer | gatecat <gatecat@ds0.me> | 2021-02-12 10:36:59 +0000 |
commit | 5f748272fc118f5fdf8b5389188434c6070ca917 (patch) | |
tree | d4cf72f5cbf89c501ca10c7f22fdf6f45d8e9d41 | |
parent | 682de724a8f84ee5106a1fd8ad68888605eafa89 (diff) | |
download | nextpnr-5f748272fc118f5fdf8b5389188434c6070ca917.tar.gz nextpnr-5f748272fc118f5fdf8b5389188434c6070ca917.tar.bz2 nextpnr-5f748272fc118f5fdf8b5389188434c6070ca917.zip |
machxo2: Implement bel_to_cell and API functions using it.
-rw-r--r-- | machxo2/arch.cc | 16 | ||||
-rw-r--r-- | machxo2/arch.h | 52 |
2 files changed, 47 insertions, 21 deletions
diff --git a/machxo2/arch.cc b/machxo2/arch.cc index 8c8dda5e..42d93f16 100644 --- a/machxo2/arch.cc +++ b/machxo2/arch.cc @@ -167,22 +167,6 @@ uint32_t Arch::getBelChecksum(BelId bel) const return 0; } -void Arch::bindBel(BelId bel, CellInfo *cell, PlaceStrength strength) -{ - -} - -void Arch::unbindBel(BelId bel) -{ - -} - -bool Arch::checkBelAvail(BelId bel) const { return false; } - -CellInfo *Arch::getBoundBelCell(BelId bel) const { return nullptr; } - -CellInfo *Arch::getConflictingBelCell(BelId bel) const { return nullptr; } - const std::map<IdString, std::string> &Arch::getBelAttrs(BelId bel) const { return attrs_dummy; } WireId Arch::getBelPinWire(BelId bel, IdString pin) const diff --git a/machxo2/arch.h b/machxo2/arch.h index 1c848388..b5d6c522 100644 --- a/machxo2/arch.h +++ b/machxo2/arch.h @@ -311,6 +311,8 @@ struct Arch : BaseCtx const ChipInfoPOD *chip_info; const PackageInfoPOD *package_info; + std::vector<CellInfo *> bel_to_cell; + // Placeholders to be removed. std::unordered_map<Loc, BelId> bel_by_loc; std::vector<BelId> bel_id_dummy; @@ -327,6 +329,11 @@ struct Arch : BaseCtx return &(chip_info->tiles[id.location.y * chip_info->width + id.location.x]); } + int getBelFlatIndex(BelId bel) const + { + return (bel.location.y * chip_info->width + bel.location.x) * max_loc_bels + bel.index; + } + // --------------------------------------------------------------- // Common Arch API. Every arch must provide the following methods. @@ -373,11 +380,46 @@ struct Arch : BaseCtx const std::vector<BelId> &getBelsByTile(int x, int y) const; bool getBelGlobalBuf(BelId bel) const; uint32_t getBelChecksum(BelId bel) const; - void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength); - void unbindBel(BelId bel); - bool checkBelAvail(BelId bel) const; - CellInfo *getBoundBelCell(BelId bel) const; - CellInfo *getConflictingBelCell(BelId bel) const; + + void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength) + { + NPNR_ASSERT(bel != BelId()); + int idx = getBelFlatIndex(bel); + NPNR_ASSERT(bel_to_cell.at(idx) == nullptr); + bel_to_cell[idx] = cell; + cell->bel = bel; + cell->belStrength = strength; + refreshUiBel(bel); + } + + void unbindBel(BelId bel) + { + NPNR_ASSERT(bel != BelId()); + int idx = getBelFlatIndex(bel); + NPNR_ASSERT(bel_to_cell.at(idx) != nullptr); + bel_to_cell[idx]->bel = BelId(); + bel_to_cell[idx]->belStrength = STRENGTH_NONE; + bel_to_cell[idx] = nullptr; + refreshUiBel(bel); + } + + bool checkBelAvail(BelId bel) const + { + NPNR_ASSERT(bel != BelId()); + return bel_to_cell[getBelFlatIndex(bel)] == nullptr; + } + + CellInfo *getBoundBelCell(BelId bel) const + { + NPNR_ASSERT(bel != BelId()); + return bel_to_cell[getBelFlatIndex(bel)]; + } + + CellInfo *getConflictingBelCell(BelId bel) const + { + NPNR_ASSERT(bel != BelId()); + return bel_to_cell[getBelFlatIndex(bel)]; + } BelRange getBels() const { |