From 8637e3bc182bfe2f63e1904cb8ecbaf36b6bc733 Mon Sep 17 00:00:00 2001 From: Lofty Date: Mon, 21 Jul 2025 11:52:02 +0100 Subject: [PATCH] heavy refactoring --- himbaechel/uarch/gatemate/route_mult.cc | 399 +++++++++++++----------- 1 file changed, 211 insertions(+), 188 deletions(-) diff --git a/himbaechel/uarch/gatemate/route_mult.cc b/himbaechel/uarch/gatemate/route_mult.cc index 4eb045a5..fc978eb6 100644 --- a/himbaechel/uarch/gatemate/route_mult.cc +++ b/himbaechel/uarch/gatemate/route_mult.cc @@ -19,12 +19,212 @@ #include "gatemate.h" #include "log.h" +#include "nextpnr_assertions.h" #include "nextpnr_base_types.h" #include "nextpnr_namespaces.h" #define HIMBAECHEL_CONSTIDS "uarch/gatemate/constids.inc" #include "himbaechel_constids.h" +namespace { + USING_NEXTPNR_NAMESPACE; + + void find_and_bind_downhill_pip(Context *ctx, WireId from, WireId to, NetInfo *net) { + NPNR_ASSERT(from != WireId()); + NPNR_ASSERT(to != WireId()); + for (auto pip : ctx->getPipsDownhill(from)) { + if (ctx->getPipDstWire(pip) == to) { + log_info(" pip %s: %s -> %s\n", ctx->nameOfPip(pip), ctx->nameOfWire(from), ctx->nameOfWire(to)); + + ctx->bindPip(pip, net, STRENGTH_LOCKED); + return; + } + } + log_error("Couldn't find pip from %s to %s\n", ctx->nameOfWire(from), ctx->nameOfWire(to)); + } + + void route_mult_x1y1_lower(Context *ctx, NetInfo *net, CellInfo* lower, Loc loc, bool is_fourgroup_a) { + log_info(" routing net '%s' -> IN5\n", net->name.c_str(ctx)); + + auto x1y1 = ctx->idf("X%dY%d", loc.x, loc.y); + auto x2y1 = ctx->idf("X%dY%d", loc.x + 1, loc.y); + + auto cpe_combout1 = ctx->getBelPinWire(lower->bel, id_OUT); + auto cpe_out1_int = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("CPE.OUT1_int"))); + auto in_mux = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("IM.P05.D0"))); + + ctx->bindWire(cpe_combout1, net, STRENGTH_LOCKED); + find_and_bind_downhill_pip(ctx, cpe_combout1, cpe_out1_int, net); + + if (is_fourgroup_a) { + auto sb_big = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("SB_BIG.P05.D0"))); + + find_and_bind_downhill_pip(ctx, cpe_out1_int, sb_big, net); + find_and_bind_downhill_pip(ctx, sb_big, in_mux, net); // inverting + } else { + auto sb_sml_d0 = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("SB_SML.P05.D0"))); + auto sb_sml_y1_int = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("SB_SML.P05.Y1_int"))); + + find_and_bind_downhill_pip(ctx, cpe_out1_int, sb_sml_d0, net); + find_and_bind_downhill_pip(ctx, sb_sml_d0, sb_sml_y1_int, net); + find_and_bind_downhill_pip(ctx, sb_sml_y1_int, in_mux, net); // inverting + } + + auto cpe_in5 = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("CPE.IN5"))); + auto cpe_in5_int = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("CPE.IN5_int"))); + + find_and_bind_downhill_pip(ctx, in_mux, cpe_in5, net); // inverting + find_and_bind_downhill_pip(ctx, cpe_in5, cpe_in5_int, net); + } + + void route_mult_x1y1_upper_in1(Context *ctx, NetInfo *net, CellInfo* upper, Loc loc, bool is_fourgroup_a) { + log_info(" routing net '%s' -> IN1\n", net->name.c_str(ctx)); + + auto x1y1 = ctx->idf("X%dY%d", loc.x, loc.y); + auto x2y1 = ctx->idf("X%dY%d", loc.x + 1, loc.y); + + auto cpe_combout2 = ctx->getBelPinWire(upper->bel, id_OUT); + auto cpe_out2_int = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("CPE.OUT2_int"))); + auto in_mux = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("IM.P01.D0"))); + + ctx->bindWire(cpe_combout2, net, STRENGTH_LOCKED); + find_and_bind_downhill_pip(ctx, cpe_combout2, cpe_out2_int, net); + + if (is_fourgroup_a) { + auto sb_big = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("SB_BIG.P01.D0"))); + + find_and_bind_downhill_pip(ctx, cpe_out2_int, sb_big, net); + find_and_bind_downhill_pip(ctx, sb_big, in_mux, net); // inverting + } else { + auto sb_sml_d0 = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("SB_SML.P01.D0"))); + auto sb_sml_y1_int = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("SB_SML.P01.Y1_int"))); + + find_and_bind_downhill_pip(ctx, cpe_out2_int, sb_sml_d0, net); + find_and_bind_downhill_pip(ctx, sb_sml_d0, sb_sml_y1_int, net); + find_and_bind_downhill_pip(ctx, sb_sml_y1_int, in_mux, net); // inverting + } + + auto cpe_in1 = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("CPE.IN1"))); + auto cpe_in1_int = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("CPE.IN1_int"))); + + find_and_bind_downhill_pip(ctx, in_mux, cpe_in1, net); // inverting + find_and_bind_downhill_pip(ctx, cpe_in1, cpe_in1_int, net); + } + + void route_mult_x1y1_upper_in8(Context *ctx, NetInfo *net, CellInfo* upper, Loc loc, bool is_fourgroup_a) { + log_info(" routing net '%s' -> IN8\n", net->name.c_str(ctx)); + + auto x2y2 = ctx->idf("X%dY%d", loc.x + 1, loc.y + 1); + auto x4y2 = ctx->idf("X%dY%d", loc.x + 3, loc.y + 1); + + auto out_mux_d0 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("OM.P12.D0"))); + auto out_mux_y = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("OM.P12.Y"))); + auto in_mux_p12 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P12.D2"))); + + find_and_bind_downhill_pip(ctx, out_mux_d0, out_mux_y, net); // inverting + + if (is_fourgroup_a) { + auto sb_sml = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("SB_SML.P12.Y1_int"))); + auto sb_big_d2_1 = ctx->getWireByName(IdStringList::concat(x4y2, ctx->idf("SB_BIG.P12.D2_1"))); + auto sb_big_y1 = ctx->getWireByName(IdStringList::concat(x4y2, ctx->idf("SB_BIG.P12.Y1"))); + auto sb_big_ydiag = ctx->getWireByName(IdStringList::concat(x4y2, ctx->idf("SB_BIG.P12.YDIAG"))); + + find_and_bind_downhill_pip(ctx, out_mux_y, sb_sml, net); + find_and_bind_downhill_pip(ctx, sb_sml, sb_big_d2_1, net); // inverting + find_and_bind_downhill_pip(ctx, sb_big_d2_1, sb_big_y1, net); // inverting + find_and_bind_downhill_pip(ctx, sb_big_y1, sb_big_ydiag, net); // inverting + find_and_bind_downhill_pip(ctx, sb_big_ydiag, in_mux_p12, net); // inverting + } else { + auto sb_big = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("SB_BIG.P12.Y1"))); // aka x4y2/SB_SML.P12.D2_1 + auto sb_sml_y1_int = ctx->getWireByName(IdStringList::concat(x4y2, ctx->idf("SB_SML.P12.Y1_int"))); + auto sb_sml_ydiag_int = ctx->getWireByName(IdStringList::concat(x4y2, ctx->idf("SB_SML.P12.YDIAG_int"))); + auto sb_sml_y3_int = ctx->getWireByName(IdStringList::concat(x4y2, ctx->idf("SB_SML.P12.Y3_int"))); + + find_and_bind_downhill_pip(ctx, out_mux_y, sb_big, net); // inverting + find_and_bind_downhill_pip(ctx, sb_big, sb_sml_y1_int, net); + find_and_bind_downhill_pip(ctx, sb_sml_y1_int, sb_sml_ydiag_int, net); + find_and_bind_downhill_pip(ctx, sb_sml_ydiag_int, sb_sml_y3_int, net); + find_and_bind_downhill_pip(ctx, sb_sml_y3_int, in_mux_p12, net); // inverting + } + + auto in_mux_p04 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P04.D7"))); // aka IM.P12.Y + auto in_mux_p08 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P08.D6"))); // aka IM.P04.Y + auto in_mux_p08_y = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P08.Y"))); + auto cpe_in8_int = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("CPE.IN8_int"))); + + find_and_bind_downhill_pip(ctx, in_mux_p12, in_mux_p04, net); // inverting + find_and_bind_downhill_pip(ctx, in_mux_p04, in_mux_p08, net); // inverting + find_and_bind_downhill_pip(ctx, in_mux_p08, in_mux_p08_y, net); // inverting + find_and_bind_downhill_pip(ctx, in_mux_p08_y, cpe_in8_int, net); + } + + void route_mult_x1y2_lower(Context *ctx, NetInfo *net, CellInfo* lower, Loc loc, bool is_fourgroup_a) { + log_info(" routing net '%s' -> IN5\n", net->name.c_str(ctx)); + + auto x1y1 = ctx->idf("X%dY%d", loc.x, loc.y); + + auto cpe_combout1 = ctx->getBelPinWire(lower->bel, id_OUT); + auto cpe_out1_int = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("CPE.OUT1_int"))); + + //ctx->bindWire(cpe_combout1, net, STRENGTH_LOCKED); + //find_and_bind_downhill_pip(ctx, cpe_combout1, cpe_out1_int, net); + } + + void route_mult_x1y2_upper_in1(Context *ctx, NetInfo *net, CellInfo* upper, Loc loc, bool is_fourgroup_a) { + log_info(" routing net '%s' -> IN1\n", net->name.c_str(ctx)); + + auto x1y1 = ctx->idf("X%dY%d", loc.x, loc.y); + auto x2y1 = ctx->idf("X%dY%d", loc.x + 1, loc.y); + + auto cpe_combout2 = ctx->getBelPinWire(upper->bel, id_OUT); + auto cpe_out2_int = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("CPE.OUT2_int"))); + + ctx->bindWire(cpe_combout2, net, STRENGTH_LOCKED); + find_and_bind_downhill_pip(ctx, cpe_combout2, cpe_out2_int, net); + + auto out_mux_d1 = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("OM.P10.D1"))); + + find_and_bind_downhill_pip(ctx, cpe_out2_int, out_mux_d1, net); // inverting + } + + void route_mult_x1y2_upper_in8(Context *ctx, NetInfo *net, CellInfo* upper, Loc loc, bool is_fourgroup_a) { + log_info(" routing net '%s' -> IN8\n", net->name.c_str(ctx)); + + auto x2y1 = ctx->idf("X%dY%d", loc.x + 1, loc.y); + auto x2y2 = ctx->idf("X%dY%d", loc.x + 1, loc.y + 1); + + auto out_mux_d1 = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("OM.P10.D1"))); + auto out_mux_y = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("OM.P10.Y"))); + auto in_mux_p10 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P10.D1"))); + + find_and_bind_downhill_pip(ctx, out_mux_d1, out_mux_y, net); // inverting + + if (is_fourgroup_a) { + auto sb_sml = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("SB_SML.P10.Y2_int"))); + + find_and_bind_downhill_pip(ctx, out_mux_y, sb_sml, net); + find_and_bind_downhill_pip(ctx, sb_sml, in_mux_p10, net); // inverting + } else { + // x2y1/OM.P10.Y is x2y1/SB_BIG.P10.D0 + // x2y2/IM.P10.D1 is x2y1/SB_BIG.P10.Y2 + + find_and_bind_downhill_pip(ctx, out_mux_y, in_mux_p10, net); // inverting + } + + auto in_mux_p12 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P12.D6"))); // aka IM.P10.Y + auto in_mux_p04 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P04.D7"))); // aka IM.P12.Y + auto in_mux_p08 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P08.D6"))); // aka IM.P04.Y + auto in_mux_p08_y = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P08.Y"))); + auto cpe_in8_int = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("CPE.IN8_int"))); + + find_and_bind_downhill_pip(ctx, in_mux_p10, in_mux_p12, net); // inverting + find_and_bind_downhill_pip(ctx, in_mux_p12, in_mux_p04, net); // inverting + find_and_bind_downhill_pip(ctx, in_mux_p04, in_mux_p08, net); // inverting + find_and_bind_downhill_pip(ctx, in_mux_p08, in_mux_p08_y, net); // inverting + find_and_bind_downhill_pip(ctx, in_mux_p08_y, cpe_in8_int, net); + } +} + NEXTPNR_NAMESPACE_BEGIN void GateMateImpl::route_mult() { @@ -63,196 +263,19 @@ void GateMateImpl::route_mult() { log_info(" -> %s.%s\n", sink_port.cell->name.c_str(ctx), sink_port.port.c_str(ctx)); } - auto x1y1 = ctx->idf("X%dY%d", loc.x, loc.y); - auto x2y1 = ctx->idf("X%dY%d", loc.x + 1, loc.y); - auto x2y2 = ctx->idf("X%dY%d", loc.x + 1, loc.y + 1); - auto x4y2 = ctx->idf("X%dY%d", loc.x + 3, loc.y + 1); - - auto find_downhill_pip = [&](WireId from, WireId to) { - NPNR_ASSERT(from != WireId()); - NPNR_ASSERT(to != WireId()); - for (auto pip : ctx->getPipsDownhill(from)) { - if (ctx->getPipDstWire(pip) == to) { - log_info(" pip %s: %s -> %s\n", ctx->nameOfPip(pip), ctx->nameOfWire(from), ctx->nameOfWire(to)); - - return pip; - } - } - log_error("Couldn't find pip from %s to %s\n", ctx->nameOfWire(from), ctx->nameOfWire(to)); - }; - - if (x_within_fourgroup == 0 && y_within_fourgroup == 0) { - auto cpe_combout1 = ctx->getBelPinWire(lower->bel, id_OUT); - auto cpe_out1_int = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("CPE.OUT1_int"))); - - ctx->bindWire(cpe_combout1, lower_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(cpe_combout1, cpe_out1_int), lower_out, STRENGTH_LOCKED); - - auto cpe_combout2 = ctx->getBelPinWire(upper->bel, id_OUT); - auto cpe_out2_int = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("CPE.OUT2_int"))); - - ctx->bindWire(cpe_combout2, upper_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(cpe_combout2, cpe_out2_int), upper_out, STRENGTH_LOCKED); - - { - log_info(" routing net '%s' -> IN5\n", lower_out->name.c_str(ctx)); - - auto in_mux = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("IM.P05.D0"))); - auto cpe_in5 = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("CPE.IN5"))); - auto cpe_in5_int = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("CPE.IN5_int"))); - - if (is_fourgroup_a) { - auto sb_big = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("SB_BIG.P05.D0"))); - - ctx->bindPip(find_downhill_pip(cpe_out1_int, sb_big), lower_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(sb_big, in_mux), lower_out, STRENGTH_LOCKED); // inverting - } else { - auto sb_sml_d0 = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("SB_SML.P05.D0"))); - auto sb_sml_y1_int = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("SB_SML.P05.Y1_int"))); - - ctx->bindPip(find_downhill_pip(cpe_out1_int, sb_sml_d0), lower_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(sb_sml_d0, sb_sml_y1_int), lower_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(sb_sml_y1_int, in_mux), lower_out, STRENGTH_LOCKED); // inverting - } - - ctx->bindPip(find_downhill_pip(in_mux, cpe_in5), lower_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(cpe_in5, cpe_in5_int), lower_out, STRENGTH_LOCKED); - } - - { - log_info(" routing net '%s' -> IN1\n", upper_out->name.c_str(ctx)); - - auto in_mux = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("IM.P01.D0"))); - auto cpe_in1 = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("CPE.IN1"))); - auto cpe_in1_int = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("CPE.IN1_int"))); - - if (is_fourgroup_a) { - auto sb_big = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("SB_BIG.P01.D0"))); - - ctx->bindPip(find_downhill_pip(cpe_out2_int, sb_big), upper_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(sb_big, in_mux), upper_out, STRENGTH_LOCKED); // inverting - } else { - auto sb_sml_d0 = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("SB_SML.P01.D0"))); - auto sb_sml_y1_int = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("SB_SML.P01.Y1_int"))); - - ctx->bindPip(find_downhill_pip(cpe_out2_int, sb_sml_d0), upper_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(sb_sml_d0, sb_sml_y1_int), upper_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(sb_sml_y1_int, in_mux), upper_out, STRENGTH_LOCKED); // inverting - } - - ctx->bindPip(find_downhill_pip(in_mux, cpe_in1), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(cpe_in1, cpe_in1_int), upper_out, STRENGTH_LOCKED); - } - - if (needs_in8_route) { - log_info(" routing net '%s' -> IN8\n", upper_out->name.c_str(ctx)); - - auto out_mux_d0 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("OM.P12.D0"))); - auto out_mux_y = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("OM.P12.Y"))); - auto in_mux_p12 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P12.D2"))); - auto in_mux_p04 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P04.D7"))); // aka IM.P12.Y - auto in_mux_p08 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P08.D6"))); // aka IM.P04.Y - auto in_mux_p08_y = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P08.Y"))); - auto cpe_in8_int = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("CPE.IN8_int"))); - - ctx->bindPip(find_downhill_pip(out_mux_d0, out_mux_y), upper_out, STRENGTH_LOCKED); // inverting - - if (is_fourgroup_a) { - auto sb_sml = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("SB_SML.P12.Y1_int"))); - auto sb_big_d2_1 = ctx->getWireByName(IdStringList::concat(x4y2, ctx->idf("SB_BIG.P12.D2_1"))); - auto sb_big_y1 = ctx->getWireByName(IdStringList::concat(x4y2, ctx->idf("SB_BIG.P12.Y1"))); - auto sb_big_ydiag = ctx->getWireByName(IdStringList::concat(x4y2, ctx->idf("SB_BIG.P12.YDIAG"))); - - ctx->bindPip(find_downhill_pip(out_mux_y, sb_sml), upper_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(sb_sml, sb_big_d2_1), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(sb_big_d2_1, sb_big_y1), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(sb_big_y1, sb_big_ydiag), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(sb_big_ydiag, in_mux_p12), upper_out, STRENGTH_LOCKED); // inverting - } else { - auto sb_big = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("SB_BIG.P12.Y1"))); // aka x4y2/SB_SML.P12.D2_1 - auto sb_sml_y1_int = ctx->getWireByName(IdStringList::concat(x4y2, ctx->idf("SB_SML.P12.Y1_int"))); - auto sb_sml_ydiag_int = ctx->getWireByName(IdStringList::concat(x4y2, ctx->idf("SB_SML.P12.YDIAG_int"))); - auto sb_sml_y3_int = ctx->getWireByName(IdStringList::concat(x4y2, ctx->idf("SB_SML.P12.Y3_int"))); - - ctx->bindPip(find_downhill_pip(out_mux_y, sb_big), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(sb_big, sb_sml_y1_int), upper_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(sb_sml_y1_int, sb_sml_ydiag_int), upper_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(sb_sml_ydiag_int, sb_sml_y3_int), upper_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(sb_sml_y3_int, in_mux_p12), upper_out, STRENGTH_LOCKED); // inverting - } - - ctx->bindPip(find_downhill_pip(in_mux_p12, in_mux_p04), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(in_mux_p04, in_mux_p08), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(in_mux_p08, in_mux_p08_y), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(in_mux_p08_y, cpe_in8_int), upper_out, STRENGTH_LOCKED); - } + route_mult_x1y1_lower(ctx, lower_out, lower, loc, is_fourgroup_a); + route_mult_x1y1_upper_in1(ctx, upper_out, upper, loc, is_fourgroup_a); + if (needs_in8_route) + route_mult_x1y1_upper_in8(ctx, upper_out, upper, loc, is_fourgroup_a); + } else if (x_within_fourgroup == 0 && y_within_fourgroup == 1) { + route_mult_x1y2_lower(ctx, lower_out, lower, loc, is_fourgroup_a); + route_mult_x1y2_upper_in1(ctx, upper_out, upper, loc, is_fourgroup_a); + if (needs_in8_route) + route_mult_x1y2_upper_in8(ctx, upper_out, upper, loc, is_fourgroup_a); } else if (is_fourgroup_a) { - if (x_within_fourgroup == 0 && y_within_fourgroup == 1) { - /* auto cpe_combout1 = ctx->getBelPinWire(lower->bel, id_OUT); - auto cpe_out1_int = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("CPE.OUT1_int"))); - - ctx->bindWire(cpe_combout1, lower_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(cpe_combout1, cpe_out1_int), lower_out, STRENGTH_LOCKED);*/ - - auto cpe_combout2 = ctx->getBelPinWire(upper->bel, id_OUT); - auto cpe_out2_int = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("CPE.OUT2_int"))); - - ctx->bindWire(cpe_combout2, upper_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(cpe_combout2, cpe_out2_int), upper_out, STRENGTH_LOCKED); - - { - //log_info(" routing net '%s' -> IN5\n", lower_out->name.c_str(ctx)); - - auto sb_sml = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("SB_SML.P06.D0"))); - // the cologne chip guide for this magically teleports from plane 6 to plane 5. I do not know how. - } - - if (needs_in8_route) { - log_info(" routing net '%s' -> IN8\n", upper_out->name.c_str(ctx)); - - auto out_mux_d1 = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("OM.P10.D1"))); - auto out_mux_y = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("OM.P10.Y"))); - auto sb_sml = ctx->getWireByName(IdStringList::concat(x2y1, ctx->idf("SB_SML.P10.Y2_int"))); - auto in_mux_p10 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P10.D1"))); - auto in_mux_p12 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P12.D6"))); // aka IM.P10.Y - auto in_mux_p04 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P04.D7"))); // aka IM.P12.Y - auto in_mux_p08 = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P08.D6"))); // aka IM.P04.Y - auto in_mux_p08_y = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("IM.P08.Y"))); - auto cpe_in8_int = ctx->getWireByName(IdStringList::concat(x2y2, ctx->idf("CPE.IN8_int"))); - - ctx->bindPip(find_downhill_pip(cpe_out2_int, out_mux_d1), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(out_mux_d1, out_mux_y), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(out_mux_y, sb_sml), upper_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(sb_sml, in_mux_p10), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(in_mux_p10, in_mux_p12), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(in_mux_p12, in_mux_p04), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(in_mux_p04, in_mux_p08), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(in_mux_p08, in_mux_p08_y), upper_out, STRENGTH_LOCKED); // inverting - ctx->bindPip(find_downhill_pip(in_mux_p08_y, cpe_in8_int), upper_out, STRENGTH_LOCKED); - } - } else if (false && x_within_fourgroup == 0 && y_within_fourgroup == 1) { - /* auto cpe_combout1 = ctx->getBelPinWire(lower->bel, id_OUT); - auto cpe_out1_int = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("CPE.OUT1_int"))); - - ctx->bindWire(cpe_combout1, lower_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(cpe_combout1, cpe_out1_int), lower_out, STRENGTH_LOCKED);*/ - - auto cpe_combout2 = ctx->getBelPinWire(upper->bel, id_OUT); - auto cpe_out2_int = ctx->getWireByName(IdStringList::concat(x1y1, ctx->idf("CPE.OUT2_int"))); - - ctx->bindWire(cpe_combout2, upper_out, STRENGTH_LOCKED); - ctx->bindPip(find_downhill_pip(cpe_combout2, cpe_out2_int), upper_out, STRENGTH_LOCKED); - - if (needs_in8_route) { - log_info(" routing net '%s' -> IN8\n", upper_out->name.c_str(ctx)); - - - } - } else { - log_info(" don't know how to route net '%s' (it's four-group A, (%d, %d))\n", lower_out->name.c_str(ctx), x_within_fourgroup, y_within_fourgroup); - log_info(" don't know how to route net '%s' (it's four-group A, (%d, %d))\n", upper_out->name.c_str(ctx), x_within_fourgroup, y_within_fourgroup); - } + log_info(" don't know how to route net '%s' (it's four-group A, (%d, %d))\n", lower_out->name.c_str(ctx), x_within_fourgroup, y_within_fourgroup); + log_info(" don't know how to route net '%s' (it's four-group A, (%d, %d))\n", upper_out->name.c_str(ctx), x_within_fourgroup, y_within_fourgroup); } else { log_info(" don't know how to route net '%s' (it's four-group B, (%d, %d))\n", lower_out->name.c_str(ctx), x_within_fourgroup, y_within_fourgroup); log_info(" don't know how to route net '%s' (it's four-group B, (%d, %d))\n", upper_out->name.c_str(ctx), x_within_fourgroup, y_within_fourgroup);