From cd1217efdbe3fcf92aa5e29443e75aed30e583dc Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 9 Jul 2025 09:03:56 +0200 Subject: [PATCH] Update FF params and ports first --- himbaechel/uarch/gatemate/pack.cc | 1 + himbaechel/uarch/gatemate/pack.h | 1 + himbaechel/uarch/gatemate/pack_cpe.cc | 14 ++++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/himbaechel/uarch/gatemate/pack.cc b/himbaechel/uarch/gatemate/pack.cc index 24fa57ec..01a051cd 100644 --- a/himbaechel/uarch/gatemate/pack.cc +++ b/himbaechel/uarch/gatemate/pack.cc @@ -175,6 +175,7 @@ void GateMatePacker::optimize_lut() void GateMatePacker::cleanup() { log_info("Running cleanups..\n"); + dff_update_params(); do { count = 0; remove_not_used(); diff --git a/himbaechel/uarch/gatemate/pack.h b/himbaechel/uarch/gatemate/pack.h index 28123f2e..03c54740 100644 --- a/himbaechel/uarch/gatemate/pack.h +++ b/himbaechel/uarch/gatemate/pack.h @@ -72,6 +72,7 @@ struct GateMatePacker private: void rename_param(CellInfo *cell, IdString name, IdString new_name, int width); void dff_to_cpe(CellInfo *dff); + void dff_update_params(); void insert_bufg(CellInfo *cell, IdString port); void disconnect_if_gnd(CellInfo *cell, IdString input); void pll_out(CellInfo *cell, IdString origPort, Loc fixed); diff --git a/himbaechel/uarch/gatemate/pack_cpe.cc b/himbaechel/uarch/gatemate/pack_cpe.cc index ddd211b4..0693c8cb 100644 --- a/himbaechel/uarch/gatemate/pack_cpe.cc +++ b/himbaechel/uarch/gatemate/pack_cpe.cc @@ -141,6 +141,16 @@ void GateMatePacker::dff_to_cpe(CellInfo *dff) } } +void GateMatePacker::dff_update_params() +{ + for (auto &cell : ctx->cells) { + CellInfo &ci = *cell.second; + if (!ci.type.in(id_CC_DFF, id_CC_DLT)) + continue; + dff_to_cpe(&ci); + } +} + void GateMatePacker::pack_cpe() { log_info("Packing CPEs..\n"); @@ -205,7 +215,6 @@ void GateMatePacker::pack_cpe() ci.constr_children.push_back(dff); dff->renamePort(id_D, id_DIN); dff->renamePort(id_Q, id_DOUT); - dff_to_cpe(dff); dff->type = (dff->type == id_CC_DLT) ? id_CPE_LATCH : id_CPE_FF; } } @@ -290,7 +299,6 @@ void GateMatePacker::pack_cpe() ci.constr_children.push_back(dff); dff->renamePort(id_D, id_DIN); dff->renamePort(id_Q, id_DOUT); - dff_to_cpe(dff); dff->type = (dff->type == id_CC_DLT) ? id_CPE_LATCH : id_CPE_FF; } } @@ -325,7 +333,6 @@ void GateMatePacker::pack_cpe() } lt->params[id_INIT_L10] = Property(LUT_D0, 4); ci.movePortTo(id_D, lt, id_IN1); - dff_to_cpe(&ci); ci.type = (ci.type == id_CC_DLT) ? id_CPE_LATCH : id_CPE_FF; NetInfo *conn = ctx->createNet(ctx->idf("%s$di", ci.name.c_str(ctx))); lt->connectPort(id_OUT, conn); @@ -465,7 +472,6 @@ void GateMatePacker::pack_addf() cell->constr_children.push_back(dff); dff->renamePort(id_D, id_DIN); dff->renamePort(id_Q, id_DOUT); - dff_to_cpe(dff); dff->type = (dff->type == id_CC_DLT) ? id_CPE_LATCH : id_CPE_FF; } }