Skip to content

Commit fcf2bf6

Browse files
authored
Merge pull request #970 from yrabbit/nr9-wip
gowin: handle the GW1N-9 feature.
2 parents 2ed68a2 + 85e8570 commit fcf2bf6

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

gowin/arch.cc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ Arch::Arch(ArchArgs args) : args(args)
11191119
z++; /* fall-through*/
11201120
case ID_IOBB:
11211121
z++; /* fall-through*/
1122-
case ID_IOBA:
1122+
case ID_IOBA: {
11231123
snprintf(buf, 32, "R%dC%d_IOB%c", row + 1, col + 1, 'A' + z);
11241124
belname = id(buf);
11251125
addBel(belname, id_IOB, Loc(col, row, z), false);
@@ -1132,7 +1132,22 @@ Arch::Arch(ArchArgs args) : args(args)
11321132
portname = IdString(pairLookup(bel->ports.get(), bel->num_ports, ID_OE)->src_id);
11331133
snprintf(buf, 32, "R%dC%d_%s", row + 1, col + 1, portname.c_str(this));
11341134
addBelInput(belname, id_OEN, id(buf));
1135-
break;
1135+
// GW1NR-9 quirk
1136+
const PairPOD *xxx_port = pairLookup(bel->ports.get(), bel->num_ports, ID_XXX_VSS0);
1137+
if (xxx_port != nullptr) {
1138+
gw1n9_quirk = true;
1139+
portname = IdString(xxx_port->src_id);
1140+
snprintf(buf, 32, "R%dC%d_%s", row + 1, col + 1, portname.c_str(this));
1141+
addBelInput(belname, id_XXX_VSS0, id(buf));
1142+
}
1143+
xxx_port = pairLookup(bel->ports.get(), bel->num_ports, ID_XXX_VSS1);
1144+
if (xxx_port != nullptr) {
1145+
gw1n9_quirk = true;
1146+
portname = IdString(xxx_port->src_id);
1147+
snprintf(buf, 32, "R%dC%d_%s", row + 1, col + 1, portname.c_str(this));
1148+
addBelInput(belname, id_XXX_VSS1, id(buf));
1149+
}
1150+
} break;
11361151
// Simplified IO
11371152
case ID_IOBJS:
11381153
z++; /* fall-through*/

gowin/arch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ struct Arch : BaseArch<ArchRanges>
472472

473473
// XXX GW1N-9C DDR quirk
474474
bool ddr_has_extra_inputs = false;
475+
// XXX GW1NR-9 iobuf quirk
476+
bool gw1n9_quirk = false;
475477

476478
// Permissible combinations of modes in a single slice
477479
std::map<const IdString, IdString> dff_comp_mode;

gowin/constids.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,8 @@ X(IOBJS)
683683
X(TX)
684684
X(XXX_VSS)
685685
X(XXX_VCC)
686+
X(XXX_VSS0)
687+
X(XXX_VSS1)
686688
X(OBUF_TYPE)
687689
X(SBUF)
688690
X(DBUF)

gowin/pack.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,14 @@ static void pack_iologic(Context *ctx)
805805
ci->addInput(id_XXX_VCC);
806806
ci->connectPort(id_XXX_VCC, ctx->nets[ctx->id("$PACKER_VCC_NET")].get());
807807
}
808+
if (ctx->gw1n9_quirk && iob_bel != q0_dst->attrs.end()) {
809+
bool have_XXX_VSS0 =
810+
ctx->bels[ctx->getBelByNameStr(iob_bel->second.as_string())].pins.count(id_XXX_VSS0);
811+
if (have_XXX_VSS0) {
812+
q0_dst->disconnectPort(id_XXX_VSS0);
813+
q0_dst->connectPort(id_XXX_VSS0, ctx->nets[ctx->id("$PACKER_VCC_NET")].get());
814+
}
815+
}
808816
} break;
809817
default:
810818
break;
@@ -933,6 +941,7 @@ static void pack_io(Context *ctx)
933941
// what type to create
934942
IdString new_cell_type = id_IOB;
935943
std::string constr_bel_name = std::string("");
944+
bool have_xxx_port = false;
936945
// check whether the given IO is limited to simplified IO cells
937946
auto constr_bel = ci->attrs.find(id_BEL);
938947
if (constr_bel != ci->attrs.end()) {
@@ -946,6 +955,9 @@ static void pack_io(Context *ctx)
946955
BelId constr_bel = ctx->getBelByNameStr(constr_bel_name);
947956
if (constr_bel != BelId()) {
948957
new_cell_type = ctx->bels[constr_bel].type;
958+
if (ctx->gw1n9_quirk) {
959+
have_xxx_port = ctx->bels[constr_bel].pins.count(id_XXX_VSS0) != 0;
960+
}
949961
}
950962
}
951963

@@ -954,6 +966,13 @@ static void pack_io(Context *ctx)
954966
gwio_to_iob(ctx, ci, ice_cell.get(), packed_cells);
955967
new_cells.push_back(std::move(ice_cell));
956968
auto gwiob = new_cells.back().get();
969+
// XXX GW1NR-9 quirks
970+
if (have_xxx_port && ci->type != id_IBUF) {
971+
gwiob->addInput(id_XXX_VSS0);
972+
gwiob->connectPort(id_XXX_VSS0, ctx->nets[ctx->id("$PACKER_GND_NET")].get());
973+
gwiob->addInput(id_XXX_VSS1);
974+
gwiob->connectPort(id_XXX_VSS1, ctx->nets[ctx->id("$PACKER_GND_NET")].get());
975+
}
957976

958977
packed_cells.insert(ci->name);
959978
if (iob != nullptr) {

0 commit comments

Comments
 (0)