aboutsummaryrefslogtreecommitdiffstats
path: root/gowin/arch.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gowin/arch.cc')
-rw-r--r--gowin/arch.cc64
1 files changed, 63 insertions, 1 deletions
diff --git a/gowin/arch.cc b/gowin/arch.cc
index 6213124f..2c1e50b7 100644
--- a/gowin/arch.cc
+++ b/gowin/arch.cc
@@ -440,7 +440,9 @@ IdString Arch::wireToGlobal(int &row, int &col, const DatabasePOD *db, IdString
{
const std::string &wirename = wire.str(this);
char buf[32];
- if (wirename == "VCC" || wirename == "GND") {
+ if (wirename == "VCC" || wirename == "VSS") {
+ row = 0;
+ col = 0;
return wire;
}
if (!isdigit(wirename[1]) || !isdigit(wirename[2]) || !isdigit(wirename[3])) {
@@ -949,6 +951,13 @@ Arch::Arch(ArchArgs args) : args(args)
package_name.c_str(this), speed_id.c_str(this));
// setup db
+ // add global VCC and GND bels
+ addBel(id_GND, id_GND, Loc(0, 0, BelZ::gnd_0_z), true);
+ addWire(id_VSS, id_VSS, 0, 0);
+ addBelOutput(id_GND, id_G, id_VSS);
+ addBel(id_VCC, id_VCC, Loc(0, 0, BelZ::vcc_0_z), true);
+ addWire(id_VCC, id_VCC, 0, 0);
+ addBelOutput(id_VCC, id_V, id_VCC);
char buf[32];
// The reverse order of the enumeration simplifies the creation
// of MUX2_LUT8s: they need the existence of the wire on the right.
@@ -1000,6 +1009,44 @@ Arch::Arch(ArchArgs args) : args(args)
snprintf(buf, 32, "R%dC%d_%s", row + 1, col + 1, portname.c_str(this));
addBelInput(belname, id_GSRI, id(buf));
break;
+ case ID_OSC:
+ snprintf(buf, 32, "R%dC%d_OSC", row + 1, col + 1);
+ belname = id(buf);
+ addBel(belname, id_OSC, Loc(col, row, 0), false);
+ portname = IdString(pairLookup(bel->ports.get(), bel->num_ports, ID_OSCOUT)->src_id);
+ snprintf(buf, 32, "R%dC%d_%s", row + 1, col + 1, portname.c_str(this));
+ addBelOutput(belname, id_OSCOUT, id(buf));
+ break;
+ case ID_OSCH:
+ snprintf(buf, 32, "R%dC%d_OSCH", row + 1, col + 1);
+ belname = id(buf);
+ addBel(belname, id_OSCH, Loc(col, row, 0), false);
+ portname = IdString(pairLookup(bel->ports.get(), bel->num_ports, ID_OSCOUT)->src_id);
+ snprintf(buf, 32, "R%dC%d_%s", row + 1, col + 1, portname.c_str(this));
+ addBelOutput(belname, id_OSCOUT, id(buf));
+ break;
+ case ID_OSCF:
+ snprintf(buf, 32, "R%dC%d_OSCF", row + 1, col + 1);
+ belname = id(buf);
+ addBel(belname, id_OSCF, Loc(col, row, 0), false);
+ portname = IdString(pairLookup(bel->ports.get(), bel->num_ports, ID_OSCOUT)->src_id);
+ snprintf(buf, 32, "R%dC%d_%s", row + 1, col + 1, portname.c_str(this));
+ addBelOutput(belname, id_OSCOUT, id(buf));
+ portname = IdString(pairLookup(bel->ports.get(), bel->num_ports, ID_OSCEN)->src_id);
+ snprintf(buf, 32, "R%dC%d_%s", row + 1, col + 1, portname.c_str(this));
+ addBelInput(belname, id_OSCEN, id(buf));
+ break;
+ case ID_OSCZ:
+ snprintf(buf, 32, "R%dC%d_OSCZ", row + 1, col + 1);
+ belname = id(buf);
+ addBel(belname, id_OSCZ, Loc(col, row, 0), false);
+ portname = IdString(pairLookup(bel->ports.get(), bel->num_ports, ID_OSCOUT)->src_id);
+ snprintf(buf, 32, "R%dC%d_%s", row + 1, col + 1, portname.c_str(this));
+ addBelOutput(belname, id_OSCOUT, id(buf));
+ portname = IdString(pairLookup(bel->ports.get(), bel->num_ports, ID_OSCEN)->src_id);
+ snprintf(buf, 32, "R%dC%d_%s", row + 1, col + 1, portname.c_str(this));
+ addBelInput(belname, id_OSCEN, id(buf));
+ break;
// fall through the ++
case ID_LUT7:
z++;
@@ -1149,6 +1196,21 @@ Arch::Arch(ArchArgs args) : args(args)
snprintf(buf, 32, "R%dC%d_%s", row + 1, col + 1, portname.c_str(this));
addBelInput(belname, id_CLK, id(buf));
+ const PairPOD *xxx_port = pairLookup(bel->ports.get(), bel->num_ports, ID_XXX_VSS);
+ if (xxx_port != nullptr) {
+ ddr_has_extra_inputs = true;
+ portname = IdString(xxx_port->src_id);
+ snprintf(buf, 32, "R%dC%d_%s", row + 1, col + 1, portname.c_str(this));
+ addBelInput(belname, id_XXX_VSS, id(buf));
+ }
+ xxx_port = pairLookup(bel->ports.get(), bel->num_ports, ID_XXX_VCC);
+ if (xxx_port != nullptr) {
+ ddr_has_extra_inputs = true;
+ portname = IdString(xxx_port->src_id);
+ snprintf(buf, 32, "R%dC%d_%s", row + 1, col + 1, portname.c_str(this));
+ addBelInput(belname, id_XXX_VCC, id(buf));
+ }
+
if (oddrc) {
portname = IdString(pairLookup(bel->ports.get(), bel->num_ports, ID_CE)->src_id);
snprintf(buf, 32, "R%dC%d_%s", row + 1, col + 1, portname.c_str(this));