Debian Codegraph @

himbaechel/uarch/ng-ultra/ng_ultra.cc

raw
1 /*
2 * nextpnr -- Next Generation Place and Route
3 *
4 * Copyright (C) 2024 The Project Beyond Authors.
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
18 */
19
20 #include <boost/algorithm/string.hpp>
21 #include <fstream>
22 #include <queue>
23
24 #include "design_utils.h"
25 #include "extra_data.h"
26 #include "himbaechel_api.h"
27 #include "log.h"
28 #include "nextpnr.h"
29 #include "placer_heap.h"
30 #include "util.h"
31
32 #include "himbaechel_helpers.h"
33
34 #include "location_map.h"
35 #include "ng_ultra.h"
36
37 #define GEN_INIT_CONSTIDS
38 #define HIMBAECHEL_CONSTIDS "uarch/ng-ultra/constids.inc"
39 #include "himbaechel_constids.h"
40 using namespace NEXTPNR_NAMESPACE_PREFIX ng_ultra;
41
42 NEXTPNR_NAMESPACE_BEGIN
43
44 NgUltraImpl::~NgUltraImpl() {};
45
46 po::options_description NgUltraImpl::getUArchOptions()
47 {
48 po::options_description specific("NG-Ultra specific options");
49 specific.add_options()("bit", po::value<std::string>(), "textual configuration bitstream output file");
50 specific.add_options()("csv", po::value<std::string>(), "name of constraints file");
51 specific.add_options()("no-xlut", "disable XLUT optimisations");
52 specific.add_options()("no-lut-chains", "disable LUT chains optimisations");
53 specific.add_options()("no-dff-chains", "disable DFF chains optimisations");
54 specific.add_options()("no-csc-insertion", "disable CSC insertion");
55 return specific;
56 }
57
58 void NgUltraImpl::init_database(Arch *arch)
59 {
60 init_uarch_constids(arch);
61 arch->load_chipdb("ng-ultra/chipdb-ng-ultra.bin");
62 arch->set_package("FF-1760");
63 arch->set_speed_grade("DEFAULT");
64 }
65
66 void NgUltraImpl::init(Context *ctx)
67 {
68 HimbaechelAPI::init(ctx);
69 for (int i = 1; i <= 8; i++)
70 for (int j = 0; j < 20; j++)
71 gck_per_lobe[i].push_back(GckConfig(BelId()));
72 for (auto bel : ctx->getBels()) {
73 if (ctx->getBelType(bel) == id_IOM) {
74 std::set<IdString> ckg;
75 IdString bank = tile_name_id(bel.tile);
76 iom_bels.emplace(bank, bel);
77 WireId belpin = ctx->getBelPinWire(bel, id_CKO1);
78 for (auto dh : ctx->getPipsDownhill(belpin)) {
79 WireId pip_dst = ctx->getPipDstWire(dh);
80 for (const auto &item : ctx->getWireBelPins(pip_dst)) {
81 if (boost::contains(ctx->nameOfBel(item.bel), "WFG_C")) {
82 unused_wfg[item.bel] = tile_name_id(item.bel.tile);
83 } else if (boost::contains(ctx->nameOfBel(item.bel), "PLL")) {
84 ckg.emplace(tile_name_id(item.bel.tile));
85 unused_pll[item.bel] = tile_name_id(item.bel.tile);
86 }
87 }
88 }
89 std::pair<IdString, IdString> p;
90 p.first = *ckg.begin();
91 if (ckg.size() == 2)
92 p.second = *(ckg.begin()++);
93 bank_to_ckg[bank] = p;
94 } else if (ctx->getBelType(bel) == id_IOTP) {
95 if (ctx->getBelName(bel)[1] == ctx->id("D08P_CLK.IOTP")) {
96 global_capable_bels.emplace(bel, id_P17RI);
97 } else if (ctx->getBelName(bel)[1] == ctx->id("D09P_CLK.IOTP")) {
98 global_capable_bels.emplace(bel, id_P19RI);
99 }
100 } else if (ctx->getBelType(bel) == id_GCK) {
101 std::string name = ctx->getBelName(bel)[1].c_str(ctx);
102 int lobe = std::stoi(name.substr(1, 1));
103 int num = std::stoi(name.substr(4, 2).c_str());
104 gck_per_lobe[lobe][num - 1] = GckConfig(bel);
105 }
106 locations.emplace(stringf("%s:%s", tile_name(bel.tile).c_str(), ctx->getBelName(bel)[1].c_str(ctx)), bel);
107 Loc loc = ctx->getBelLocation(bel);
108 tile_locations.emplace(tile_name(bel.tile).c_str(), Loc(loc.x & 0xfffe, loc.y & 0xfffe, 0));
109 }
110 for (auto bel : ctx->getBels()) {
111 if (ctx->getBelType(bel) == id_DSP) {
112 WireId cco = ctx->getBelPinWire(bel, id_CCO);
113 WireId cci;
114 for (auto dh : ctx->getPipsDownhill(cco)) {
115 cci = ctx->getPipDstWire(dh);
116 }
117 if (cci != WireId()) {
118 std::string loc = stringf("%s:%s", tile_name(cci.tile).c_str(), ctx->getWireName(cci)[1].c_str(ctx));
119 loc.erase(loc.find(".CCI"));
120 BelId dsp_bel = locations[loc];
121 dsp_cascade.emplace(dsp_bel, bel);
122 }
123 }
124 }
125 }
126
127 namespace {
128 // Note: These are per Cell type not Bel type
129 // Sinks
130 const dict<IdString, pool<IdString>> fabric_lowskew_sinks = {
131 // TILE - DFF
132 {id_BEYOND_FE, {id_CK, id_L, id_R}},
133 // { id_DFF, { id_CK }}, // This is part of BEYOND_FE
134 // TILE - Register file
135 {id_RF, {id_WCK}},
136 {id_RFSP, {id_WCK}},
137 {id_XHRF, {id_WCK1, id_WCK2}},
138 {id_XWRF, {id_WCK1, id_WCK2}},
139 {id_XPRF, {id_WCK1, id_WCK2}},
140 // TILE - CDC
141 {id_CDC, {id_CK1, id_CK2}},
142 {id_DDE, {id_CK1, id_CK2}},
143 {id_TDE, {id_CK1, id_CK2}},
144 {id_XCDC, {id_CK1, id_CK2}},
145 // TILE - FIFO
146 {id_FIFO, {id_RCK, id_WCK}},
147 {id_XHFIFO, {id_RCK1, id_RCK2, id_WCK1, id_WCK2}},
148 {id_XWFIFO, {id_RCK1, id_RCK2, id_WCK1, id_WCK2}},
149 // CGB - RAM
150 {id_RAM, {id_ACK, id_BCK}},
151 // CGB - DSP
152 {id_DSP, {id_CK}},
153 };
154
155 const dict<IdString, pool<IdString>> ring_clock_sinks = {
156 // CKG
157 {id_PLL, {id_CLK_CAL, id_FBK, id_REF}},
158 {id_WFB, {id_ZI}},
159 {id_WFG, {id_ZI}}};
160
161 const dict<IdString, pool<IdString>> ring_over_tile_clock_sinks = {
162 // IOB
163 {id_DFR, {id_CK}},
164 {id_DDFR, {id_CK, id_CKF}},
165 };
166 // IOB
167 // { id_IOM, { id_ALCK1, id_ALCK2, id_ALCK3, id_CCK, id_FCK1, id_FCK2, id_FDCK,
168 // id_LDSCK1, id_LDSCK2, id_LDSCK3, id_SWRX1CK, id_SWRX2CK }},
169
170 // HSSL
171 // { id_CRX, { id_LINK }},
172 // { id_CTX, { id_LINK }},
173 // { id_PMA, { id_hssl_clock_i1, id_hssl_clock_i2, id_hssl_clock_i3, id_hssl_clock_i4 },
174
175 const dict<IdString, pool<IdString>> tube_clock_sinks = {
176 // TUBE
177 {id_GCK, {id_SI1, id_SI2}},
178 };
179 // Sources
180 // CKG
181 const dict<IdString, pool<IdString>> ring_clock_source = {
182 {id_IOM, {id_CKO1, id_CKO2}},
183 {id_WFB, {id_ZO}},
184 {id_WFG, {id_ZO}},
185 {id_PLL,
186 {id_OSC, id_VCO, id_REFO, id_LDFO, id_CLK_DIV1, id_CLK_DIV2, id_CLK_DIV3, id_CLK_DIV4, id_CLK_DIVD1,
187 id_CLK_DIVD2, id_CLK_DIVD3, id_CLK_DIVD4, id_CLK_DIVD5, id_CLK_CAL_DIV}}};
188 // TUBE
189 const dict<IdString, pool<IdString>> tube_clock_source = {
190 {id_GCK, {id_SO}},
191 };
192
193 }; // namespace
194
195 const dict<IdString, pool<IdString>> &NgUltraImpl::get_fabric_lowskew_sinks() { return fabric_lowskew_sinks; }
196
197 bool NgUltraImpl::is_fabric_lowskew_sink(const PortRef &ref)
198 {
199 return fabric_lowskew_sinks.count(ref.cell->type) && fabric_lowskew_sinks.at(ref.cell->type).count(ref.port);
200 }
201
202 bool NgUltraImpl::is_ring_clock_sink(const PortRef &ref)
203 {
204 return ring_clock_sinks.count(ref.cell->type) && ring_clock_sinks.at(ref.cell->type).count(ref.port);
205 }
206
207 bool NgUltraImpl::is_ring_over_tile_clock_sink(const PortRef &ref)
208 {
209 return ring_over_tile_clock_sinks.count(ref.cell->type) &&
210 ring_over_tile_clock_sinks.at(ref.cell->type).count(ref.port);
211 }
212
213 bool NgUltraImpl::is_tube_clock_sink(const PortRef &ref)
214 {
215 return tube_clock_sinks.count(ref.cell->type) && tube_clock_sinks.at(ref.cell->type).count(ref.port);
216 }
217
218 bool NgUltraImpl::is_ring_clock_source(const PortRef &ref)
219 {
220 return ring_clock_source.count(ref.cell->type) && ring_clock_source.at(ref.cell->type).count(ref.port);
221 }
222
223 bool NgUltraImpl::is_tube_clock_source(const PortRef &ref)
224 {
225 return tube_clock_source.count(ref.cell->type) && tube_clock_source.at(ref.cell->type).count(ref.port);
226 }
227
228 const NGUltraTileInstExtraDataPOD *NgUltraImpl::tile_extra_data(int tile) const
229 {
230 return reinterpret_cast<const NGUltraTileInstExtraDataPOD *>(ctx->chip_info->tile_insts[tile].extra_data.get());
231 }
232
233 const NGUltraPipExtraDataPOD *NgUltraImpl::pip_extra_data(PipId pip) const
234 {
235 return reinterpret_cast<const NGUltraPipExtraDataPOD *>(chip_pip_info(ctx->chip_info, pip).extra_data.get());
236 }
237
238 const NGUltraBelExtraDataPOD *NgUltraImpl::bel_extra_data(BelId bel) const
239 {
240 return reinterpret_cast<const NGUltraBelExtraDataPOD *>(chip_bel_info(ctx->chip_info, bel).extra_data.get());
241 }
242
243 IdString NgUltraImpl::tile_name_id(int tile) const
244 {
245 const auto &data = *tile_extra_data(tile);
246 return IdString(data.name);
247 }
248
249 std::string NgUltraImpl::tile_name(int tile) const { return stringf("%s", tile_name_id(tile).c_str(ctx)); }
250
251 int NgUltraImpl::tile_lobe(int tile) const
252 {
253 const auto &data = *tile_extra_data(tile);
254 return data.lobe;
255 }
256
257 TileTypeExtra NgUltraImpl::tile_type(int tile) const
258 {
259 const auto &data = *tile_extra_data(tile);
260 return (TileTypeExtra)data.tile_type;
261 }
262
263 bool NgUltraImpl::get_mux_data(BelId bel, IdString port, uint8_t *value)
264 {
265 return get_mux_data(ctx->getBelPinWire(bel, port), value);
266 }
267
268 bool NgUltraImpl::get_mux_data(WireId wire, uint8_t *value)
269 {
270 for (PipId pip : ctx->getPipsUphill(wire)) {
271 if (!ctx->getBoundPipNet(pip))
272 continue;
273 const auto &extra_data = *pip_extra_data(pip);
274 if (!extra_data.name)
275 continue;
276 if (extra_data.type == PipExtra::PIP_EXTRA_MUX) {
277 *value = extra_data.input;
278 return true;
279 }
280 }
281 return false;
282 }
283
284 bool NgUltraImpl::update_bff_to_csc(CellInfo *cell, BelId bel, PipId dst_pip)
285 {
286 const auto &extra_data = *bel_extra_data(bel);
287 // Check if CSC mode only if FE is capable
288 if (extra_data.flags & BEL_EXTRA_FE_CSC) {
289 WireId dwire = ctx->getPipDstWire(dst_pip);
290 for (PipId pip : ctx->getPipsDownhill(dwire)) {
291 if (!ctx->getBoundPipNet(pip))
292 continue;
293 for (PipId pip2 : ctx->getPipsDownhill(ctx->getPipDstWire(pip))) {
294 if (!ctx->getBoundPipNet(pip2))
295 continue;
296 IdString dst = ctx->getWireName(ctx->getPipDstWire(pip2))[1];
297 if (boost::ends_with(dst.c_str(ctx), ".DS")) {
298 cell->setParam(id_type, Property("CSC"));
299 return true;
300 }
301 }
302 }
303 }
304 return false;
305 }
306
307 bool NgUltraImpl::update_bff_to_scc(CellInfo *cell, BelId bel, PipId dst_pip)
308 {
309 const auto &extra_data = *bel_extra_data(bel);
310 // Check if SCC mode only if FE is capable
311 if (extra_data.flags & BEL_EXTRA_FE_SCC) {
312 WireId dwire = ctx->getPipDstWire(dst_pip);
313 for (PipId pip : ctx->getPipsUphill(dwire)) {
314 if (!ctx->getBoundPipNet(pip))
315 continue;
316 for (PipId pip2 : ctx->getPipsUphill(ctx->getPipSrcWire(pip))) {
317 if (!ctx->getBoundPipNet(pip2))
318 continue;
319 IdString dst = ctx->getWireName(ctx->getPipSrcWire(pip2))[1];
320 if (boost::starts_with(dst.c_str(ctx), "SYSTEM.ST1")) {
321 cell->setParam(id_type, Property("SCC"));
322 return true;
323 }
324 }
325 }
326 }
327 return false;
328 }
329
330 void NgUltraImpl::postRoute()
331 {
332 ctx->assignArchInfo();
333 log_break();
334 log_info("Resources spent on routing:\n");
335 int bff_count = 0, csc_count = 0, scc_count = 0, lut_bypass = 0, fe_new = 0, wfg_bypass = 0, gck_bypass = 0;
336 for (auto &net : ctx->nets) {
337 NetInfo *ni = net.second.get();
338 for (auto &w : ni->wires) {
339 if (w.second.pip != PipId()) {
340 const auto &extra_data = *pip_extra_data(w.second.pip);
341 if (!extra_data.name)
342 continue;
343 if (extra_data.type == PipExtra::PIP_EXTRA_BYPASS) {
344 IdStringList id = ctx->getPipName(w.second.pip);
345 BelId bel = ctx->getBelByName(IdStringList::concat(id[0], IdString(extra_data.name)));
346 IdString type = ctx->getBelType(bel);
347 if (!ctx->getBoundBelCell(bel)) {
348 CellInfo *cell = ctx->createCell(ctx->id(ctx->nameOfBel(bel)), type);
349 ctx->bindBel(bel, cell, PlaceStrength::STRENGTH_FIXED);
350 if (type == id_BEYOND_FE)
351 fe_new++;
352 }
353 CellInfo *cell = ctx->getBoundBelCell(bel);
354 switch (type.index) {
355 case id_BEYOND_FE.index:
356 if (extra_data.input == 0) {
357 // set bypass mode for DFF
358 cell->setParam(id_type, Property("BFF"));
359 cell->params[id_dff_used] = Property(1, 1);
360 // Note: no conflict, CSC and SCC modes are never available on same position
361 if (update_bff_to_csc(cell, bel, w.second.pip))
362 csc_count++;
363 else if (update_bff_to_scc(cell, bel, w.second.pip))
364 scc_count++;
365 else
366 bff_count++;
367 } else {
368 lut_bypass++;
369 cell->params[id_lut_used] = Property(1, 1);
370 cell->params[id_lut_table] = Property(0xaaaa, 16);
371 }
372 break;
373 case id_WFG.index:
374 wfg_bypass++;
375 cell->type = id_WFB;
376 break;
377 case id_GCK.index:
378 gck_bypass++;
379 cell->setParam(id_std_mode, extra_data.input == 0 ? Property("BYPASS") : Property("CSC"));
380 break;
381 default:
382 log_error("Unmaped bel type '%s' for routing\n", type.c_str(ctx));
383 }
384 }
385 }
386 }
387 }
388 if (bff_count)
389 log_info(" %6d DFFs used as BFF\n", bff_count);
390 if (csc_count)
391 log_info(" %6d DFFs used as CSC\n", csc_count);
392 if (scc_count)
393 log_info(" %6d DFFs used as SCC\n", scc_count);
394 if (lut_bypass)
395 log_info(" %6d LUTs used in bypass mode\n", lut_bypass);
396 if (fe_new)
397 log_info(" %6d newly allocated FEs\n", fe_new);
398 if (wfg_bypass)
399 log_info(" %6d WFGs used as WFB\n", wfg_bypass);
400 if (gck_bypass)
401 log_info(" %6d GCK\n", gck_bypass);
402
403 // Handle LUT permutation
404 for (auto &cell : ctx->cells) {
405 if (cell.second->type == id_BEYOND_FE) {
406 // if LUT part used
407 if (cell.second->params.count(id_lut_table) != 0) {
408 std::array<std::vector<unsigned>, 4> phys_to_log;
409 unsigned orig_init = int_or_default(cell.second->params, id_lut_table);
410 const std::array<IdString, 4> ports{id_I1, id_I2, id_I3, id_I4};
411 for (unsigned i = 0; i < 4; i++) {
412 WireId pin_wire = ctx->getBelPinWire(cell.second->bel, ports[i]);
413 for (PipId pip : ctx->getPipsUphill(pin_wire)) {
414 if (!ctx->getBoundPipNet(pip))
415 continue;
416 const auto &extra_data = *pip_extra_data(pip);
417 if (!extra_data.name)
418 continue;
419 if (extra_data.type == PipExtra::PIP_EXTRA_LUT_PERMUTATION) {
420 NPNR_ASSERT(extra_data.output == i);
421 phys_to_log[extra_data.input].push_back(i);
422 }
423 }
424 }
425 unsigned permuted_init = 0;
426 for (unsigned i = 0; i < 16; i++) {
427 unsigned log_idx = 0;
428 for (unsigned j = 0; j < 4; j++) {
429 if ((i >> j) & 0x1) {
430 for (auto log_pin : phys_to_log[j])
431 log_idx |= (1 << log_pin);
432 }
433 }
434 if ((orig_init >> log_idx) & 0x1)
435 permuted_init |= (1 << i);
436 }
437 cell.second->params[id_lut_table] = Property(permuted_init, 16);
438 }
439 }
440 }
441
442 fixup_crossbars();
443
444 print_utilisation(ctx);
445 const ArchArgs &args = ctx->args;
446 if (args.options.count("bit")) {
447 write_bitstream_json(args.options["bit"].as<std::string>());
448 }
449 }
450
451 void NgUltraImpl::configurePlacerHeap(PlacerHeapCfg &cfg)
452 {
453 cfg.beta = 0.5;
454 cfg.placeAllAtOnce = true;
455 }
456
457 namespace {
458
459 template <size_t N> bool check_assign_sig(std::array<const NetInfo *, N> &sig_set, const NetInfo *sig)
460 {
461 if (sig == nullptr)
462 return true;
463 for (size_t i = 0; i < N; i++)
464 if (sig_set[i] == sig) {
465 return true;
466 } else if (sig_set[i] == nullptr) {
467 sig_set[i] = sig;
468 return true;
469 }
470 return false;
471 };
472
473 struct SectionFEWorker
474 {
475 std::array<const NetInfo *, 2> clk{}; // from local system matrix
476 std::array<const NetInfo *, 2> reset{}; // from local system matrix
477 std::array<const NetInfo *, 2> load{}; // from local system matrix
478 std::array<const NetInfo *, 1> shared{}; // 1 from local system matrix
479 // Additional R and L can be used from RI network
480 bool run(const NgUltraImpl *impl, const Context *ctx, BelId bel, CellInfo *cell)
481 {
482 Loc loc = ctx->getBelLocation(bel);
483 for (uint8_t id = 0; id <= BEL_LUT_MAX_Z; id++) {
484 const CellInfo *ff = ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, id)));
485 if (ff == nullptr)
486 continue;
487 if (!check_assign_sig(reset, ff->getPort(id_R))) {
488 if (!check_assign_sig(shared, ff->getPort(id_R)))
489 return false;
490 }
491 if (!check_assign_sig(load, ff->getPort(id_L))) {
492 if (!check_assign_sig(shared, ff->getPort(id_L)))
493 return false;
494 }
495 if (!check_assign_sig(clk, ff->getPort(id_CK)))
496 return false;
497 }
498 const auto &extra_data = *impl->bel_extra_data(bel);
499 if (cell->params.count(id_type)) {
500 const std::string &type = cell->params[id_type].as_string();
501 if (type == "CSC" && (extra_data.flags & BEL_EXTRA_FE_CSC) == 0)
502 return false; // No CSC capability on FE
503 if (type == "SCC" && (extra_data.flags & BEL_EXTRA_FE_SCC) == 0)
504 return false; // No SCC capability on FE
505 }
506 if (extra_data.flags & BEL_EXTRA_FE_CSC)
507 return false;
508 return true;
509 }
510 };
511
512 }; // namespace
513
514 bool NgUltraImpl::isBelLocationValid(BelId bel, bool explain_invalid) const
515 {
516 CellInfo *cell = ctx->getBoundBelCell(bel);
517 if (cell == nullptr) {
518 return true;
519 }
520 if (ctx->getBelType(bel) == id_BEYOND_FE) {
521 SectionFEWorker worker;
522 return worker.run(this, ctx, bel, cell);
523 } else if (ctx->getBelType(bel).in(id_RF, id_XRF)) {
524 Loc loc = ctx->getBelLocation(bel);
525 if (loc.z == BEL_XRF_Z) {
526 // If we used any of RFs we can not used XRF
527 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_RF_Z))))
528 return false;
529 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_RF_Z + 1))))
530 return false;
531 // If we used any FIFO we can not use XRF
532 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_FIFO_Z))))
533 return false;
534 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_FIFO_Z + 1))))
535 return false;
536 // If we used XFIFO we can not use XRF
537 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_XFIFO_Z))))
538 return false;
539 } else {
540 // If we used XRF we can not use individual RF
541 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_XRF_Z))))
542 return false;
543 // If we used XFIFO we can not use RF
544 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_XFIFO_Z))))
545 return false;
546 int index = loc.z - BEL_RF_Z;
547 // If we used coresponding FIFO we can not use RF
548 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_FIFO_Z + index))))
549 return false;
550 }
551 } else if (ctx->getBelType(bel).in(id_FIFO, id_XFIFO)) {
552 Loc loc = ctx->getBelLocation(bel);
553 if (loc.z == BEL_XFIFO_Z) {
554 // If we used any of RFs we can not used XFIFO
555 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_RF_Z))))
556 return false;
557 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_RF_Z + 1))))
558 return false;
559 // If we used any FIFO we can not use XFIFO
560 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_FIFO_Z))))
561 return false;
562 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_FIFO_Z + 1))))
563 return false;
564 // If we used XFIFO we can not use XFIFO
565 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_XFIFO_Z))))
566 return false;
567 // If we used any CDC we can not use XFIFO
568 // NOTE: CDC1 is in S4 and CDC2 is S12
569 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x - 1, loc.y, BEL_CDC_Z))))
570 return false;
571 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x + 1, loc.y, BEL_CDC_Z + 1))))
572 return false;
573 // If we used XCDC we can not use XFIFO
574 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_XCDC_Z))))
575 return false;
576 } else {
577 // If we used XFIFO we can not use individual FIFO
578 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_XFIFO_Z))))
579 return false;
580 // If we used XRF we can not use FIFO
581 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_XRF_Z))))
582 return false;
583 // If we used XCDC we can not use FIFO
584 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_XCDC_Z))))
585 return false;
586 int index = loc.z - BEL_FIFO_Z;
587 // If we used coresponding RF we can not use FIFO
588 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_RF_Z + index))))
589 return false;
590 // If we used coresponding CDC we can not use FIFO
591 // NOTE: CDC1 is in S4 and CDC2 is S12
592 int rel = (index == 0) ? -1 : +1;
593 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x + rel, loc.y, BEL_CDC_Z + index))))
594 return false;
595 }
596 } else if (ctx->getBelType(bel).in(id_CDC, id_XCDC)) {
597 Loc loc = ctx->getBelLocation(bel);
598 if (loc.z == BEL_XCDC_Z) {
599 // If we used any of CDCs we can not used XCDC
600 // NOTE: CDC1 is in S4 and CDC2 is S12
601 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x - 1, loc.y, BEL_CDC_Z))))
602 return false;
603 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x + 1, loc.y, BEL_CDC_Z + 1))))
604 return false;
605 // If we used any FIFO we can not use XCDC
606 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_FIFO_Z))))
607 return false;
608 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_FIFO_Z + 1))))
609 return false;
610 // If we used XFIFO we can not use XCDC
611 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x, loc.y, BEL_XFIFO_Z))))
612 return false;
613 } else {
614 // NOTE: CDC1 is in S4 and CDC2 is S12 so we move calculation relative to S8
615 int index = loc.z - BEL_CDC_Z;
616 int fix = (index == 0) ? +1 : -1;
617 // If we used XCDC we can not use individual CDC
618 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x + fix, loc.y, BEL_XCDC_Z))))
619 return false;
620 // If we used XFIFO we can not use CDC
621 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x + fix, loc.y, BEL_XFIFO_Z))))
622 return false;
623 // If we used coresponding FIFO we can not use CDC
624 if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x + fix, loc.y, BEL_FIFO_Z + index))))
625 return false;
626 }
627 }
628 return true;
629 }
630
631 // Bel bucket functions
632 IdString NgUltraImpl::getBelBucketForCellType(IdString cell_type) const
633 {
634 if (cell_type.in(id_IOP, id_IP, id_OP, id_IOTP, id_ITP, id_OTP))
635 return ctx->idf("IOP/IOTP");
636 else if (cell_type.in(id_BFR, id_DFR, id_DDFR))
637 return ctx->idf("DFR/DDFR");
638 else if (cell_type.in(id_RF, id_RFSP))
639 return id_RF;
640 else if (cell_type.in(id_XHRF, id_XWRF, id_XPRF))
641 return id_XRF;
642 else if (cell_type.in(id_DDE, id_TDE, id_CDC, id_BGC, id_GBC))
643 return id_CDC;
644 else if (cell_type.in(id_XCDC))
645 return id_XCDC;
646 else if (cell_type.in(id_FIFO))
647 return id_FIFO;
648 else if (cell_type.in(id_XHFIFO, id_XWFIFO))
649 return id_XFIFO;
650 else if (cell_type.in(id_WFB, id_WFG))
651 return id_WFG;
652 else
653 return cell_type;
654 }
655
656 BelBucketId NgUltraImpl::getBelBucketForBel(BelId bel) const
657 {
658 IdString bel_type = ctx->getBelType(bel);
659 if (bel_type.in(id_IOP, id_IOTP))
660 return ctx->idf("IOP/IOTP");
661 else if (bel_type.in(id_DFR, id_DDFR))
662 return ctx->idf("DFR/DDFR");
663 return bel_type;
664 }
665
666 bool NgUltraImpl::isValidBelForCellType(IdString cell_type, BelId bel) const
667 {
668 IdString bel_type = ctx->getBelType(bel);
669 if (bel_type == id_IOTP)
670 return cell_type.in(id_IOP, id_IP, id_OP, id_IOTP, id_ITP, id_OTP);
671 else if (bel_type == id_IOP)
672 return cell_type.in(id_IOP, id_IP, id_OP);
673 else if (bel_type == id_DDFR)
674 return cell_type.in(id_BFR, id_DFR, id_DDFR);
675 else if (bel_type == id_DFR)
676 return cell_type.in(id_BFR, id_DFR);
677 else if (bel_type == id_RF)
678 return cell_type.in(id_RF, id_RFSP);
679 else if (bel_type == id_XRF)
680 return cell_type.in(id_XHRF, id_XWRF, id_XPRF);
681 else if (bel_type == id_CDC)
682 return cell_type.in(id_DDE, id_TDE, id_CDC, id_BGC, id_GBC);
683 else if (bel_type == id_XCDC)
684 return cell_type.in(id_XCDC);
685 else if (bel_type == id_FIFO)
686 return cell_type.in(id_FIFO);
687 else if (bel_type == id_XFIFO)
688 return cell_type.in(id_XHFIFO, id_XWFIFO);
689 else if (bel_type == id_WFG)
690 return cell_type.in(id_WFB, id_WFG);
691 else
692 return (bel_type == cell_type);
693 }
694
695 bool NgUltraImpl::getChildPlacement(const BaseClusterInfo *cluster, Loc root_loc,
696 std::vector<std::pair<CellInfo *, BelId>> &placement) const
697 {
698 Loc prev = root_loc;
699 for (auto child : cluster->constr_children) {
700 Loc child_loc;
701 switch (child->constr_z) {
702 case PLACE_CY_CHAIN:
703 child_loc = getNextLocInCYChain(prev);
704 prev = child_loc;
705 break;
706 case PLACE_LUT_CHAIN:
707 child_loc = getNextLocInLUTChain(prev);
708 prev = child_loc;
709 break;
710 case PLACE_DFF_CHAIN:
711 child_loc = getNextLocInDFFChain(prev);
712 prev = child_loc;
713 break;
714 case PLACE_CY_FE1 ... PLACE_CY_FE4:
715 child_loc = getCYFE(root_loc, child->constr_z - PLACE_CY_FE1);
716 break;
717 case PLACE_XLUT_FE1 ... PLACE_XLUT_FE4:
718 child_loc = getXLUTFE(root_loc, child->constr_z - PLACE_XLUT_FE1);
719 break;
720 case PLACE_XRF_I1 ... PLACE_XRF_WEA:
721 child_loc = getXRFFE(root_loc, child->constr_z - PLACE_XRF_I1);
722 break;
723 case PLACE_CDC_AI1 ... PLACE_CDC_DDRSTI:
724 child_loc = getCDCFE(root_loc, child->constr_z - PLACE_CDC_AI1);
725 break;
726 case PLACE_FIFO_I1 ... PLACE_FIFO_REQ2:
727 child_loc = getFIFOFE(root_loc, child->constr_z - PLACE_FIFO_I1);
728 break;
729 case PLACE_DSP_CHAIN:
730 child_loc = getNextLocInDSPChain(this, prev);
731 prev = child_loc;
732 break;
733 default:
734 child_loc.x = root_loc.x + child->constr_x;
735 child_loc.y = root_loc.y + child->constr_y;
736 child_loc.z = child->constr_abs_z ? child->constr_z : (root_loc.z + child->constr_z);
737 }
738 BelId child_bel = ctx->getBelByLocation(child_loc);
739 if (child_bel == BelId() || !this->isValidBelForCellType(child->type, child_bel))
740 return false;
741 placement.emplace_back(child, child_bel);
742 if (!getChildPlacement(child, child_loc, placement))
743 return false;
744 }
745 return true;
746 }
747
748 bool NgUltraImpl::getClusterPlacement(ClusterId cluster, BelId root_bel,
749 std::vector<std::pair<CellInfo *, BelId>> &placement) const
750 {
751 CellInfo *root_cell = get_cluster_root(ctx, cluster);
752 placement.clear();
753 NPNR_ASSERT(root_bel != BelId());
754 Loc root_loc = ctx->getBelLocation(root_bel);
755 if (root_cell->constr_abs_z) {
756 // Coerce root to absolute z constraint
757 root_loc.z = root_cell->constr_z;
758 root_bel = ctx->getBelByLocation(root_loc);
759 if (root_bel == BelId() || !this->isValidBelForCellType(root_cell->type, root_bel))
760 return false;
761 }
762 placement.emplace_back(root_cell, root_bel);
763 return getChildPlacement(root_cell, root_loc, placement);
764 }
765
766 BoundingBox NgUltraImpl::getRouteBoundingBox(WireId src, WireId dst) const
767 {
768 if ((tile_type(src.tile) != TILE_EXTRA_FABRIC || tile_type(dst.tile) != TILE_EXTRA_FABRIC)) {
769 return {0, 0, ctx->getGridDimX(), ctx->getGridDimY()};
770 }
771 int x0, y0, x1, y1;
772 auto expand = [&](int x, int y) {
773 x0 = std::min(x0, x);
774 x1 = std::max(x1, x);
775 y0 = std::min(y0, y);
776 y1 = std::max(y1, y);
777 };
778 tile_xy(ctx->chip_info, src.tile, x0, y0);
779 x1 = x0;
780 y1 = y0;
781 int dx, dy;
782 tile_xy(ctx->chip_info, dst.tile, dx, dy);
783 expand(dx, dy);
784 // Reach 7 MESH above and below (3 left and 3 right of TILE/CGB)
785 return {(x0 & 0xfffc) - 3 * 4, // 3 MESH on left
786 (y0 & 0xfffc) - 4, // row above
787 (x1 & 0xfffc) + 4 * 4, // MESH bellow and 3 right
788 (y1 & 0xfffc) + 8}; // current and row bellow
789 }
790
791 void NgUltraImpl::expandBoundingBox(BoundingBox &bb) const
792 {
793 // Updated numbers for NG-ULTRA only
794 // x0 and y0 substract 1 TILE
795 // x1 and y1 adds 1 TILE (and of one added)
796 bb.x0 = std::max((bb.x0 & 0xfffc) - 4, 0);
797 bb.y0 = std::max((bb.y0 & 0xfffc) - 4, 0);
798 bb.x1 = std::min((bb.x1 & 0xfffc) + 8, ctx->getGridDimX());
799 bb.y1 = std::min((bb.y1 & 0xfffc) + 8, ctx->getGridDimY());
800 }
801
802 delay_t NgUltraImpl::estimateDelay(WireId src, WireId dst) const
803 {
804 int sx, sy, dx, dy;
805 tile_xy(ctx->chip_info, src.tile, sx, sy);
806 tile_xy(ctx->chip_info, dst.tile, dx, dy);
807 if (sx == dx && sy == dy) {
808 // Same sub tile
809 return 50;
810 } else if (((sx & 0xfffc) == (dx & 0xfffc)) && ((sy & 0xfffc) == (dy & 0xfffc))) {
811 // Same "TILE"
812 return 200;
813 }
814 return 500 + 100 * (std::abs(dy - sy) / 4 + std::abs(dx - sx) / 4);
815 }
816
817 delay_t NgUltraImpl::predictDelay(BelId src_bel, IdString src_pin, BelId dst_bel, IdString dst_pin) const
818 {
819 Loc src_loc = ctx->getBelLocation(src_bel), dst_loc = ctx->getBelLocation(dst_bel);
820 if (src_loc.x == dst_loc.x && src_loc.y == dst_loc.y) {
821 // Same sub tile
822 return 50;
823 } else if (((src_loc.x & 0xfffc) == (dst_loc.x & 0xfffc)) && ((src_loc.y & 0xfffc) == (dst_loc.y & 0xfffc))) {
824 // Same "TILE"
825 return 200;
826 }
827 return 500 + 100 * (std::abs(dst_loc.y - src_loc.y) / 4 + std::abs(dst_loc.x - src_loc.x) / 4);
828 }
829
830 void NgUltraImpl::fixup_crossbars()
831 {
832
833 auto is_crossbar_pip = [&](PipId pip) {
834 const auto &extra_data = *pip_extra_data(pip);
835 return (extra_data.name && extra_data.type == PipExtra::PIP_EXTRA_CROSSBAR);
836 };
837
838 auto crossbar_key = [&](PipId pip) {
839 const auto &extra_data = *pip_extra_data(pip);
840 return std::make_pair(pip.tile, IdString(extra_data.name));
841 };
842
843 for (auto &net : ctx->nets) {
844 NetInfo *ni = net.second.get();
845 dict<WireId, std::vector<PipId>> downstream;
846 // build a map of wires to sinks
847 for (auto &w : ni->wires) {
848 if (w.second.pip != PipId()) {
849 downstream[ctx->getPipSrcWire(w.second.pip)].push_back(w.second.pip);
850 }
851 }
852 // the original drivers of crossbars
853 dict<std::pair<int, IdString>, WireId> crossbar_entries;
854 // traverse from the start forwards so we always reach closer wires first in the route tree
855 WireId src = ctx->getNetinfoSourceWire(ni);
856 if (src == WireId() || !downstream.count(src)) {
857 continue;
858 }
859 std::queue<WireId> visit;
860 visit.push(src);
861 while (!visit.empty()) {
862 WireId cursor = visit.front();
863 visit.pop();
864 if (!downstream.count(cursor))
865 continue;
866 for (auto pip : downstream.at(cursor)) {
867 WireId dst = ctx->getPipDstWire(pip);
868 if (is_crossbar_pip(pip)) {
869 auto key = crossbar_key(pip);
870 if (!crossbar_entries.count(key)) {
871 crossbar_entries[key] = ctx->getPipSrcWire(pip);
872 } else {
873 WireId xbar_src = crossbar_entries.at(key);
874 if (ctx->getPipSrcWire(pip) != xbar_src) {
875 // rewrite to be driven by original entry
876 ctx->unbindPip(pip);
877 PipId found_pip = PipId();
878 for (auto search_pip : ctx->getPipsUphill(dst)) {
879 if (ctx->getPipSrcWire(search_pip) == xbar_src) {
880 found_pip = search_pip;
881 break;
882 }
883 }
884 NPNR_ASSERT(found_pip != PipId());
885 // rebind
886 // log_info(" replacing crossbar pip %s with %s on %s\n", ctx->nameOfPip(pip),
887 // ctx->nameOfPip(found_pip), ctx->nameOf(ni));
888 ctx->bindPip(found_pip, ni, STRENGTH_STRONG);
889 }
890 }
891 }
892 visit.push(dst);
893 }
894 downstream.erase(cursor);
895 }
896 // check everything was visited by our BFS tree traversal
897 NPNR_ASSERT(downstream.empty());
898 }
899 }
900
901 void NgUltraImpl::drawBel(std::vector<GraphicElement> &g, GraphicElement::style_t style, IdString bel_type, Loc loc)
902 {
903 GraphicElement el;
904 el.type = GraphicElement::TYPE_BOX;
905 el.style = style;
906 switch (bel_type.index) {
907 case id_BEYOND_FE.index:
908 el.x1 = loc.x + 0.15 + (loc.z % 8) * 0.1;
909 el.x2 = el.x1 + 0.05;
910 el.y1 = loc.y + 0.9 - (loc.z / 8) * 0.15;
911 el.y2 = el.y1 - 0.05;
912 g.push_back(el);
913 break;
914 case id_XLUT.index:
915 el.x1 = loc.x + 0.15 + ((loc.z - BEL_XLUT_Z) % 8) * 0.1;
916 el.x2 = el.x1 + 0.05;
917 el.y1 = loc.y + 0.9 - 4 * 0.15;
918 el.y2 = el.y1 - 0.1;
919 g.push_back(el);
920 break;
921 case id_CY.index:
922 el.x1 = loc.x + 0.15 + ((loc.z - BEL_CY_Z) % 4) * 0.2;
923 el.x2 = el.x1 + 0.15;
924 el.y1 = loc.y + 0.9 - 4 * 0.15;
925 el.y2 = el.y1 - 0.1;
926 g.push_back(el);
927 break;
928 case id_RF.index:
929 el.x1 = loc.x + 0.15 + ((loc.z - BEL_RF_Z) % 2) * 0.6;
930 el.x2 = el.x1 + 0.15;
931 el.y1 = loc.y + 0.9 - 4 * 0.15;
932 el.y2 = el.y1 - 0.05;
933 g.push_back(el);
934 break;
935 case id_XRF.index:
936 el.x1 = loc.x + 0.15 + 0.2;
937 el.x2 = el.x1 + 0.35;
938 el.y1 = loc.y + 0.9 - 4 * 0.15;
939 el.y2 = el.y1 - 0.05;
940 g.push_back(el);
941 break;
942 case id_CDC.index:
943 el.x1 = loc.x + 0.15 + ((loc.z - BEL_CDC_Z) % 2) * 0.6;
944 el.x2 = el.x1 + 0.15;
945 el.y1 = loc.y + 0.9 - 4 * 0.15 - 0.1;
946 el.y2 = el.y1 - 0.05;
947 g.push_back(el);
948 break;
949 case id_XCDC.index:
950 el.x1 = loc.x + 0.15 + 0.2;
951 el.x2 = el.x1 + 0.35;
952 el.y1 = loc.y + 0.9 - 4 * 0.15 - 0.1;
953 el.y2 = el.y1 - 0.05;
954 g.push_back(el);
955 break;
956 case id_FIFO.index:
957 el.x1 = loc.x + 0.15 + ((loc.z - BEL_FIFO_Z) % 2) * 0.6;
958 el.x2 = el.x1 + 0.15;
959 el.y1 = loc.y + 0.9 - 4 * 0.15 - 0.2;
960 el.y2 = el.y1 - 0.05;
961 g.push_back(el);
962 break;
963 case id_XFIFO.index:
964 el.x1 = loc.x + 0.15 + 0.2;
965 el.x2 = el.x1 + 0.35;
966 el.y1 = loc.y + 0.9 - 4 * 0.15 - 0.2;
967 el.y2 = el.y1 - 0.05;
968 g.push_back(el);
969 break;
970 case id_IOTP.index:
971 el.x1 = loc.x + 0.15 + loc.z / 4 * 0.11;
972 el.x2 = el.x1 + 0.06;
973 if (loc.y == 3) { // bottom
974 el.y1 = 0.1;
975 el.y2 = el.y1 + 0.2;
976 } else { // top
977 el.y1 = loc.y + 0.9;
978 el.y2 = el.y1 - 0.2;
979 }
980 g.push_back(el);
981 break;
982 case id_IOM.index:
983 el.x1 = loc.x + 0.15;
984 el.x2 = el.x1 + 33 * 0.11 + 0.06;
985 if (loc.y == 3) { // bottom
986 el.y1 = 0.4;
987 el.y2 = el.y1 + 0.2;
988 } else { // top
989 el.y1 = loc.y + 0.6;
990 el.y2 = el.y1 - 0.2;
991 }
992 g.push_back(el);
993 break;
994 case id_DDFR.index:
995 el.x1 = loc.x + 0.15 + loc.z / 4 * 0.11 + (loc.z % 4 - 1) * 0.02;
996 el.x2 = el.x1 + 0.015;
997 if (loc.y == 3) { // bottom
998 el.y1 = 0.7;
999 el.y2 = el.y1 + 0.1;
1000 } else { // top
1001 el.y1 = loc.y + 0.3;
1002 el.y2 = el.y1 - 0.1;
1003 }
1004 g.push_back(el);
1005 break;
1006 case id_IOP.index:
1007 if (loc.x == ctx->getGridDimX() - 4) { // right
1008 el.x1 = ctx->getGridDimX() - 0.1;
1009 el.x2 = el.x1 - 0.2;
1010 } else { // left
1011 el.x1 = loc.x + 0.1;
1012 el.x2 = el.x1 + 0.2;
1013 }
1014 el.y1 = loc.y + 0.85 - loc.z / 4 * 0.11;
1015 el.y2 = el.y1 - 0.06;
1016 g.push_back(el);
1017 break;
1018 case id_DFR.index:
1019 if (loc.x == ctx->getGridDimX() - 4) { // right
1020 el.x1 = ctx->getGridDimX() - 0.4;
1021 el.x2 = el.x1 - 0.1;
1022 } else { // left
1023 el.x1 = loc.x + 0.4;
1024 el.x2 = el.x1 + 0.1;
1025 }
1026 el.y1 = loc.y + 0.85 - loc.z / 4 * 0.11 - (loc.z % 4 - 1) * 0.02 - 0.02;
1027 el.y2 = el.y1 + 0.015;
1028 g.push_back(el);
1029 break;
1030 case id_PLL.index:
1031 el.x1 = loc.x + 0.1;
1032 el.x2 = el.x1 + 0.8;
1033 el.y1 = loc.y + 0.9;
1034 el.y2 = el.y1 - 0.8;
1035 g.push_back(el);
1036 break;
1037 case id_WFG.index:
1038 el.x1 = loc.x + 1.1;
1039 el.x2 = el.x1 + 0.8;
1040 el.y1 = loc.y + 0.95 - (loc.z - 1) * 0.25 + 3;
1041 el.y2 = el.y1 - 0.2;
1042 g.push_back(el);
1043 break;
1044 case id_RAM.index:
1045 el.x1 = loc.x + 0.2;
1046 el.x2 = el.x1 + 3.6;
1047 el.y1 = loc.y + 0.8;
1048 el.y2 = el.y1 - 1.6;
1049 g.push_back(el);
1050 break;
1051 case id_DSP.index:
1052 el.x1 = (loc.x - 1) + 0.2;
1053 el.x2 = el.x1 + 1.6;
1054 el.y1 = loc.y + 0.8;
1055 el.y2 = el.y1 - 1.6;
1056 g.push_back(el);
1057 break;
1058 case id_GCK.index: {
1059 int lobe = loc.z / 20;
1060 el.x1 = (47 + (lobe % 2) * 3) * 4 + 0.1;
1061 el.x2 = el.x1 + 0.8;
1062 el.y1 = (ctx->getGridDimY() - 1 - (7 * 4 + 12 * 4 * (lobe >> 1))) + 0.95 - (loc.z % 20) * 0.25;
1063 el.y2 = el.y1 - 0.2;
1064 g.push_back(el);
1065 } break;
1066 default:
1067 break;
1068 }
1069 }
1070
1071 struct NgUltraArch : HimbaechelArch
1072 {
1073 NgUltraArch() : HimbaechelArch("ng-ultra") {};
1074 bool match_device(const std::string &device) override { return device == "NG-ULTRA"; }
1075 std::unique_ptr<HimbaechelAPI> create(const std::string &device) override
1076 {
1077 return std::make_unique<NgUltraImpl>();
1078 }
1079 } ngUltraArch;
1080
1081 NEXTPNR_NAMESPACE_END