From 6a32aca4ac8705b637943c236cedd2f36422fb21 Mon Sep 17 00:00:00 2001 From: gatecat Date: Fri, 18 Feb 2022 10:52:37 +0000 Subject: refactor: New member functions to replace design_utils Signed-off-by: gatecat --- generic/arch.cc | 2 +- generic/cells.cc | 22 +++++++++++----------- generic/pack.cc | 2 +- generic/viaduct/example/example.cc | 6 +++--- generic/viaduct_helpers.cc | 8 ++++---- 5 files changed, 20 insertions(+), 20 deletions(-) (limited to 'generic') diff --git a/generic/arch.cc b/generic/arch.cc index ad054efd..c4814bab 100644 --- a/generic/arch.cc +++ b/generic/arch.cc @@ -721,7 +721,7 @@ void Arch::assignArchInfo() CellInfo *ci = cell.second.get(); if (ci->type == id("GENERIC_SLICE")) { ci->is_slice = true; - ci->slice_clk = get_net_or_empty(ci, id("CLK")); + ci->slice_clk = ci->getPort(id("CLK")); } else { ci->is_slice = false; } diff --git a/generic/cells.cc b/generic/cells.cc index c14ddf73..76d6474f 100644 --- a/generic/cells.cc +++ b/generic/cells.cc @@ -66,19 +66,19 @@ void lut_to_lc(const Context *ctx, CellInfo *lut, CellInfo *lc, bool no_dff) for (int i = 0; i < lut_k; i++) { IdString port = ctx->id("I[" + std::to_string(i) + "]"); - replace_port(lut, port, lc, port); + lut->movePortTo(port, lc, port); } if (no_dff) { lc->params[ctx->id("FF_USED")] = 0; - replace_port(lut, ctx->id("Q"), lc, ctx->id("F")); + lut->movePortTo(ctx->id("Q"), lc, ctx->id("F")); } } void dff_to_lc(const Context *ctx, CellInfo *dff, CellInfo *lc, bool pass_thru_lut) { lc->params[ctx->id("FF_USED")] = 1; - replace_port(dff, ctx->id("CLK"), lc, ctx->id("CLK")); + dff->movePortTo(ctx->id("CLK"), lc, ctx->id("CLK")); if (pass_thru_lut) { // Fill LUT with alternating 10 @@ -89,26 +89,26 @@ void dff_to_lc(const Context *ctx, CellInfo *dff, CellInfo *lc, bool pass_thru_l init.append("10"); lc->params[ctx->id("INIT")] = Property::from_string(init); - replace_port(dff, ctx->id("D"), lc, ctx->id("I[0]")); + dff->movePortTo(ctx->id("D"), lc, ctx->id("I[0]")); } - replace_port(dff, ctx->id("Q"), lc, ctx->id("Q")); + dff->movePortTo(ctx->id("Q"), lc, ctx->id("Q")); } void nxio_to_iob(Context *ctx, CellInfo *nxio, CellInfo *iob, pool &todelete_cells) { if (nxio->type == ctx->id("$nextpnr_ibuf")) { iob->params[ctx->id("INPUT_USED")] = 1; - replace_port(nxio, ctx->id("O"), iob, ctx->id("O")); + nxio->movePortTo(ctx->id("O"), iob, ctx->id("O")); } else if (nxio->type == ctx->id("$nextpnr_obuf")) { iob->params[ctx->id("OUTPUT_USED")] = 1; - replace_port(nxio, ctx->id("I"), iob, ctx->id("I")); + nxio->movePortTo(ctx->id("I"), iob, ctx->id("I")); } else if (nxio->type == ctx->id("$nextpnr_iobuf")) { // N.B. tristate will be dealt with below iob->params[ctx->id("INPUT_USED")] = 1; iob->params[ctx->id("OUTPUT_USED")] = 1; - replace_port(nxio, ctx->id("I"), iob, ctx->id("I")); - replace_port(nxio, ctx->id("O"), iob, ctx->id("O")); + nxio->movePortTo(ctx->id("I"), iob, ctx->id("I")); + nxio->movePortTo(ctx->id("O"), iob, ctx->id("O")); } else { NPNR_ASSERT(false); } @@ -118,8 +118,8 @@ void nxio_to_iob(Context *ctx, CellInfo *nxio, CellInfo *iob, pool &to ctx->id("Y")); if (tbuf) { iob->params[ctx->id("ENABLE_USED")] = 1; - replace_port(tbuf, ctx->id("A"), iob, ctx->id("I")); - replace_port(tbuf, ctx->id("E"), iob, ctx->id("EN")); + tbuf->movePortTo(ctx->id("A"), iob, ctx->id("I")); + tbuf->movePortTo(ctx->id("E"), iob, ctx->id("EN")); if (donet->users.size() > 1) { for (auto user : donet->users) diff --git a/generic/pack.cc b/generic/pack.cc index 8bdbbed0..cb3f5897 100644 --- a/generic/pack.cc +++ b/generic/pack.cc @@ -242,7 +242,7 @@ static void pack_io(Context *ctx) } else if (bool_or_default(ctx->settings, ctx->id("disable_iobs"))) { // No IO buffer insertion; just remove nextpnr_[io]buf for (auto &p : ci->ports) - disconnect_port(ctx, ci, p.first); + ci->disconnectPort(p.first); } else { // Create a GENERIC_IOB buffer std::unique_ptr ice_cell = diff --git a/generic/viaduct/example/example.cc b/generic/viaduct/example/example.cc index 3d1c201c..49b36792 100644 --- a/generic/viaduct/example/example.cc +++ b/generic/viaduct/example/example.cc @@ -253,10 +253,10 @@ struct ExampleImpl : ViaductAPI CellInfo *ci = cell.second.get(); auto &fc = fast_cell_info.at(ci->flat_index); if (ci->type == id_LUT4) { - fc.lut_f = get_net_or_empty(ci, id_F); - fc.lut_i3_used = (get_net_or_empty(ci, ctx->id(stringf("I[%d]", K - 1))) != nullptr); + fc.lut_f = ci->getPort(id_F); + fc.lut_i3_used = (ci->getPort(ctx->id(stringf("I[%d]", K - 1))) != nullptr); } else if (ci->type == id_DFF) { - fc.ff_d = get_net_or_empty(ci, id_D); + fc.ff_d = ci->getPort(id_D); } } } diff --git a/generic/viaduct_helpers.cc b/generic/viaduct_helpers.cc index e9f7fa60..10c3b802 100644 --- a/generic/viaduct_helpers.cc +++ b/generic/viaduct_helpers.cc @@ -59,13 +59,13 @@ void ViaductHelpers::remove_nextpnr_iobs(const pool &top_ports) auto &ci = *cell.second; if (!ci.type.in(ctx->id("$nextpnr_ibuf"), ctx->id("$nextpnr_obuf"), ctx->id("$nextpnr_iobuf"))) continue; - NetInfo *i = get_net_or_empty(&ci, ctx->id("I")); + NetInfo *i = ci.getPort(ctx->id("I")); if (i && i->driver.cell) { if (!top_ports.count(CellTypePort(i->driver))) log_error("Top-level port '%s' driven by illegal port %s.%s\n", ctx->nameOf(&ci), ctx->nameOf(i->driver.cell), ctx->nameOf(i->driver.port)); } - NetInfo *o = get_net_or_empty(&ci, ctx->id("O")); + NetInfo *o = ci.getPort(ctx->id("O")); if (o) { for (auto &usr : o->users) { if (!top_ports.count(CellTypePort(usr))) @@ -73,8 +73,8 @@ void ViaductHelpers::remove_nextpnr_iobs(const pool &top_ports) ctx->nameOf(usr.cell), ctx->nameOf(usr.port)); } } - disconnect_port(ctx, &ci, ctx->id("I")); - disconnect_port(ctx, &ci, ctx->id("O")); + ci.disconnectPort(ctx->id("I")); + ci.disconnectPort(ctx->id("O")); to_remove.push_back(ci.name); } for (IdString cell_name : to_remove) -- cgit v1.2.3