| 1 |
#include "design_utils.h" |
| 2 |
#include "log.h" |
| 3 |
#include "nextpnr.h" |
| 4 |
|
| 5 |
#define HIMBAECHEL_CONSTIDS "uarch/gowin/constids.inc" |
| 6 |
#include "himbaechel_constids.h" |
| 7 |
#include "himbaechel_helpers.h" |
| 8 |
|
| 9 |
#include "gowin.h" |
| 10 |
#include "gowin_utils.h" |
| 11 |
#include "pack.h" |
| 12 |
|
| 13 |
#include <cinttypes> |
| 14 |
|
| 15 |
NEXTPNR_NAMESPACE_BEGIN |
| 16 |
|
| 17 |
// =================================== |
| 18 |
// IO logic |
| 19 |
// =================================== |
| 20 |
// the functions of these two inputs are yet to be discovered, so we set as observed |
| 21 |
// in the exemplary images |
| 22 |
void GowinPacker::set_daaj_nets(CellInfo &ci, BelId bel) |
| 23 |
{ |
| 24 |
std::vector<IdString> pins = ctx->getBelPins(bel); |
| 25 |
if (std::find(pins.begin(), pins.end(), id_DAADJ0) != pins.end()) { |
| 26 |
ci.addInput(id_DAADJ0); |
| 27 |
ci.connectPort(id_DAADJ0, ctx->nets.at(ctx->id("$PACKER_GND")).get()); |
| 28 |
} |
| 29 |
if (std::find(pins.begin(), pins.end(), id_DAADJ1) != pins.end()) { |
| 30 |
ci.addInput(id_DAADJ1); |
| 31 |
ci.connectPort(id_DAADJ1, ctx->nets.at(ctx->id("$PACKER_VCC")).get()); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
BelId GowinPacker::get_iologico_bel(CellInfo *iob) |
| 36 |
{ |
| 37 |
NPNR_ASSERT(iob->bel != BelId()); |
| 38 |
Loc loc = ctx->getBelLocation(iob->bel); |
| 39 |
loc.z = loc.z - BelZ::IOBA_Z + BelZ::IOLOGICA_Z; |
| 40 |
BelId bel = ctx->getBelByLocation(loc); |
| 41 |
if (bel != BelId()) { |
| 42 |
if (ctx->getBelType(bel) == id_IOLOGICO) { |
| 43 |
return bel; |
| 44 |
} |
| 45 |
} |
| 46 |
return BelId(); |
| 47 |
} |
| 48 |
|
| 49 |
BelId GowinPacker::get_iologici_bel(CellInfo *iob) |
| 50 |
{ |
| 51 |
NPNR_ASSERT(iob->bel != BelId()); |
| 52 |
Loc loc = ctx->getBelLocation(iob->bel); |
| 53 |
loc.z = loc.z - BelZ::IOBA_Z + BelZ::IOLOGICA_Z + 2; |
| 54 |
BelId bel = ctx->getBelByLocation(loc); |
| 55 |
if (bel != BelId()) { |
| 56 |
if (ctx->getBelType(bel) == id_IOLOGICI) { |
| 57 |
return bel; |
| 58 |
} |
| 59 |
} |
| 60 |
return BelId(); |
| 61 |
} |
| 62 |
|
| 63 |
void GowinPacker::check_iologic_placement(CellInfo &ci, Loc iob_loc, int diff /* 1 - diff */) |
| 64 |
{ |
| 65 |
if (ci.type.in(id_ODDR, id_ODDRC, id_IDDR, id_IDDRC, id_OSER4, id_IOLOGICI_EMPTY, id_IOLOGICO_EMPTY) || diff) { |
| 66 |
return; |
| 67 |
} |
| 68 |
BelId l_bel = ctx->getBelByLocation(Loc(iob_loc.x, iob_loc.y, BelZ::IOBA_Z + 1 - (iob_loc.z - BelZ::IOBA_Z))); |
| 69 |
if (!ctx->checkBelAvail(l_bel)) { |
| 70 |
log_error("Can't place %s at %s because it's already taken by %s\n", ctx->nameOf(&ci), ctx->nameOfBel(l_bel), |
| 71 |
ctx->nameOf(ctx->getBoundBelCell(l_bel))); |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
// While we require an exact match of the type, in the future the criteria |
| 76 |
// may be relaxed and there will be a comparison of the control networks |
| 77 |
// used. |
| 78 |
bool are_iologic_compatible(CellInfo *ci_0, CellInfo *ci_1) |
| 79 |
{ |
| 80 |
switch (ci_0->type.hash()) { |
| 81 |
case ID_ODDR: |
| 82 |
return ci_1->type == id_IDDR; |
| 83 |
case ID_ODDRC: |
| 84 |
return ci_1->type == id_IDDRC; |
| 85 |
case ID_IDDR: |
| 86 |
return ci_1->type == id_ODDR; |
| 87 |
case ID_IDDRC: |
| 88 |
return ci_1->type == id_ODDRC; |
| 89 |
default: |
| 90 |
return false; |
| 91 |
} |
| 92 |
return false; |
| 93 |
} |
| 94 |
|
| 95 |
void GowinPacker::pack_bi_output_iol(CellInfo &ci, std::vector<IdString> &nets_to_remove) |
| 96 |
{ |
| 97 |
// These primitives have an additional pin to control the tri-state iob - Q1. |
| 98 |
IdString out_port = id_Q0; |
| 99 |
IdString tx_port = id_Q1; |
| 100 |
|
| 101 |
CellInfo *out_iob = net_only_drives(ctx, ci.ports.at(out_port).net, is_iob, id_I, true); |
| 102 |
NPNR_ASSERT(out_iob != nullptr && out_iob->bel != BelId()); |
| 103 |
BelId iob_bel = out_iob->bel; |
| 104 |
|
| 105 |
BelId l_bel = get_iologico_bel(out_iob); |
| 106 |
// check compatible Input and Output iologic if any |
| 107 |
BelId in_l_bel = get_iologici_bel(out_iob); |
| 108 |
if (in_l_bel != BelId() && !ctx->checkBelAvail(in_l_bel)) { |
| 109 |
CellInfo *in_iologic_ci = ctx->getBoundBelCell(in_l_bel); |
| 110 |
if (!are_iologic_compatible(&ci, in_iologic_ci)) { |
| 111 |
log_error("IOLOGIC %s at %s cannot coexist with %s\n", ctx->nameOf(&ci), ctx->nameOfBel(iob_bel), |
| 112 |
ctx->nameOf(in_iologic_ci)); |
| 113 |
} |
| 114 |
} |
| 115 |
if (l_bel == BelId()) { |
| 116 |
log_error("Can't place IOLOGIC %s at %s\n", ctx->nameOf(&ci), ctx->nameOfBel(iob_bel)); |
| 117 |
} |
| 118 |
// mark IOB as used by IOLOGIC |
| 119 |
out_iob->setParam(id_IOLOGIC_IOB, 1); |
| 120 |
check_iologic_placement(ci, ctx->getBelLocation(iob_bel), |
| 121 |
out_iob->params.count(id_DIFF_TYPE) || out_iob->params.count(id_MIPI_OBUF)); |
| 122 |
|
| 123 |
if (!ctx->checkBelAvail(l_bel)) { |
| 124 |
log_error("Can't place %s at %s because it's already taken by %s\n", ctx->nameOf(&ci), ctx->nameOfBel(l_bel), |
| 125 |
ctx->nameOf(ctx->getBoundBelCell(l_bel))); |
| 126 |
} |
| 127 |
ctx->bindBel(l_bel, &ci, PlaceStrength::STRENGTH_LOCKED); |
| 128 |
std::string out_mode; |
| 129 |
switch (ci.type.hash()) { |
| 130 |
case ID_ODDR: |
| 131 |
case ID_ODDRC: |
| 132 |
out_mode = "ODDRX1"; |
| 133 |
break; |
| 134 |
case ID_OSER4: |
| 135 |
out_mode = "ODDRX2"; |
| 136 |
break; |
| 137 |
case ID_OSER8: |
| 138 |
out_mode = "ODDRX4"; |
| 139 |
break; |
| 140 |
} |
| 141 |
ci.setParam(ctx->id("OUTMODE"), out_mode); |
| 142 |
|
| 143 |
// disconnect Q output: it is wired internally |
| 144 |
nets_to_remove.push_back(ci.getPort(out_port)->name); |
| 145 |
out_iob->disconnectPort(id_I); |
| 146 |
ci.disconnectPort(out_port); |
| 147 |
set_daaj_nets(ci, iob_bel); |
| 148 |
|
| 149 |
Loc io_loc = ctx->getBelLocation(iob_bel); |
| 150 |
if (io_loc.y == ctx->getGridDimY() - 1) { |
| 151 |
config_bottom_row(*out_iob, io_loc, Bottom_io_POD::DDR); |
| 152 |
} |
| 153 |
|
| 154 |
// if Q1 is connected then disconnect it too |
| 155 |
if (gwu.port_used(&ci, tx_port)) { |
| 156 |
NPNR_ASSERT(out_iob == net_only_drives(ctx, ci.ports.at(tx_port).net, is_iob, id_OEN, true)); |
| 157 |
nets_to_remove.push_back(ci.getPort(tx_port)->name); |
| 158 |
out_iob->disconnectPort(id_OEN); |
| 159 |
ci.disconnectPort(tx_port); |
| 160 |
} else { // disconnect TXx ports, ignore these nets |
| 161 |
switch (ci.type.hash()) { |
| 162 |
case ID_OSER8: |
| 163 |
ci.disconnectPort(id_TX3); |
| 164 |
ci.disconnectPort(id_TX2); /* fall-through */ |
| 165 |
case ID_OSER4: |
| 166 |
ci.disconnectPort(id_TX1); |
| 167 |
ci.disconnectPort(id_TX0); |
| 168 |
break; |
| 169 |
case ID_ODDR: /* fall-through */ |
| 170 |
case ID_ODDRC: /* fall-through */ |
| 171 |
ci.disconnectPort(id_TX); |
| 172 |
break; |
| 173 |
} |
| 174 |
} |
| 175 |
make_iob_nets(*out_iob); |
| 176 |
} |
| 177 |
|
| 178 |
void GowinPacker::pack_single_output_iol(CellInfo &ci, std::vector<IdString> &nets_to_remove) |
| 179 |
{ |
| 180 |
IdString out_port = id_Q; |
| 181 |
|
| 182 |
CellInfo *out_iob = net_only_drives(ctx, ci.ports.at(out_port).net, is_iob, id_I, true); |
| 183 |
NPNR_ASSERT(out_iob != nullptr && out_iob->bel != BelId()); |
| 184 |
BelId iob_bel = out_iob->bel; |
| 185 |
|
| 186 |
BelId l_bel = get_iologico_bel(out_iob); |
| 187 |
if (l_bel == BelId()) { |
| 188 |
log_error("Can't place IOLOGIC %s at %s\n", ctx->nameOf(&ci), ctx->nameOfBel(iob_bel)); |
| 189 |
} |
| 190 |
// mark IOB as used by IOLOGIC |
| 191 |
out_iob->setParam(id_IOLOGIC_IOB, 1); |
| 192 |
check_iologic_placement(ci, ctx->getBelLocation(iob_bel), |
| 193 |
out_iob->params.count(id_DIFF_TYPE) || out_iob->params.count(id_MIPI_OBUF)); |
| 194 |
|
| 195 |
if (!ctx->checkBelAvail(l_bel)) { |
| 196 |
log_error("Can't place %s at %s because it's already taken by %s\n", ctx->nameOf(&ci), ctx->nameOfBel(l_bel), |
| 197 |
ctx->nameOf(ctx->getBoundBelCell(l_bel))); |
| 198 |
} |
| 199 |
ctx->bindBel(l_bel, &ci, PlaceStrength::STRENGTH_LOCKED); |
| 200 |
std::string out_mode; |
| 201 |
switch (ci.type.hash()) { |
| 202 |
case ID_IOLOGICO_EMPTY: |
| 203 |
out_mode = "EMPTY"; |
| 204 |
break; |
| 205 |
case ID_OVIDEO: |
| 206 |
out_mode = "VIDEORX"; |
| 207 |
break; |
| 208 |
case ID_OSER10: |
| 209 |
out_mode = "ODDRX5"; |
| 210 |
break; |
| 211 |
} |
| 212 |
ci.setParam(ctx->id("OUTMODE"), out_mode); |
| 213 |
// disconnect Q output: it is wired internally |
| 214 |
nets_to_remove.push_back(ci.getPort(out_port)->name); |
| 215 |
out_iob->disconnectPort(id_I); |
| 216 |
ci.disconnectPort(out_port); |
| 217 |
if (ci.type == id_IOLOGICO_EMPTY) { |
| 218 |
if (ci.attrs.count(id_HAS_REG) == 0) { |
| 219 |
ci.movePortTo(id_D, out_iob, id_I); |
| 220 |
} |
| 221 |
return; |
| 222 |
} |
| 223 |
set_daaj_nets(ci, iob_bel); |
| 224 |
|
| 225 |
Loc io_loc = ctx->getBelLocation(iob_bel); |
| 226 |
if (io_loc.y == ctx->getGridDimY() - 1) { |
| 227 |
config_bottom_row(*out_iob, io_loc, Bottom_io_POD::DDR); |
| 228 |
} |
| 229 |
make_iob_nets(*out_iob); |
| 230 |
} |
| 231 |
|
| 232 |
BelId GowinPacker::get_aux_iologic_bel(const CellInfo &ci) |
| 233 |
{ |
| 234 |
return ctx->getBelByLocation(gwu.get_pair_iologic_bel(ctx->getBelLocation(ci.bel))); |
| 235 |
} |
| 236 |
|
| 237 |
bool GowinPacker::is_diff_io(BelId bel) { return ctx->getBoundBelCell(bel)->params.count(id_DIFF_TYPE) != 0; } |
| 238 |
bool GowinPacker::is_mipi_io(BelId bel) |
| 239 |
{ |
| 240 |
return ctx->getBoundBelCell(bel)->params.count(id_MIPI_IBUF) || |
| 241 |
ctx->getBoundBelCell(bel)->params.count(id_MIPI_OBUF); |
| 242 |
} |
| 243 |
|
| 244 |
CellInfo *GowinPacker::create_aux_iologic_cell(CellInfo &ci, IdString mode, bool io16, int idx) |
| 245 |
{ |
| 246 |
if (ci.type.in(id_ODDR, id_ODDRC, id_OSER4, id_IDDR, id_IDDRC, id_IDES4, id_IOLOGICI_EMPTY, id_IOLOGICO_EMPTY)) { |
| 247 |
return nullptr; |
| 248 |
} |
| 249 |
IdString aux_name = gwu.create_aux_name(ci.name, idx); |
| 250 |
BelId bel = get_aux_iologic_bel(ci); |
| 251 |
BelId io_bel = gwu.get_io_bel_from_iologic(bel); |
| 252 |
if (!ctx->checkBelAvail(io_bel)) { |
| 253 |
if (!(is_diff_io(io_bel) || is_mipi_io(io_bel))) { |
| 254 |
log_error("Can't place %s at %s because of a conflict with another IO %s\n", ctx->nameOf(&ci), |
| 255 |
ctx->nameOfBel(bel), ctx->nameOf(ctx->getBoundBelCell(io_bel))); |
| 256 |
} |
| 257 |
} |
| 258 |
|
| 259 |
ctx->createCell(aux_name, id_IOLOGIC_DUMMY); |
| 260 |
CellInfo *aux = ctx->cells.at(aux_name).get(); |
| 261 |
ci.copyPortTo(id_PCLK, aux, id_PCLK); |
| 262 |
ci.copyPortTo(id_RESET, aux, id_RESET); |
| 263 |
if (io16) { |
| 264 |
aux->setParam(mode, Property("DDRENABLE16")); |
| 265 |
} else { |
| 266 |
aux->setParam(mode, Property("DDRENABLE")); |
| 267 |
} |
| 268 |
aux->setAttr(ctx->id("IOLOGIC_TYPE"), Property("DUMMY")); |
| 269 |
aux->setAttr(ctx->id("MAIN_CELL"), Property(ci.name.str(ctx))); |
| 270 |
ctx->bindBel(bel, aux, PlaceStrength::STRENGTH_LOCKED); |
| 271 |
return aux; |
| 272 |
} |
| 273 |
|
| 274 |
void GowinPacker::reconnect_ides_outs(CellInfo *ci) |
| 275 |
{ |
| 276 |
IdString dest_ports[] = {id_Q9, id_Q8, id_Q7, id_Q6, id_Q5, id_Q4, id_Q3, id_Q2}; |
| 277 |
switch (ci->type.hash()) { |
| 278 |
case ID_IDDR: /* fall-through*/ |
| 279 |
case ID_IDDRC: |
| 280 |
ci->renamePort(id_Q1, id_Q9); |
| 281 |
ci->renamePort(id_Q0, id_Q8); |
| 282 |
break; |
| 283 |
case ID_IDES4: |
| 284 |
for (int i = 0; i < 4; ++i) { |
| 285 |
ci->renamePort(ctx->idf("Q%d", 3 - i), dest_ports[i]); |
| 286 |
} |
| 287 |
break; |
| 288 |
case ID_IVIDEO: |
| 289 |
for (int i = 0; i < 7; ++i) { |
| 290 |
ci->renamePort(ctx->idf("Q%d", 6 - i), dest_ports[i]); |
| 291 |
} |
| 292 |
break; |
| 293 |
case ID_IDES8: |
| 294 |
for (int i = 0; i < 8; ++i) { |
| 295 |
ci->renamePort(ctx->idf("Q%d", 7 - i), dest_ports[i]); |
| 296 |
} |
| 297 |
break; |
| 298 |
default: |
| 299 |
break; |
| 300 |
} |
| 301 |
} |
| 302 |
|
| 303 |
void GowinPacker::pack_ides_iol(CellInfo &ci, std::vector<IdString> &nets_to_remove) |
| 304 |
{ |
| 305 |
IdString in_port = id_D; |
| 306 |
|
| 307 |
CellInfo *in_iob = net_driven_by(ctx, ci.ports.at(in_port).net, is_iob, id_O); |
| 308 |
NPNR_ASSERT(in_iob != nullptr && in_iob->bel != BelId()); |
| 309 |
BelId iob_bel = in_iob->bel; |
| 310 |
|
| 311 |
BelId l_bel = get_iologici_bel(in_iob); |
| 312 |
if (l_bel == BelId()) { |
| 313 |
log_error("Can't place IOLOGIC %s at %s\n", ctx->nameOf(&ci), ctx->nameOfBel(iob_bel)); |
| 314 |
} |
| 315 |
// mark IOB as used by IOLOGIC |
| 316 |
in_iob->setParam(id_IOLOGIC_IOB, 1); |
| 317 |
check_iologic_placement(ci, ctx->getBelLocation(iob_bel), |
| 318 |
in_iob->params.count(id_DIFF_TYPE) || in_iob->params.count(id_MIPI_IBUF)); |
| 319 |
|
| 320 |
if (!ctx->checkBelAvail(l_bel)) { |
| 321 |
log_error("Can't place %s at %s because it's already taken by %s\n", ctx->nameOf(&ci), ctx->nameOfBel(l_bel), |
| 322 |
ctx->nameOf(ctx->getBoundBelCell(l_bel))); |
| 323 |
} |
| 324 |
ctx->bindBel(l_bel, &ci, PlaceStrength::STRENGTH_LOCKED); |
| 325 |
std::string in_mode; |
| 326 |
switch (ci.type.hash()) { |
| 327 |
case ID_IOLOGICI_EMPTY: |
| 328 |
in_mode = "EMPTY"; |
| 329 |
break; |
| 330 |
case ID_IDDR: |
| 331 |
case ID_IDDRC: |
| 332 |
in_mode = "IDDRX1"; |
| 333 |
break; |
| 334 |
case ID_IDES4: |
| 335 |
in_mode = "IDDRX2"; |
| 336 |
break; |
| 337 |
case ID_IDES8: |
| 338 |
in_mode = "IDDRX4"; |
| 339 |
break; |
| 340 |
case ID_IDES10: |
| 341 |
in_mode = "IDDRX5"; |
| 342 |
break; |
| 343 |
case ID_IVIDEO: |
| 344 |
in_mode = "VIDEORX"; |
| 345 |
break; |
| 346 |
} |
| 347 |
ci.setParam(ctx->id("INMODE"), in_mode); |
| 348 |
// disconnect D input: it is wired internally |
| 349 |
nets_to_remove.push_back(ci.getPort(in_port)->name); |
| 350 |
in_iob->disconnectPort(id_O); |
| 351 |
ci.disconnectPort(in_port); |
| 352 |
if (ci.type == id_IOLOGICI_EMPTY) { |
| 353 |
if (ci.attrs.count(id_HAS_REG) == 0) { |
| 354 |
ci.movePortTo(id_Q, in_iob, id_O); |
| 355 |
} |
| 356 |
return; |
| 357 |
} |
| 358 |
|
| 359 |
set_daaj_nets(ci, iob_bel); |
| 360 |
reconnect_ides_outs(&ci); |
| 361 |
|
| 362 |
make_iob_nets(*in_iob); |
| 363 |
} |
| 364 |
|
| 365 |
void GowinPacker::pack_iem(void) |
| 366 |
{ |
| 367 |
log_info("Pack Input Edge Monitors...\n"); |
| 368 |
std::vector<IdString> cells_to_remove; |
| 369 |
std::vector<std::unique_ptr<CellInfo>> new_cells; |
| 370 |
|
| 371 |
for (auto &cell : ctx->cells) { |
| 372 |
CellInfo &ci = *cell.second; |
| 373 |
if (ci.type != id_IEM) { |
| 374 |
continue; |
| 375 |
} |
| 376 |
if (ctx->debug) { |
| 377 |
log_info("pack %s of type %s.\n", ctx->nameOf(&ci), ci.type.c_str(ctx)); |
| 378 |
} |
| 379 |
// IEM is part of IOLOGIC but functions independently of the |
| 380 |
// presence/absence of other IOLOGIC components. Therefore, we use |
| 381 |
// the existing cell whenever possible. |
| 382 |
const NetInfo *d_net = ci.ports.at(id_D).net; |
| 383 |
CellInfo *in_iob = net_driven_by(ctx, d_net, is_iob, id_O); |
| 384 |
NPNR_ASSERT(in_iob != nullptr && in_iob->bel != BelId()); |
| 385 |
BelId iob_bel = in_iob->bel; |
| 386 |
|
| 387 |
BelId l_bel = get_iologici_bel(in_iob); |
| 388 |
if (l_bel == BelId()) { |
| 389 |
log_error("Can't place IOLOGIC %s at %s\n", ctx->nameOf(&ci), ctx->nameOfBel(iob_bel)); |
| 390 |
} |
| 391 |
CellInfo *iologic = nullptr; |
| 392 |
for (auto &usr : d_net->users) { |
| 393 |
if (is_iologici(usr.cell)) { |
| 394 |
if (ctx->debug) { |
| 395 |
log_info(" found IOLOGIC cell %s of type %s, use it.\n", ctx->nameOf(usr.cell), |
| 396 |
usr.cell->type.c_str(ctx)); |
| 397 |
} |
| 398 |
iologic = usr.cell; |
| 399 |
if (iologic->ports.count(id_CLK)) { |
| 400 |
NPNR_ASSERT(iologic->ports.at(id_CLK).net == ci.ports.at(id_CLK).net); |
| 401 |
} else { |
| 402 |
if (iologic->ports.count(id_PCLK)) { |
| 403 |
NPNR_ASSERT(iologic->ports.at(id_PCLK).net == ci.ports.at(id_CLK).net); |
| 404 |
} |
| 405 |
iologic->addInput(ctx->id("CLK")); |
| 406 |
} |
| 407 |
if (iologic->ports.count(id_RESET)) { |
| 408 |
NPNR_ASSERT(iologic->ports.at(id_RESET).net == ci.ports.at(id_RESET).net); |
| 409 |
} else { |
| 410 |
iologic->addInput(ctx->id("RESET")); |
| 411 |
} |
| 412 |
break; |
| 413 |
} |
| 414 |
} |
| 415 |
if (iologic == nullptr) { |
| 416 |
IdString iologic_name = gwu.create_aux_name(ci.name); |
| 417 |
if (ctx->debug) { |
| 418 |
log_info(" create IOLOGIC cell %s.\n", iologic_name.c_str(ctx)); |
| 419 |
} |
| 420 |
auto iologic_cell = gwu.create_cell(iologic_name, id_IOLOGICI_EMPTY); |
| 421 |
new_cells.push_back(std::move(iologic_cell)); |
| 422 |
iologic = new_cells.back().get(); |
| 423 |
ci.copyPortTo(id_D, iologic, id_D); |
| 424 |
ci.copyPortTo(id_CLK, iologic, id_CLK); |
| 425 |
ci.copyPortTo(id_RESET, iologic, id_RESET); |
| 426 |
} |
| 427 |
ci.movePortTo(id_MCLK, iologic, id_MCLK); |
| 428 |
ci.movePortTo(id_LAG, iologic, id_LAG); |
| 429 |
ci.movePortTo(id_LEAD, iologic, id_LEAD); |
| 430 |
|
| 431 |
ci.disconnectPort(id_D); |
| 432 |
ci.disconnectPort(id_CLK); |
| 433 |
ci.disconnectPort(id_RESET); |
| 434 |
|
| 435 |
// WINSIZE attribute defines routing to ports WINSIZE0/1 |
| 436 |
iologic->addInput(id_WINSIZE0); |
| 437 |
iologic->addInput(id_WINSIZE1); |
| 438 |
if (ci.params.count(id_WINSIZE) == 0) { |
| 439 |
ci.setParam(id_WINSIZE, Property("SMALL")); |
| 440 |
} |
| 441 |
|
| 442 |
NetInfo *vcc_net = ctx->nets.at(ctx->id("$PACKER_VCC")).get(); |
| 443 |
NetInfo *vss_net = ctx->nets.at(ctx->id("$PACKER_GND")).get(); |
| 444 |
IdString winsize = ctx->id(ci.params.at(id_WINSIZE).as_string()); |
| 445 |
switch (winsize.hash()) { |
| 446 |
case ID_SMALL: |
| 447 |
iologic->connectPort(id_WINSIZE0, vss_net); |
| 448 |
iologic->connectPort(id_WINSIZE1, vss_net); |
| 449 |
break; |
| 450 |
case ID_MIDSMALL: |
| 451 |
iologic->connectPort(id_WINSIZE0, vcc_net); |
| 452 |
iologic->connectPort(id_WINSIZE1, vss_net); |
| 453 |
break; |
| 454 |
case ID_MIDLARGE: |
| 455 |
iologic->connectPort(id_WINSIZE0, vss_net); |
| 456 |
iologic->connectPort(id_WINSIZE1, vcc_net); |
| 457 |
break; |
| 458 |
case ID_LARGE: |
| 459 |
iologic->connectPort(id_WINSIZE0, vcc_net); |
| 460 |
iologic->connectPort(id_WINSIZE1, vcc_net); |
| 461 |
break; |
| 462 |
default: |
| 463 |
log_error("%s has incorrect WINSIZE:%s\n", ctx->nameOf(&ci), ci.params.at(id_WINSIZE).c_str()); |
| 464 |
} |
| 465 |
|
| 466 |
if (ci.params.count(id_GSREN) != 0) { |
| 467 |
if (iologic->params.count(id_GSREN) == 0) { |
| 468 |
iologic->setParam(id_GSREN, ci.params.at(id_GSREN)); |
| 469 |
} else { |
| 470 |
if (ci.params.at(id_GSREN) != iologic->params.at(id_GSREN)) { |
| 471 |
log_error("GSREN parameter values of %s and %s do not match.\n", ctx->nameOf(&ci), |
| 472 |
ctx->nameOf(iologic)); |
| 473 |
} |
| 474 |
} |
| 475 |
} |
| 476 |
if (ci.params.count(id_LSREN) != 0) { |
| 477 |
if (iologic->params.count(id_LSREN) == 0) { |
| 478 |
iologic->setParam(id_LSREN, ci.params.at(id_LSREN)); |
| 479 |
} else { |
| 480 |
if (ci.params.at(id_LSREN) != iologic->params.at(id_LSREN)) { |
| 481 |
log_error("LSREN parameter values of %s and %s do not match.\n", ctx->nameOf(&ci), |
| 482 |
ctx->nameOf(iologic)); |
| 483 |
} |
| 484 |
} |
| 485 |
} |
| 486 |
cells_to_remove.push_back(ci.name); |
| 487 |
} |
| 488 |
|
| 489 |
for (auto cell : cells_to_remove) { |
| 490 |
ctx->cells.erase(cell); |
| 491 |
} |
| 492 |
|
| 493 |
for (auto &ncell : new_cells) { |
| 494 |
ctx->cells[ncell->name] = std::move(ncell); |
| 495 |
} |
| 496 |
} |
| 497 |
|
| 498 |
void GowinPacker::pack_iodelay(void) |
| 499 |
{ |
| 500 |
log_info("Pack IODELAY...\n"); |
| 501 |
std::vector<IdString> cells_to_remove; |
| 502 |
std::vector<IdString> nets_to_remove; |
| 503 |
std::vector<std::unique_ptr<CellInfo>> new_cells; |
| 504 |
|
| 505 |
for (auto &cell : ctx->cells) { |
| 506 |
CellInfo &ci = *cell.second; |
| 507 |
if (ci.type != id_IODELAY) { |
| 508 |
continue; |
| 509 |
} |
| 510 |
if (ctx->debug) { |
| 511 |
log_info("pack %s of type %s.\n", ctx->nameOf(&ci), ci.type.c_str(ctx)); |
| 512 |
} |
| 513 |
// There is only one delay line in the IO block, which can be either |
| 514 |
// input or output. Define which case we are dealing with. |
| 515 |
bool is_idelay = false; |
| 516 |
NetInfo *di_net = ci.ports.at(id_DI).net; |
| 517 |
NetInfo *do_net = ci.ports.at(id_DO).net; |
| 518 |
CellInfo *iob = net_driven_by(ctx, di_net, is_iob, id_O); |
| 519 |
if (iob != nullptr) { |
| 520 |
NPNR_ASSERT(iob->bel != BelId()); |
| 521 |
if (di_net->users.entries() != 1) { |
| 522 |
log_error("IODELAY %s should be the only sink in the %s network.\n", ctx->nameOf(&ci), |
| 523 |
ctx->nameOf(di_net)); |
| 524 |
} |
| 525 |
is_idelay = true; |
| 526 |
} else { |
| 527 |
iob = net_only_drives(ctx, do_net, is_iob, id_I, true); |
| 528 |
if (iob != nullptr) { |
| 529 |
NPNR_ASSERT(iob->bel != BelId()); |
| 530 |
} else { |
| 531 |
log_error("IODELAY %s is not connected to the pin.\n", ctx->nameOf(&ci)); |
| 532 |
} |
| 533 |
} |
| 534 |
|
| 535 |
BelId iob_bel = iob->bel; |
| 536 |
BelId l_bel = get_iologici_bel(iob); |
| 537 |
if (l_bel == BelId()) { |
| 538 |
log_error("Can't place IOLOGIC %s at %s\n", ctx->nameOf(&ci), ctx->nameOfBel(iob_bel)); |
| 539 |
} |
| 540 |
|
| 541 |
// find IOLOGIC connected or create dummy one |
| 542 |
CellInfo *iologic = nullptr; |
| 543 |
Property attr; |
| 544 |
IdString dummy_iol_type; |
| 545 |
if (is_idelay) { |
| 546 |
attr = Property("IN"); |
| 547 |
dummy_iol_type = id_IOLOGICI_EMPTY; |
| 548 |
for (auto &usr : do_net->users) { |
| 549 |
if (is_iologici(usr.cell)) { |
| 550 |
iologic = usr.cell; |
| 551 |
if (iologic->attrs.count(id_IODELAY) != 0) { |
| 552 |
log_error("Only one IODELAY allowed per IO block %s.\n", ctx->nameOfBel(iob->bel)); |
| 553 |
} |
| 554 |
if (ctx->debug) { |
| 555 |
log_info(" found IOLOGIC cell %s of type %s, use it.\n", ctx->nameOf(iologic), |
| 556 |
iologic->type.c_str(ctx)); |
| 557 |
} |
| 558 |
} |
| 559 |
} |
| 560 |
} else { |
| 561 |
attr = Property("OUT"); |
| 562 |
dummy_iol_type = id_IOLOGICO_EMPTY; |
| 563 |
if (is_iologico(di_net->driver.cell)) { |
| 564 |
iologic = di_net->driver.cell; |
| 565 |
if (iologic->attrs.count(id_IODELAY) != 0) { |
| 566 |
log_error("Only one IODELAY allowed per IO block %s.\n", ctx->nameOfBel(iob->bel)); |
| 567 |
} |
| 568 |
if (ctx->debug) { |
| 569 |
log_info(" found IOLOGIC cell %s of type %s, use it.\n", ctx->nameOf(iologic), |
| 570 |
iologic->type.c_str(ctx)); |
| 571 |
} |
| 572 |
} |
| 573 |
} |
| 574 |
|
| 575 |
if (iologic == nullptr) { |
| 576 |
IdString iologic_name = gwu.create_aux_name(ci.name); |
| 577 |
if (ctx->debug) { |
| 578 |
log_info(" create IOLOGIC cell %s.\n", iologic_name.c_str(ctx)); |
| 579 |
} |
| 580 |
auto iologic_cell = gwu.create_cell(iologic_name, dummy_iol_type); |
| 581 |
new_cells.push_back(std::move(iologic_cell)); |
| 582 |
iologic = new_cells.back().get(); |
| 583 |
iologic->addInput(id_D); |
| 584 |
iologic->addOutput(id_Q); |
| 585 |
ci.movePortTo(id_DI, iologic, id_D); |
| 586 |
ci.movePortTo(id_DO, iologic, id_Q); |
| 587 |
} else { |
| 588 |
if (is_idelay) { |
| 589 |
iob->disconnectPort(id_O); |
| 590 |
ci.disconnectPort(id_I); |
| 591 |
ci.movePortTo(id_DO, iob, id_O); |
| 592 |
} else { |
| 593 |
IdString iol_out = di_net->driver.port; |
| 594 |
ci.disconnectPort(id_DI); |
| 595 |
iologic->disconnectPort(iol_out); |
| 596 |
ci.movePortTo(id_DO, iologic, iol_out); |
| 597 |
} |
| 598 |
nets_to_remove.push_back(di_net->name); |
| 599 |
} |
| 600 |
|
| 601 |
ci.movePortTo(id_SDTAP, iologic, id_SDTAP); |
| 602 |
ci.movePortTo(id_SETN, iologic, id_SETN); |
| 603 |
ci.movePortTo(id_VALUE, iologic, id_VALUE); |
| 604 |
ci.movePortTo(id_DF, iologic, id_DF); |
| 605 |
|
| 606 |
if (ci.params.count(id_C_STATIC_DLY)) { |
| 607 |
iologic->setParam(id_C_STATIC_DLY, ci.params.at(id_C_STATIC_DLY)); |
| 608 |
} |
| 609 |
iologic->setAttr(id_IODELAY, attr); |
| 610 |
cells_to_remove.push_back(ci.name); |
| 611 |
} |
| 612 |
for (auto cell : cells_to_remove) { |
| 613 |
ctx->cells.erase(cell); |
| 614 |
} |
| 615 |
|
| 616 |
for (auto &ncell : new_cells) { |
| 617 |
ctx->cells[ncell->name] = std::move(ncell); |
| 618 |
} |
| 619 |
|
| 620 |
for (auto net : nets_to_remove) { |
| 621 |
ctx->nets.erase(net); |
| 622 |
} |
| 623 |
} |
| 624 |
|
| 625 |
void GowinPacker::pack_iologic(void) |
| 626 |
{ |
| 627 |
log_info("Pack IO logic...\n"); |
| 628 |
std::vector<IdString> nets_to_remove; |
| 629 |
|
| 630 |
for (auto &cell : ctx->cells) { |
| 631 |
CellInfo &ci = *cell.second; |
| 632 |
if (!(is_iologici(&ci) || is_iologico(&ci))) { |
| 633 |
continue; |
| 634 |
} |
| 635 |
if (ctx->debug) { |
| 636 |
log_info("pack %s of type %s.\n", ctx->nameOf(&ci), ci.type.c_str(ctx)); |
| 637 |
} |
| 638 |
if (ci.type.in(id_ODDR, id_ODDRC, id_OSER4, id_OSER8)) { |
| 639 |
pack_bi_output_iol(ci, nets_to_remove); |
| 640 |
create_aux_iologic_cell(ci, ctx->id("OUTMODE")); |
| 641 |
continue; |
| 642 |
} |
| 643 |
if (ci.type.in(id_OVIDEO, id_OSER10, id_IOLOGICO_EMPTY)) { |
| 644 |
pack_single_output_iol(ci, nets_to_remove); |
| 645 |
create_aux_iologic_cell(ci, ctx->id("OUTMODE")); |
| 646 |
continue; |
| 647 |
} |
| 648 |
if (ci.type.in(id_IDDR, id_IDDRC, id_IDES4, id_IDES8, id_IDES10, id_IVIDEO, id_IOLOGICI_EMPTY)) { |
| 649 |
pack_ides_iol(ci, nets_to_remove); |
| 650 |
create_aux_iologic_cell(ci, ctx->id("INMODE")); |
| 651 |
continue; |
| 652 |
} |
| 653 |
} |
| 654 |
|
| 655 |
for (auto net : nets_to_remove) { |
| 656 |
ctx->nets.erase(net); |
| 657 |
} |
| 658 |
} |
| 659 |
|
| 660 |
// =================================== |
| 661 |
// IDES16 / OSER16 |
| 662 |
// =================================== |
| 663 |
void GowinPacker::check_io16_placement(CellInfo &ci, Loc main_loc, Loc aux_off, int diff /* 1 - diff */) |
| 664 |
{ |
| 665 |
if (main_loc.z != BelZ::IOBA_Z) { |
| 666 |
log_error("Can't place %s at %s because OSER16/IDES16 must be placed at A pin\n", ctx->nameOf(&ci), |
| 667 |
ctx->nameOfBel(ctx->getBelByLocation(main_loc))); |
| 668 |
} |
| 669 |
|
| 670 |
int mod[][3] = {{0, 0, 1}, {1, 1, 0}, {1, 1, 1}}; |
| 671 |
for (int i = diff; i < 3; ++i) { |
| 672 |
Loc aux_loc(main_loc.x + mod[i][0] * aux_off.x, main_loc.y + mod[i][1] * aux_off.y, main_loc.z + mod[i][2]); |
| 673 |
BelId l_bel = ctx->getBelByLocation(aux_loc); |
| 674 |
if (!ctx->checkBelAvail(l_bel)) { |
| 675 |
log_error("Can't place %s at %s because it's already taken by %s\n", ctx->nameOf(&ci), |
| 676 |
ctx->nameOfBel(l_bel), ctx->nameOf(ctx->getBoundBelCell(l_bel))); |
| 677 |
} |
| 678 |
} |
| 679 |
} |
| 680 |
|
| 681 |
void GowinPacker::pack_oser16(CellInfo &ci, std::vector<IdString> &nets_to_remove) |
| 682 |
{ |
| 683 |
IdString out_port = id_Q; |
| 684 |
|
| 685 |
CellInfo *out_iob = net_only_drives(ctx, ci.ports.at(out_port).net, is_iob, id_I, true); |
| 686 |
NPNR_ASSERT(out_iob != nullptr && out_iob->bel != BelId()); |
| 687 |
// mark IOB as used by IOLOGIC |
| 688 |
out_iob->setParam(id_IOLOGIC_IOB, 1); |
| 689 |
|
| 690 |
BelId iob_bel = out_iob->bel; |
| 691 |
|
| 692 |
Loc iob_loc = ctx->getBelLocation(iob_bel); |
| 693 |
Loc aux_offset = gwu.get_tile_io16_offs(iob_loc.x, iob_loc.y); |
| 694 |
|
| 695 |
if (aux_offset.x == 0 && aux_offset.y == 0) { |
| 696 |
log_error("OSER16 %s can not be placed at %s\n", ctx->nameOf(&ci), ctx->nameOfBel(iob_bel)); |
| 697 |
} |
| 698 |
check_io16_placement(ci, iob_loc, aux_offset, out_iob->params.count(id_DIFF_TYPE)); |
| 699 |
|
| 700 |
BelId main_bel = ctx->getBelByLocation(Loc(iob_loc.x, iob_loc.y, BelZ::OSER16_Z)); |
| 701 |
ctx->bindBel(main_bel, &ci, PlaceStrength::STRENGTH_LOCKED); |
| 702 |
|
| 703 |
// disconnect Q output: it is wired internally |
| 704 |
nets_to_remove.push_back(ci.getPort(out_port)->name); |
| 705 |
out_iob->disconnectPort(id_I); |
| 706 |
ci.disconnectPort(out_port); |
| 707 |
|
| 708 |
// to simplify packaging, the parts of the OSER16 are presented as IOLOGIC cells |
| 709 |
// and one of these aux cells is declared as main |
| 710 |
IdString main_name = gwu.create_aux_name(ci.name); |
| 711 |
|
| 712 |
IdString aux_name = gwu.create_aux_name(ci.name, 1); |
| 713 |
ctx->createCell(aux_name, id_IOLOGIC_DUMMY); |
| 714 |
CellInfo *aux = ctx->cells.at(aux_name).get(); |
| 715 |
|
| 716 |
aux->setAttr(ctx->id("MAIN_CELL"), Property(main_name.str(ctx))); |
| 717 |
aux->setParam(ctx->id("OUTMODE"), Property("ODDRX8")); |
| 718 |
aux->setParam(ctx->id("UPDATE"), Property("SAME")); |
| 719 |
aux->setAttr(ctx->id("IOLOGIC_TYPE"), Property("DUMMY")); |
| 720 |
ci.copyPortTo(id_PCLK, aux, id_PCLK); |
| 721 |
ci.copyPortTo(id_RESET, aux, id_RESET); |
| 722 |
ctx->bindBel(ctx->getBelByLocation(Loc(iob_loc.x, iob_loc.y, BelZ::IOLOGICA_Z)), aux, |
| 723 |
PlaceStrength::STRENGTH_LOCKED); |
| 724 |
|
| 725 |
// make aux cell in the first cell |
| 726 |
aux = create_aux_iologic_cell(*aux, ctx->id("OUTMODE"), true, 2); |
| 727 |
aux->setAttr(ctx->id("MAIN_CELL"), Property(main_name.str(ctx))); |
| 728 |
aux->setParam(ctx->id("UPDATE"), Property("SAME")); |
| 729 |
|
| 730 |
// make cell in the next location |
| 731 |
ctx->createCell(main_name, id_IOLOGIC); |
| 732 |
aux = ctx->cells.at(main_name).get(); |
| 733 |
|
| 734 |
aux->setAttr(ctx->id("MAIN_CELL"), Property(main_name.str(ctx))); |
| 735 |
aux->setParam(ctx->id("OUTMODE"), Property("DDRENABLE16")); |
| 736 |
aux->setParam(ctx->id("UPDATE"), Property("SAME")); |
| 737 |
aux->setAttr(ctx->id("IOLOGIC_TYPE"), Property("DUMMY")); |
| 738 |
ci.copyPortTo(id_PCLK, aux, id_PCLK); |
| 739 |
ci.copyPortTo(id_RESET, aux, id_RESET); |
| 740 |
ci.movePortTo(id_FCLK, aux, id_FCLK); |
| 741 |
ci.movePortTo(id_D12, aux, id_D0); |
| 742 |
ci.movePortTo(id_D13, aux, id_D1); |
| 743 |
ci.movePortTo(id_D14, aux, id_D2); |
| 744 |
ci.movePortTo(id_D15, aux, id_D3); |
| 745 |
Loc next_io16(iob_loc.x + aux_offset.x, iob_loc.y + aux_offset.y, BelZ::IOLOGICA_Z); |
| 746 |
ctx->bindBel(ctx->getBelByLocation(next_io16), aux, PlaceStrength::STRENGTH_LOCKED); |
| 747 |
|
| 748 |
Loc io_loc = ctx->getBelLocation(iob_bel); |
| 749 |
if (io_loc.y == ctx->getGridDimY() - 1) { |
| 750 |
config_bottom_row(*out_iob, io_loc, Bottom_io_POD::DDR); |
| 751 |
} |
| 752 |
make_iob_nets(*out_iob); |
| 753 |
} |
| 754 |
|
| 755 |
void GowinPacker::pack_ides16(CellInfo &ci, std::vector<IdString> &nets_to_remove) |
| 756 |
{ |
| 757 |
IdString in_port = id_D; |
| 758 |
|
| 759 |
CellInfo *in_iob = net_driven_by(ctx, ci.ports.at(in_port).net, is_iob, id_O); |
| 760 |
NPNR_ASSERT(in_iob != nullptr && in_iob->bel != BelId()); |
| 761 |
// mark IOB as used by IOLOGIC |
| 762 |
in_iob->setParam(id_IOLOGIC_IOB, 1); |
| 763 |
|
| 764 |
BelId iob_bel = in_iob->bel; |
| 765 |
|
| 766 |
Loc iob_loc = ctx->getBelLocation(iob_bel); |
| 767 |
Loc aux_offset = gwu.get_tile_io16_offs(iob_loc.x, iob_loc.y); |
| 768 |
|
| 769 |
if (aux_offset.x == 0 && aux_offset.y == 0) { |
| 770 |
log_error("IDES16 %s can not be placed at %s\n", ctx->nameOf(&ci), ctx->nameOfBel(iob_bel)); |
| 771 |
} |
| 772 |
check_io16_placement(ci, iob_loc, aux_offset, in_iob->params.count(id_DIFF_TYPE)); |
| 773 |
|
| 774 |
BelId main_bel = ctx->getBelByLocation(Loc(iob_loc.x, iob_loc.y, BelZ::IDES16_Z)); |
| 775 |
ctx->bindBel(main_bel, &ci, PlaceStrength::STRENGTH_LOCKED); |
| 776 |
|
| 777 |
// disconnect Q output: it is wired internally |
| 778 |
nets_to_remove.push_back(ci.getPort(in_port)->name); |
| 779 |
in_iob->disconnectPort(id_O); |
| 780 |
ci.disconnectPort(in_port); |
| 781 |
|
| 782 |
// to simplify packaging, the parts of the IDES16 are presented as IOLOGIC cells |
| 783 |
// and one of these aux cells is declared as main |
| 784 |
IdString main_name = gwu.create_aux_name(ci.name); |
| 785 |
|
| 786 |
IdString aux_name = gwu.create_aux_name(ci.name, 1); |
| 787 |
ctx->createCell(aux_name, id_IOLOGIC_DUMMY); |
| 788 |
CellInfo *aux = ctx->cells.at(aux_name).get(); |
| 789 |
|
| 790 |
aux->setAttr(ctx->id("MAIN_CELL"), Property(main_name.str(ctx))); |
| 791 |
aux->setParam(ctx->id("INMODE"), Property("IDDRX8")); |
| 792 |
aux->setAttr(ctx->id("IOLOGIC_TYPE"), Property("DUMMY")); |
| 793 |
ci.copyPortTo(id_PCLK, aux, id_PCLK); |
| 794 |
ci.copyPortTo(id_RESET, aux, id_RESET); |
| 795 |
ctx->bindBel(ctx->getBelByLocation(Loc(iob_loc.x, iob_loc.y, BelZ::IOLOGICA_Z)), aux, |
| 796 |
PlaceStrength::STRENGTH_LOCKED); |
| 797 |
|
| 798 |
// make aux cell in the first cell |
| 799 |
aux = create_aux_iologic_cell(*aux, ctx->id("INMODE"), true, 2); |
| 800 |
aux->setAttr(ctx->id("MAIN_CELL"), Property(main_name.str(ctx))); |
| 801 |
ci.copyPortTo(id_CALIB, aux, id_CALIB); |
| 802 |
|
| 803 |
// make cell in the next location |
| 804 |
ctx->createCell(main_name, id_IOLOGIC); |
| 805 |
aux = ctx->cells.at(main_name).get(); |
| 806 |
|
| 807 |
aux->setAttr(ctx->id("MAIN_CELL"), Property(main_name.str(ctx))); |
| 808 |
aux->setParam(ctx->id("INMODE"), Property("DDRENABLE16")); |
| 809 |
aux->setAttr(ctx->id("IOLOGIC_TYPE"), Property("DUMMY")); |
| 810 |
ci.copyPortTo(id_PCLK, aux, id_PCLK); |
| 811 |
ci.copyPortTo(id_RESET, aux, id_RESET); |
| 812 |
ci.copyPortTo(id_CALIB, aux, id_CALIB); |
| 813 |
ci.movePortTo(id_FCLK, aux, id_FCLK); |
| 814 |
ci.movePortTo(id_Q0, aux, id_Q6); |
| 815 |
ci.movePortTo(id_Q1, aux, id_Q7); |
| 816 |
ci.movePortTo(id_Q2, aux, id_Q8); |
| 817 |
ci.movePortTo(id_Q3, aux, id_Q9); |
| 818 |
Loc next_io16(iob_loc.x + aux_offset.x, iob_loc.y + aux_offset.y, BelZ::IOLOGICA_Z); |
| 819 |
ctx->bindBel(ctx->getBelByLocation(next_io16), aux, PlaceStrength::STRENGTH_LOCKED); |
| 820 |
|
| 821 |
make_iob_nets(*in_iob); |
| 822 |
} |
| 823 |
|
| 824 |
void GowinPacker::pack_io16(void) |
| 825 |
{ |
| 826 |
std::vector<IdString> nets_to_remove; |
| 827 |
log_info("Pack DESER16 logic...\n"); |
| 828 |
|
| 829 |
for (auto &cell : ctx->cells) { |
| 830 |
CellInfo &ci = *cell.second; |
| 831 |
if (ci.type == id_OSER16) { |
| 832 |
if (ctx->debug) { |
| 833 |
log_info("pack %s of type %s.\n", ctx->nameOf(&ci), ci.type.c_str(ctx)); |
| 834 |
} |
| 835 |
pack_oser16(ci, nets_to_remove); |
| 836 |
continue; |
| 837 |
} |
| 838 |
if (ci.type == id_IDES16) { |
| 839 |
if (ctx->debug) { |
| 840 |
log_info("pack %s of type %s.\n", ctx->nameOf(&ci), ci.type.c_str(ctx)); |
| 841 |
} |
| 842 |
pack_ides16(ci, nets_to_remove); |
| 843 |
continue; |
| 844 |
} |
| 845 |
} |
| 846 |
for (auto net : nets_to_remove) { |
| 847 |
ctx->nets.erase(net); |
| 848 |
} |
| 849 |
} |
| 850 |
NEXTPNR_NAMESPACE_END |