From 57f75385b0960d6e1e30112a395a89ee4df07056 Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Sat, 14 Jul 2018 18:53:08 +0100 Subject: Revert "Make PnR use Unlocked methods" This reverts commit 9e4f97290a50fc5d9dc0cbe6ead945840b9811b1. --- ice40/arch.cc | 26 ++--------- ice40/arch.h | 117 +++++++++-------------------------------------- ice40/arch_place.cc | 6 +-- ice40/place_legaliser.cc | 14 +++--- 4 files changed, 34 insertions(+), 129 deletions(-) (limited to 'ice40') diff --git a/ice40/arch.cc b/ice40/arch.cc index 30eea776..74353fe6 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -242,11 +242,6 @@ IdString Arch::archArgsToId(ArchArgs args) const BelId Arch::getBelByName(IdString name) const { boost::lock_guard lock(mtx_); - return getBelByNameUnlocked(name); -} - -BelId Arch::getBelByNameUnlocked(IdString name) const -{ BelId ret; if (bel_by_name.empty()) { @@ -280,14 +275,9 @@ BelRange Arch::getBelsAtSameTile(BelId bel) const } WireId Arch::getWireBelPin(BelId bel, PortPin pin) const -{ - boost::shared_lock_guard lock(mtx_); - return getWireBelPinUnlocked(bel, pin); -} - -WireId Arch::getWireBelPinUnlocked(BelId bel, PortPin pin) const { WireId ret; + boost::shared_lock_guard lock(mtx_); NPNR_ASSERT(bel != BelId()); @@ -306,14 +296,9 @@ WireId Arch::getWireBelPinUnlocked(BelId bel, PortPin pin) const // ----------------------------------------------------------------------- WireId Arch::getWireByName(IdString name) const -{ - boost::shared_lock_guard lock(mtx_); - return getWireByNameUnlocked(name); -} - -WireId Arch::getWireByNameUnlocked(IdString name) const { WireId ret; + boost::shared_lock_guard lock(mtx_); if (wire_by_name.empty()) { for (int i = 0; i < chip_info->num_wires; i++) @@ -330,14 +315,9 @@ WireId Arch::getWireByNameUnlocked(IdString name) const // ----------------------------------------------------------------------- PipId Arch::getPipByName(IdString name) const -{ - boost::shared_lock_guard lock(mtx_); - return getPipByNameUnlocked(name); -} - -PipId Arch::getPipByNameUnlocked(IdString name) const { PipId ret; + boost::shared_lock_guard lock(mtx_); if (pip_by_name.empty()) { for (int i = 0; i < chip_info->num_pips; i++) { diff --git a/ice40/arch.h b/ice40/arch.h index 6f281d4a..a7af3269 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -362,7 +362,6 @@ public: // ------------------------------------------------- BelId getBelByName(IdString name) const; - BelId getBelByNameUnlocked(IdString name) const; IdString getBelName(BelId bel) const { @@ -372,68 +371,44 @@ public: uint32_t getBelChecksum(BelId bel) const { return bel.index; } - void bindBel(BelId bel, IdString cell, PlaceStrength strength) { - boost::lock_guard lock(mtx_); - bindBelUnlocked(bel, cell, strength); - } - - void bindBelUnlocked(BelId bel, IdString cell, PlaceStrength strength) + void bindBel(BelId bel, IdString cell, PlaceStrength strength) { NPNR_ASSERT(bel != BelId()); NPNR_ASSERT(bel_to_cell[bel.index] == IdString()); + boost::lock_guard lock(mtx_); bel_to_cell[bel.index] = cell; cells[cell]->bel = bel; cells[cell]->belStrength = strength; } void unbindBel(BelId bel) - { - boost::lock_guard lock(mtx_); - unbindBelUnlocked(bel); - } - - void unbindBelUnlocked(BelId bel) { NPNR_ASSERT(bel != BelId()); NPNR_ASSERT(bel_to_cell[bel.index] != IdString()); + boost::lock_guard lock(mtx_); cells[bel_to_cell[bel.index]]->bel = BelId(); cells[bel_to_cell[bel.index]]->belStrength = STRENGTH_NONE; bel_to_cell[bel.index] = IdString(); } bool checkBelAvail(BelId bel) const - { - boost::shared_lock_guard lock(mtx_); - return checkBelAvailUnlocked(bel); - } - - bool checkBelAvailUnlocked(BelId bel) const { NPNR_ASSERT(bel != BelId()); + boost::shared_lock_guard lock(mtx_); return bel_to_cell[bel.index] == IdString(); } IdString getBoundBelCell(BelId bel) const - { - boost::shared_lock_guard lock(mtx_); - return getBoundBelCellUnlocked(bel); - } - - IdString getBoundBelCellUnlocked(BelId bel) const { NPNR_ASSERT(bel != BelId()); + boost::shared_lock_guard lock(mtx_); return bel_to_cell[bel.index]; } IdString getConflictingBelCell(BelId bel) const - { - boost::shared_lock_guard lock(mtx_); - return getConflictingBelCellUnlocked(bel); - } - - IdString getConflictingBelCellUnlocked(BelId bel) const { NPNR_ASSERT(bel != BelId()); + boost::shared_lock_guard lock(mtx_); return bel_to_cell[bel.index]; } @@ -450,11 +425,11 @@ public: BelRange range; // FIXME #if 0 - if (type == "TYPE_A") { - range.b.cursor = bels_type_a_begin; - range.e.cursor = bels_type_a_end; - } - ... + if (type == "TYPE_A") { + range.b.cursor = bels_type_a_begin; + range.e.cursor = bels_type_a_end; + } + ... #endif return range; } @@ -468,7 +443,6 @@ public: } WireId getWireBelPin(BelId bel, PortPin pin) const; - WireId getWireBelPinUnlocked(BelId bel, PortPin pin) const; BelPin getBelPinUphill(WireId wire) const { @@ -495,7 +469,6 @@ public: // ------------------------------------------------- WireId getWireByName(IdString name) const; - WireId getWireByNameUnlocked(IdString name) const; IdString getWireName(WireId wire) const { @@ -506,15 +479,10 @@ public: uint32_t getWireChecksum(WireId wire) const { return wire.index; } void bindWire(WireId wire, IdString net, PlaceStrength strength) - { - boost::lock_guard lock(mtx_); - bindWireUnlocked(wire, net, strength); - } - - void bindWireUnlocked(WireId wire, IdString net, PlaceStrength strength) { NPNR_ASSERT(wire != WireId()); NPNR_ASSERT(wire_to_net[wire.index] == IdString()); + boost::lock_guard lock(mtx_); wire_to_net[wire.index] = net; nets[net]->wires[wire].pip = PipId(); @@ -522,15 +490,10 @@ public: } void unbindWire(WireId wire) - { - boost::lock_guard lock(mtx_); - unbindWireUnlocked(wire); - } - - void unbindWireUnlocked(WireId wire) { NPNR_ASSERT(wire != WireId()); NPNR_ASSERT(wire_to_net[wire.index] != IdString()); + boost::lock_guard lock(mtx_); auto &net_wires = nets[wire_to_net[wire.index]]->wires; auto it = net_wires.find(wire); @@ -548,37 +511,25 @@ public: bool checkWireAvail(WireId wire) const { + NPNR_ASSERT(wire != WireId()); boost::shared_lock_guard lock(mtx_); - return checkWireAvailUnlocked(wire); - } - bool checkWireAvailUnlocked(WireId wire) const - { - NPNR_ASSERT(wire != WireId()); return wire_to_net[wire.index] == IdString(); } IdString getBoundWireNet(WireId wire) const { + NPNR_ASSERT(wire != WireId()); boost::shared_lock_guard lock(mtx_); - return getBoundWireNetUnlocked(wire); - } - IdString getBoundWireNetUnlocked(WireId wire) const - { - NPNR_ASSERT(wire != WireId()); return wire_to_net[wire.index]; } IdString getConflictingWireNet(WireId wire) const { + NPNR_ASSERT(wire != WireId()); boost::shared_lock_guard lock(mtx_); - return getConflictingWireNetUnlocked(wire); - } - IdString getConflictingWireNetUnlocked(WireId wire) const - { - NPNR_ASSERT(wire != WireId()); return wire_to_net[wire.index]; } @@ -593,22 +544,16 @@ public: // ------------------------------------------------- PipId getPipByName(IdString name) const; - PipId getPipByNameUnlocked(IdString name) const; IdString getPipName(PipId pip) const; uint32_t getPipChecksum(PipId pip) const { return pip.index; } void bindPip(PipId pip, IdString net, PlaceStrength strength) - { - boost::lock_guard lock(mtx_); - bindPipUnlocked(pip, net, strength); - } - - void bindPipUnlocked(PipId pip, IdString net, PlaceStrength strength) { NPNR_ASSERT(pip != PipId()); NPNR_ASSERT(pip_to_net[pip.index] == IdString()); NPNR_ASSERT(switches_locked[chip_info->pip_data[pip.index].switch_index] == IdString()); + boost::lock_guard lock(mtx_); pip_to_net[pip.index] = net; switches_locked[chip_info->pip_data[pip.index].switch_index] = net; @@ -622,16 +567,11 @@ public: } void unbindPip(PipId pip) - { - boost::lock_guard lock(mtx_); - unbindPipUnlocked(pip); - } - - void unbindPipUnlocked(PipId pip) { NPNR_ASSERT(pip != PipId()); NPNR_ASSERT(pip_to_net[pip.index] != IdString()); NPNR_ASSERT(switches_locked[chip_info->pip_data[pip.index].switch_index] != IdString()); + boost::lock_guard lock(mtx_); WireId dst; dst.index = chip_info->pip_data[pip.index].dst; @@ -644,38 +584,23 @@ public: } bool checkPipAvail(PipId pip) const - { - boost::shared_lock_guard lock(mtx_); - return checkPipAvailUnlocked(pip); - } - - bool checkPipAvailUnlocked(PipId pip) const { NPNR_ASSERT(pip != PipId()); + boost::shared_lock_guard lock(mtx_); return switches_locked[chip_info->pip_data[pip.index].switch_index] == IdString(); } IdString getBoundPipNet(PipId pip) const - { - boost::shared_lock_guard lock(mtx_); - return getBoundPipNetUnlocked(pip); - } - - IdString getBoundPipNetUnlocked(PipId pip) const { NPNR_ASSERT(pip != PipId()); + boost::shared_lock_guard lock(mtx_); return pip_to_net[pip.index]; } IdString getConflictingPipNet(PipId pip) const - { - boost::shared_lock_guard lock(mtx_); - return getConflictingPipNetUnlocked(pip); - } - - IdString getConflictingPipNetUnlocked(PipId pip) const { NPNR_ASSERT(pip != PipId()); + boost::shared_lock_guard lock(mtx_); return switches_locked[chip_info->pip_data[pip.index].switch_index]; } diff --git a/ice40/arch_place.cc b/ice40/arch_place.cc index c9dd26c5..dc1bc3eb 100644 --- a/ice40/arch_place.cc +++ b/ice40/arch_place.cc @@ -80,7 +80,7 @@ bool Arch::isBelLocationValid(BelId bel) const if (getBelType(bel) == TYPE_ICESTORM_LC) { std::vector bel_cells; for (auto bel_other : getBelsAtSameTile(bel)) { - IdString cell_other = getBoundBelCellUnlocked(bel_other); + IdString cell_other = getBoundBelCell(bel_other); if (cell_other != IdString()) { const CellInfo *ci_other = cells.at(cell_other).get(); bel_cells.push_back(ci_other); @@ -88,7 +88,7 @@ bool Arch::isBelLocationValid(BelId bel) const } return logicCellsCompatible(bel_cells); } else { - IdString cellId = getBoundBelCellUnlocked(bel); + IdString cellId = getBoundBelCell(bel); if (cellId == IdString()) return true; else @@ -104,7 +104,7 @@ bool Arch::isValidBelForCell(CellInfo *cell, BelId bel) const std::vector bel_cells; for (auto bel_other : getBelsAtSameTile(bel)) { - IdString cell_other = getBoundBelCellUnlocked(bel_other); + IdString cell_other = getBoundBelCell(bel_other); if (cell_other != IdString() && bel_other != bel) { const CellInfo *ci_other = cells.at(cell_other).get(); bel_cells.push_back(ci_other); diff --git a/ice40/place_legaliser.cc b/ice40/place_legaliser.cc index d42188f0..559358c7 100644 --- a/ice40/place_legaliser.cc +++ b/ice40/place_legaliser.cc @@ -143,7 +143,7 @@ class PlacementLegaliser // Using the non-standard API here to get (x, y, z) rather than just (x, y) auto bi = ctx->chip_info->bel_data[bel.index]; int x = bi.x, y = bi.y, z = bi.z; - IdString cell = ctx->getBoundBelCellUnlocked(bel); + IdString cell = ctx->getBoundBelCell(bel); if (cell != IdString() && ctx->cells.at(cell)->belStrength >= STRENGTH_FIXED) logic_bels.at(x).at(y).at(z) = std::make_pair(bel, true); // locked out of use else @@ -331,16 +331,16 @@ class PlacementLegaliser NPNR_ASSERT(!loc.second); BelId bel = loc.first; // Check if there is a cell presently at the location, which we will need to rip up - IdString existing = ctx->getBoundBelCellUnlocked(bel); + IdString existing = ctx->getBoundBelCell(bel); if (existing != IdString()) { // TODO: keep track of the previous position of the ripped up cell, as a hint rippedCells.insert(existing); - ctx->unbindBelUnlocked(bel); + ctx->unbindBel(bel); } if (cell->bel != BelId()) { - ctx->unbindBelUnlocked(cell->bel); + ctx->unbindBel(cell->bel); } - ctx->bindBelUnlocked(bel, cell->name, STRENGTH_LOCKED); + ctx->bindBel(bel, cell->name, STRENGTH_LOCKED); rippedCells.erase(cell->name); // If cell was ripped up previously, no need to re-place loc.second = true; // Bel is now unavailable for further use } @@ -435,7 +435,7 @@ class PlacementLegaliser CellInfo *target = nullptr; for (int z = 0; z < 8; z++) { BelId bel = logic_bels.at(x).at(y).at(z).first; - IdString cell = ctx->getBoundBelCellUnlocked(bel); + IdString cell = ctx->getBoundBelCell(bel); if (cell != IdString()) { CellInfo *ci = ctx->cells.at(cell).get(); if (ci->belStrength >= STRENGTH_STRONG) @@ -448,7 +448,7 @@ class PlacementLegaliser } } if (target != nullptr) { - ctx->unbindBelUnlocked(target->bel); + ctx->unbindBel(target->bel); rippedCells.insert(target->name); changed = true; } -- cgit v1.2.3