From 9ef0bc3d3ad667d937ed803eba7b216a604d5624 Mon Sep 17 00:00:00 2001 From: gatecat Date: Wed, 16 Feb 2022 16:45:45 +0000 Subject: refactor: Use cell member functions to add ports Signed-off-by: gatecat --- generic/cells.cc | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'generic') diff --git a/generic/cells.cc b/generic/cells.cc index 967afb23..c14ddf73 100644 --- a/generic/cells.cc +++ b/generic/cells.cc @@ -24,13 +24,6 @@ NEXTPNR_NAMESPACE_BEGIN -void add_port(const Context *ctx, CellInfo *cell, std::string name, PortType dir) -{ - IdString id = ctx->id(name); - NPNR_ASSERT(cell->ports.count(id) == 0); - cell->ports[id] = PortInfo{id, nullptr, dir}; -} - std::unique_ptr create_generic_cell(Context *ctx, IdString type, std::string name) { static int auto_idx = 0; @@ -43,21 +36,21 @@ std::unique_ptr create_generic_cell(Context *ctx, IdString type, std:: new_cell->params[ctx->id("FF_USED")] = 0; for (int i = 0; i < ctx->args.K; i++) - add_port(ctx, new_cell.get(), "I[" + std::to_string(i) + "]", PORT_IN); + new_cell->addInput(ctx->id("I[" + std::to_string(i) + "]")); - add_port(ctx, new_cell.get(), "CLK", PORT_IN); + new_cell->addInput(ctx->id("CLK")); - add_port(ctx, new_cell.get(), "F", PORT_OUT); - add_port(ctx, new_cell.get(), "Q", PORT_OUT); + new_cell->addOutput(ctx->id("F")); + new_cell->addOutput(ctx->id("Q")); } else if (type == ctx->id("GENERIC_IOB")) { new_cell->params[ctx->id("INPUT_USED")] = 0; new_cell->params[ctx->id("OUTPUT_USED")] = 0; new_cell->params[ctx->id("ENABLE_USED")] = 0; - add_port(ctx, new_cell.get(), "PAD", PORT_INOUT); - add_port(ctx, new_cell.get(), "I", PORT_IN); - add_port(ctx, new_cell.get(), "EN", PORT_IN); - add_port(ctx, new_cell.get(), "O", PORT_OUT); + new_cell->addInout(ctx->id("PAD")); + new_cell->addInput(ctx->id("I")); + new_cell->addInput(ctx->id("EN")); + new_cell->addOutput(ctx->id("O")); } else { log_error("unable to create generic cell of type %s", type.c_str(ctx)); } -- cgit v1.2.3