diff options
Diffstat (limited to 'ecp5/arch.cc')
-rw-r--r-- | ecp5/arch.cc | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/ecp5/arch.cc b/ecp5/arch.cc index 5c5689f0..1938c297 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -402,5 +402,84 @@ IdString ArchReadMethods::getBoundBelCell(BelId bel) const return bel_to_cell.at(bel); } +void ArchMutateMethods::unbindWire(WireId wire) +{ + NPNR_ASSERT(wire != WireId()); + NPNR_ASSERT(wire_to_net[wire] != IdString()); + + auto &net_wires = parent_->nets[wire_to_net[wire]]->wires; + auto it = net_wires.find(wire); + NPNR_ASSERT(it != net_wires.end()); + + auto pip = it->second.pip; + if (pip != PipId()) { + pip_to_net[pip] = IdString(); + } + + net_wires.erase(it); + wire_to_net[wire] = IdString(); +} + +void ArchMutateMethods::unbindPip(PipId pip) +{ + NPNR_ASSERT(pip != PipId()); + NPNR_ASSERT(pip_to_net[pip] != IdString()); + + WireId dst; + dst.index = parent_->locInfo(pip)->pip_data[pip.index].dst_idx; + dst.location = pip.location + parent_->locInfo(pip)->pip_data[pip.index].rel_dst_loc; + NPNR_ASSERT(wire_to_net[dst] != IdString()); + wire_to_net[dst] = IdString(); + parent_->nets[pip_to_net[pip]]->wires.erase(dst); + + pip_to_net[pip] = IdString(); +} + +void ArchMutateMethods::unbindBel(BelId bel) +{ + NPNR_ASSERT(bel != BelId()); + NPNR_ASSERT(bel_to_cell[bel] != IdString()); + parent_->cells[bel_to_cell[bel]]->bel = BelId(); + parent_->cells[bel_to_cell[bel]]->belStrength = STRENGTH_NONE; + bel_to_cell[bel] = IdString(); +} + +void ArchMutateMethods::bindWire(WireId wire, IdString net, PlaceStrength strength) +{ + NPNR_ASSERT(wire != WireId()); + NPNR_ASSERT(wire_to_net[wire] == IdString()); + wire_to_net[wire] = net; + parent_->nets[net]->wires[wire].pip = PipId(); + parent_->nets[net]->wires[wire].strength = strength; +} + +void ArchMutateMethods::bindPip(PipId pip, IdString net, PlaceStrength strength) +{ + NPNR_ASSERT(pip != PipId()); + NPNR_ASSERT(pip_to_net[pip] == IdString()); + + pip_to_net[pip] = net; + + WireId dst; + dst.index = parent_->locInfo(pip)->pip_data[pip.index].dst_idx; + dst.location = pip.location + parent_->locInfo(pip)->pip_data[pip.index].rel_dst_loc; + NPNR_ASSERT(wire_to_net[dst] == IdString()); + wire_to_net[dst] = net; + parent_->nets[net]->wires[dst].pip = pip; + parent_->nets[net]->wires[dst].strength = strength; +} + +void ArchMutateMethods::bindBel(BelId bel, IdString cell, PlaceStrength strength) +{ + NPNR_ASSERT(bel != BelId()); + NPNR_ASSERT(bel_to_cell[bel] == IdString()); + bel_to_cell[bel] = cell; + parent_->cells[cell]->bel = bel; + parent_->cells[cell]->belStrength = strength; +} + +CellInfo *ArchMutateMethods::getCell(IdString cell) { return parent_->cells.at(cell).get(); } + + NEXTPNR_NAMESPACE_END |