aboutsummaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorgatecat <gatecat@ds0.me>2022-02-16 13:53:47 +0000
committergatecat <gatecat@ds0.me>2022-02-16 15:10:57 +0000
commit30fd86ce69fa65e89dec119e23b5bccb54de70a3 (patch)
tree7700f5ce4d8b40255aa54e08d2c4489e74b906ff /generic
parent02e6d2dbca0433e6f873c6af635cee701e84f5f5 (diff)
downloadnextpnr-30fd86ce69fa65e89dec119e23b5bccb54de70a3.tar.gz
nextpnr-30fd86ce69fa65e89dec119e23b5bccb54de70a3.tar.bz2
nextpnr-30fd86ce69fa65e89dec119e23b5bccb54de70a3.zip
refactor: New NetInfo and CellInfo constructors
Diffstat (limited to 'generic')
-rw-r--r--generic/cells.cc10
-rw-r--r--generic/pack.cc6
2 files changed, 5 insertions, 11 deletions
diff --git a/generic/cells.cc b/generic/cells.cc
index 44b99050..967afb23 100644
--- a/generic/cells.cc
+++ b/generic/cells.cc
@@ -34,13 +34,9 @@ void add_port(const Context *ctx, CellInfo *cell, std::string name, PortType dir
std::unique_ptr<CellInfo> create_generic_cell(Context *ctx, IdString type, std::string name)
{
static int auto_idx = 0;
- std::unique_ptr<CellInfo> new_cell = std::unique_ptr<CellInfo>(new CellInfo());
- if (name.empty()) {
- new_cell->name = ctx->id("$nextpnr_" + type.str(ctx) + "_" + std::to_string(auto_idx++));
- } else {
- new_cell->name = ctx->id(name);
- }
- new_cell->type = type;
+ IdString name_id =
+ name.empty() ? ctx->id("$nextpnr_" + type.str(ctx) + "_" + std::to_string(auto_idx++)) : ctx->id(name);
+ auto new_cell = std::make_unique<CellInfo>(ctx, name_id, type);
if (type == ctx->id("GENERIC_SLICE")) {
new_cell->params[ctx->id("K")] = ctx->args.K;
new_cell->params[ctx->id("INIT")] = 0;
diff --git a/generic/pack.cc b/generic/pack.cc
index 291a528d..8bdbbed0 100644
--- a/generic/pack.cc
+++ b/generic/pack.cc
@@ -140,8 +140,7 @@ static void pack_constants(Context *ctx)
std::unique_ptr<CellInfo> gnd_cell = create_generic_cell(ctx, ctx->id("GENERIC_SLICE"), "$PACKER_GND");
gnd_cell->params[ctx->id("INIT")] = Property(0, 1 << ctx->args.K);
- std::unique_ptr<NetInfo> gnd_net = std::unique_ptr<NetInfo>(new NetInfo);
- gnd_net->name = ctx->id("$PACKER_GND_NET");
+ std::unique_ptr<NetInfo> gnd_net = std::make_unique<NetInfo>(ctx->id("$PACKER_GND_NET"));
gnd_net->driver.cell = gnd_cell.get();
gnd_net->driver.port = ctx->id("F");
gnd_cell->ports.at(ctx->id("F")).net = gnd_net.get();
@@ -149,8 +148,7 @@ static void pack_constants(Context *ctx)
std::unique_ptr<CellInfo> vcc_cell = create_generic_cell(ctx, ctx->id("GENERIC_SLICE"), "$PACKER_VCC");
// Fill with 1s
vcc_cell->params[ctx->id("INIT")] = Property(Property::S1).extract(0, (1 << ctx->args.K), Property::S1);
- std::unique_ptr<NetInfo> vcc_net = std::unique_ptr<NetInfo>(new NetInfo);
- vcc_net->name = ctx->id("$PACKER_VCC_NET");
+ std::unique_ptr<NetInfo> vcc_net = std::make_unique<NetInfo>(ctx->id("$PACKER_VCC_NET"));
vcc_net->driver.cell = vcc_cell.get();
vcc_net->driver.port = ctx->id("F");
vcc_cell->ports.at(ctx->id("F")).net = vcc_net.get();