diff options
Diffstat (limited to 'common/basectx.cc')
-rw-r--r-- | common/basectx.cc | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/common/basectx.cc b/common/basectx.cc index b9036ed6..83a2deea 100644 --- a/common/basectx.cc +++ b/common/basectx.cc @@ -22,7 +22,6 @@ #include <boost/algorithm/string.hpp> #include "context.h" -#include "design_utils.h" #include "log.h" NEXTPNR_NAMESPACE_BEGIN @@ -211,8 +210,7 @@ NetInfo *BaseCtx::createNet(IdString name) { NPNR_ASSERT(!nets.count(name)); NPNR_ASSERT(!net_aliases.count(name)); - std::unique_ptr<NetInfo> net{new NetInfo}; - net->name = name; + auto net = std::make_unique<NetInfo>(name); net_aliases[name] = name; NetInfo *ptr = net.get(); nets[name] = std::move(net); @@ -224,13 +222,23 @@ void BaseCtx::connectPort(IdString net, IdString cell, IdString port) { NetInfo *net_info = getNetByAlias(net); CellInfo *cell_info = cells.at(cell).get(); - connect_port(getCtx(), net_info, cell_info, port); + cell_info->connectPort(port, net_info); } void BaseCtx::disconnectPort(IdString cell, IdString port) { CellInfo *cell_info = cells.at(cell).get(); - disconnect_port(getCtx(), cell_info, port); + cell_info->disconnectPort(port); +} + +void BaseCtx::renameNet(IdString old_name, IdString new_name) +{ + NetInfo *net = nets.at(old_name).get(); + NPNR_ASSERT(!nets.count(new_name)); + nets[new_name]; + std::swap(nets.at(net->name), nets.at(new_name)); + nets.erase(net->name); + net->name = new_name; } void BaseCtx::ripupNet(IdString name) @@ -252,9 +260,7 @@ void BaseCtx::lockNetRouting(IdString name) CellInfo *BaseCtx::createCell(IdString name, IdString type) { NPNR_ASSERT(!cells.count(name)); - std::unique_ptr<CellInfo> cell{new CellInfo}; - cell->name = name; - cell->type = type; + auto cell = std::make_unique<CellInfo>(getCtx(), name, type); CellInfo *ptr = cell.get(); cells[name] = std::move(cell); refreshUi(); |