MLIR-AIE 1.4.6.dev
AIETargetModel.h
Go to the documentation of this file.
1//===- AIETargetModel.h -----------------------------------------*- C++ -*-===//
2//
3// Copyright (C) 2023 Advanced Micro Devices, Inc.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5//
6//===----------------------------------------------------------------------===//
7
8#ifndef MLIR_AIE_DEVICEMODEL_H
9#define MLIR_AIE_DEVICEMODEL_H
10
13
14#include "llvm/ADT/ArrayRef.h"
15#include "llvm/ADT/DenseSet.h"
16#include "llvm/ADT/STLExtras.h"
17#include "llvm/ADT/SmallVector.h"
18#include "llvm/Support/MathExtras.h"
19
20#include <iostream>
21#include <memory>
22#include <mutex>
23#include <vector>
24
25namespace xilinx::AIE {
26
27using TileID = struct TileID {
28 // friend definition (will define the function as a non-member function in the
29 // namespace surrounding the class).
30 friend std::ostream &operator<<(std::ostream &os, const TileID &s) {
31 os << "TileID(" << s.col << ", " << s.row << ")";
32 return os;
33 }
34
35 friend std::string to_string(const TileID &s) {
36 std::ostringstream ss;
37 ss << s;
38 return ss.str();
39 }
40
41 friend llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const TileID &s) {
42 os << to_string(s);
43 return os;
44 }
45
46 // Imposes a lexical order on TileIDs.
47 inline bool operator<(const TileID &rhs) const {
48 return std::tie(col, row) < std::tie(rhs.col, rhs.row);
49 }
50
51 bool operator==(const TileID &rhs) const {
52 return std::tie(col, row) == std::tie(rhs.col, rhs.row);
53 }
54
55 bool operator!=(const TileID &rhs) const { return !(*this == rhs); }
56
57 int col, row;
58};
59
60/// Bits [shift, shift + width) of register `word` in a buffer descriptor's
61/// register block. A field a tile type does not have has width 0.
62struct DmaBdField {
63 uint8_t word = 0, shift = 0, width = 0;
64
65 bool exists() const { return width != 0; }
66 uint32_t mask() const {
67 return width >= 32 ? 0xFFFFFFFFu : (1u << width) - 1;
68 }
69 uint32_t place(uint64_t value) const {
70 return exists() ? (static_cast<uint32_t>(value) & mask()) << shift : 0;
71 }
72};
73
74/// The register layout of one tile type's DMA buffer descriptor. The static
75/// and runtime BD lowerings both pack through it, so the two cannot disagree.
77 uint8_t numWords = 0;
78 /// Step fields hold (step in granules - stepBias).
79 uint8_t stepBias = 1;
82 /// Without a d0Stride field the innermost dimension is contiguous.
84 /// Fourth-dimension fields; not programmed yet (buffer_length carries d2).
92
93 /// The (before, after) zero-padding fields, innermost dimension first.
94 llvm::SmallVector<std::pair<DmaBdField, DmaBdField>, 3> padFields() const {
95 llvm::SmallVector<std::pair<DmaBdField, DmaBdField>, 3> fields;
96 for (std::pair<DmaBdField, DmaBdField> field :
97 {std::pair(d0ZeroBefore, d0ZeroAfter),
98 std::pair(d1ZeroBefore, d1ZeroAfter),
99 std::pair(d2ZeroBefore, d2ZeroAfter)}) {
100 if (!field.first.exists())
101 break;
102 fields.push_back(field);
103 }
104 return fields;
105 }
106};
107
109
110public:
139
140 // One-hot encoded list of target model properties.
142 // Device uses semaphore locks.
144 // Device is an NPU-based device.
145 IsNPU = 1U << 1,
146 // Device model is virtualized.
147 // This is used during CDO code generation to configure aie-codegen
148 // properly.
149 IsVirtualized = 1U << 2,
150 // Device uses multi-dimensional buffer descriptors.
152 // Device supports BD per-execution base address advance.
154 // Device supports out-of-order S2MM DMA.
156 // Device tiles can be configured by control packets.
158 };
159
160private:
161 const TargetModelKind kind;
162
163 uint32_t ModelProperties = 0;
164
165 // Register database (loaded lazily on first access)
166 // Thread-safe lazy initialization using std::call_once
167 mutable std::unique_ptr<RegisterDatabase> regDB;
168 mutable std::once_flag regDBInitFlag;
169
170protected:
171 /// Subclasses override to provide architecture-specific database loading.
172 /// Returns nullptr if register database is not available for this
173 /// architecture.
174 virtual std::unique_ptr<RegisterDatabase> loadRegisterDatabase() const;
175
176 /// Get the register database, loading it lazily on first access.
177 /// Throws fatal error if database is required but unavailable.
179
180public:
181 TargetModelKind getKind() const { return kind; }
182
184
186
187 /// Return the target architecture.
188 virtual AIEArch getTargetArch() const = 0;
189
190 /// Return the data bus width of the device.
191 virtual uint32_t getAddressGenGranularity() const = 0;
192
193 /// Return the number of columns in the device.
194 virtual int columns() const = 0;
195
196 /// Width of the physical array this (possibly virtualized) device is carved
197 /// from. This defaults to columns(), which is correct for devices that are
198 /// the whole array.
199 virtual int physicalColumns() const { return columns(); }
200
201 /// First physical column at which a partition may be anchored.
202 virtual int firstPlaceableColumn() const { return 0; }
203
204 /// Every physical column offset at which a numCols-wide partition still fits.
205 std::vector<int> partitionStartColumns(int numCols) const {
206 std::vector<int> starts;
207 for (int c = firstPlaceableColumn(); c + numCols <= physicalColumns(); ++c)
208 starts.push_back(c);
209 return starts;
210 }
211
212 /// Return the number of rows in the device.
213 virtual int rows() const = 0;
214
215 /// Number of microcontrollers (uC) per column
216 virtual uint32_t getNumControllersPerColumn() const { return 0; }
217
218 /// Total number of microcontrollers (uC) in the device.
219 /// Defaults to columns() * getNumControllersPerColumn();
220 /// architectures with a single device-level uC (e.g. AIE2/AIE2P NPUs)
221 /// override this directly instead, since their controller count doesn't
222 /// scale with column count.
223 virtual uint32_t getNumControllers() const {
224 return static_cast<uint32_t>(columns()) * getNumControllersPerColumn();
225 }
226
227 /// Return the tile type for the given tile coordinates.
228 /// - CoreTile: tiles with a Core, TileDMA, tile memory, and stream
229 /// connections.
230 /// - MemTile: tiles with TileDMA, tile memory, and stream connections,
231 /// but no core.
232 /// - ShimNOCTile: tiles with ShimDMA and connection to the memory-mapped NOC.
233 /// - ShimPLTile: tiles with connections to the PL, no ShimDMA.
234 virtual AIETileType getTileType(int col, int row) const = 0;
235
236 /// Return true if the given tile is a Core tile.
237 bool isCoreTile(int col, int row) const {
238 return getTileType(col, row) == AIETileType::CoreTile;
239 }
240
241 /// Return true if the given tile is a Mem tile.
242 bool isMemTile(int col, int row) const {
243 return getTileType(col, row) == AIETileType::MemTile;
244 }
245
246 /// Return true if the given tile is a ShimNOC tile.
247 bool isShimNOCTile(int col, int row) const {
248 return getTileType(col, row) == AIETileType::ShimNOCTile;
249 }
250
251 /// Return true if the given tile is a ShimPL tile.
252 bool isShimPLTile(int col, int row) const {
253 return getTileType(col, row) == AIETileType::ShimPLTile;
254 }
255
256 /// Return true if the given tile is either a ShimNOC or ShimPL tile.
257 bool isShimNOCorPLTile(int col, int row) const {
258 AIETileType t = getTileType(col, row);
259 return t == AIETileType::ShimNOCTile || t == AIETileType::ShimPLTile;
260 }
261
262 /// Return true if the given tile ID is valid.
263 virtual bool isValidTile(TileID src) const {
264 return src.col >= 0 && src.col < columns() && src.row >= 0 &&
265 src.row < rows();
266 }
267
268 /// Return the tile ID of the memory to the west of the given tile, if it
269 /// exists.
270 virtual std::optional<TileID> getMemWest(TileID src) const = 0;
271 /// Return the tile ID of the memory to the east of the given tile, if it
272 /// exists.
273 virtual std::optional<TileID> getMemEast(TileID src) const = 0;
274 /// Return the tile ID of the memory to the north of the given tile, if it
275 /// exists.
276 virtual std::optional<TileID> getMemNorth(TileID src) const = 0;
277 /// Return the tile ID of the memory to the south of the given tile, if it
278 /// exists.
279 virtual std::optional<TileID> getMemSouth(TileID src) const = 0;
280
281 /// Return true if src is the internal memory of dst
282 bool isInternal(int srcCol, int srcRow, int dstCol, int dstRow) const {
283 return srcCol == dstCol && srcRow == dstRow;
284 }
285
286 /// Return true if src is West of dst
287 bool isWest(int srcCol, int srcRow, int dstCol, int dstRow) const {
288 return srcCol == dstCol + 1 && srcRow == dstRow;
289 }
290
291 /// Return true if src is East of dst
292 bool isEast(int srcCol, int srcRow, int dstCol, int dstRow) const {
293 return srcCol == dstCol - 1 && srcRow == dstRow;
294 }
295
296 /// Return true if src is North of dst
297 bool isNorth(int srcCol, int srcRow, int dstCol, int dstRow) const {
298 return srcCol == dstCol && srcRow == dstRow - 1;
299 }
300
301 /// Return true if src is South of dst
302 bool isSouth(int srcCol, int srcRow, int dstCol, int dstRow) const {
303 return srcCol == dstCol && srcRow == dstRow + 1;
304 }
305
306 /// The steps (destination column - source column, destination row - source
307 /// row) from one core's cascade output to the next core's input.
308 virtual llvm::ArrayRef<std::pair<int, int>> getCascadeSteps() const {
309 return {};
310 }
311
312 /// Return true if a cascade can run from src to dst.
313 bool isLegalCascade(int srcCol, int srcRow, int dstCol, int dstRow) const {
314 return llvm::is_contained(getCascadeSteps(),
315 std::pair{dstCol - srcCol, dstRow - srcRow});
316 }
317
318 /// Return true if src has a memory tile which is West of dst
319 virtual bool isMemWest(int srcCol, int srcRow, int dstCol,
320 int dstRow) const = 0;
321 /// Return true if src has a memory tile which is East of dst
322 virtual bool isMemEast(int srcCol, int srcRow, int dstCol,
323 int dstRow) const = 0;
324 /// Return true if src has a memory tile which is North of dst
325 virtual bool isMemNorth(int srcCol, int srcRow, int dstCol,
326 int dstRow) const = 0;
327 /// Return true if src has a memory tile which is South of dst
328 virtual bool isMemSouth(int srcCol, int srcRow, int dstCol,
329 int dstRow) const = 0;
330
331 /// Return true if core can access the memory in mem
332 virtual bool isLegalMemAffinity(int coreCol, int coreRow, int memCol,
333 int memRow) const = 0;
334
335 /// Which of two tiles' memory modules both of them can address.
336 enum class SharedMemory {
337 /// Neither tile can address the other's memory module.
339 /// Only the first tile's module.
341 /// Only the second tile's module.
343 /// Either will do.
345 };
346
347 /// Return the memory module `a` and `b` can both reach, if any.
349 // A shim or mem tile's memory module is only ever reachable from its own
350 // kind, so tiles of different kinds share nothing.
351 if (isShimNOCorPLTile(a.col, a.row) != isShimNOCorPLTile(b.col, b.row) ||
352 isMemTile(a.col, a.row) != isMemTile(b.col, b.row)) {
353 return SharedMemory::None;
354 }
355 bool aReachesB = isLegalMemAffinity(a.col, a.row, b.col, b.row);
356 bool bReachesA = isLegalMemAffinity(b.col, b.row, a.col, a.row);
357 if (aReachesB && bReachesA) {
359 }
360 if (bReachesA) {
361 return SharedMemory::First;
362 }
363 if (aReachesB) {
365 }
366 return SharedMemory::None;
367 }
368
369 /// Return the base address in the local address map for a core.
370 virtual uint32_t getMemInternalBaseAddress(TileID src) const = 0;
371 /// Return the base address in the local address map for a core.
372 virtual uint32_t getMemSouthBaseAddress() const = 0;
373 /// Return the base address in the local address map for a core.
374 virtual uint32_t getMemWestBaseAddress() const = 0;
375 /// Return the base address in the local address map for a core.
376 virtual uint32_t getMemNorthBaseAddress() const = 0;
377 /// Return the base address in the local address map for a core.
378 virtual uint32_t getMemEastBaseAddress() const = 0;
379
380 /// Return the lock base index (or offset) in the local tile when accessing a
381 /// neighbor's lock or an empty optional if an invalid neighbor is given
382 /// Takes into account differences between Memory and Core tiles
383 virtual std::optional<uint32_t> getLockLocalBaseIndex(int localCol,
384 int localRow,
385 int lockCol,
386 int lockRow) const;
387
388 /// Return the memory base address (or offset) in the local tile when
389 /// accessing a neighbor's memory or an empty optional if an invalid neighbor
390 /// is given
391 /// Takes into account differences between Memory and Core tiles
392 virtual std::optional<uint32_t> getMemLocalBaseAddress(int localCol,
393 int localRow,
394 int memCol,
395 int memRow) const;
396
397 /// Return the size (in bytes) of the local data memory of a core.
398 virtual uint32_t getLocalMemorySize() const = 0;
399
400 /// Return the size (in bytes) of a core's program memory.
401 virtual uint32_t getProgramMemorySize() const = 0;
402
403 /// Return the size (in bytes) of the address space a core can issue data
404 /// accesses into. The neighbour memory windows sit at the bottom of it; the
405 /// span above them reaches no memory and is reserved so nothing is placed
406 /// there.
407 virtual uint32_t getCoreDataAddressSpaceSize() const = 0;
408
409 /// Return the default stack reservation (in bytes) for a core that does not
410 /// state one. It is also the floor when aiecc sizes the stack from its
411 /// measurement. The linker script places the stack directly below the
412 /// objectFIFO buffers with no clearance, so a design whose frames exceed its
413 /// reservation corrupts them instead of faulting.
414 virtual uint32_t getDefaultCoreStackSize() const { return 0x400; }
415
416 /// Stack-pointer alignment in bytes, matching Peano's AIE frame lowering:
417 /// AIE1/AIE2 require 32B; AIE2P/AIE2PS require 64B, not their 32B data bus.
418 uint32_t getCoreStackAlignment() const {
419 AIEArch arch = getTargetArch();
420 return arch == AIEArch::AIE2p || arch == AIEArch::AIE2ps ? 64 : 32;
421 }
422
423 /// Return the data bus width (in bits) for load/store operations of a compute
424 /// core.
425 virtual uint32_t getComputeTileLoadStoreBusWidth() const = 0;
426
427 /// Return the alignment (in bits) required by the widest vector load/store a
428 /// compute core can issue.
429 ///
430 /// This is NOT the load/store bus width. From AIE2P on, a full-width
431 /// (512-bit) vector access requires 512-bit alignment even though the bus is
432 /// 256 bits wide. Mirrors `vector_ldst_align` in aie_api
433 /// (aie_api/detail/ld_st.hpp), which is the contract kernels compile against:
434 /// AIE1 (__AIE_ARCH__ 10): 16B
435 /// AIE2 (__AIE_ARCH__ 20): 32B
436 /// AIE2P/AIE2PS (__AIE_ARCH__ 21/22): 64B
437 /// A buffer a core may access with a full-width vector must be aligned to
438 /// this, or the access silently touches the wrong memory.
439 virtual uint32_t getComputeTileMaxVectorAlignBits() const {
441 }
442
443 // NOTE: Maybe this should be set to 4-byte alignment, since DMA on Memtile
444 // seems to handle unaligned access.
445 /// Return the data bus width (in bits) for load/store operations of a memory
446 /// tile.
447 virtual uint32_t getMemTileLoadStoreBusWidth() const {
448 return 4 * 8; // Simply have buffer to be 4 byte aligned.
449 // Since 4 byte is the minimum access size for DMA.
450 // See discussion in
451 // https://github.com/Xilinx/mlir-aie/pull/3037#discussion_r3176686935
452 }
453
454 /// Return the size (in bits) of the accumulator/cascade.
455 virtual uint32_t getAccumulatorCascadeSize() const = 0;
456
457 /// Return the number of lock objects for a given tile type.
458 virtual uint32_t getNumLocks(AIETileType tileType) const = 0;
459
460 /// Return the number of lock objects for a tile at the given coordinates.
461 uint32_t getNumLocks(int col, int row) const {
462 return getNumLocks(getTileType(col, row));
463 }
464
465 /// Return the maximum value that can be stored in a lock register
466 virtual uint32_t getMaxLockValue() const = 0;
467
468 // Return the lock address for the lock ID in the local memory for a given
469 // tile or a nullopt if invalid arguments are given.
470 virtual std::optional<uint32_t> getLocalLockAddress(uint32_t lockId,
471 TileID tile) const = 0;
472
473 /// Return the size of the BD id space of a tile type (see getTotalNumBDs()).
474 virtual uint32_t getNumBDs(AIETileType tileType) const = 0;
475
476 /// Return the maximum number of addressing dimensions (wraps/strides) a
477 /// single buffer descriptor supports for a given tile type. This is the
478 /// hardware ND access-pattern limit; it does not count the separate shim
479 /// iteration/repeat dimension that runtime-sequence BD tasks hoist the
480 /// leading tap dimension into.
481 virtual uint32_t getBDMaxDims(AIETileType tileType) const = 0;
482
483 /// Return the maximum transfer length, measured in address-generation
484 /// granules (see getAddressGenGranularity(), 32-bit words on AIE2), that fits
485 /// in the buffer_length field of a DMA buffer descriptor for the given tile
486 /// type. The field width is tile-type specific (e.g. on AIE2 the shim field
487 /// is 32 bits, the mem-tile field 17 bits and the core-tile field 14 bits).
488 virtual uint64_t getDmaBdMaxLen(AIETileType tileType) const = 0;
489
490 /// Return the bit width of the wrap (size) field in a DMA buffer descriptor
491 /// for the given tile type. Used to compute the maximum legal wrap value
492 /// per dimension.
493 virtual uint32_t getDmaBdWrapBits(AIETileType tileType) const = 0;
494
495 /// Return the bit width of the step (stride) field in a DMA buffer
496 /// descriptor for the given tile type.
497 virtual uint32_t getDmaBdStepBits(AIETileType tileType) const = 0;
498
499 /// Return the bit width of the iteration (repeat) wrap/stride fields in a
500 /// DMA buffer descriptor for the given tile type.
501 virtual uint32_t getDmaBdIterBits(AIETileType tileType) const = 0;
502
503 /// Get stream switch port index for a given port specification
504 /// Return port index for Stream_Switch_Event_Port_Selection register, or
505 /// nullopt if invalid
506 virtual std::optional<uint32_t>
507 getStreamSwitchPortIndex(int col, int row, WireBundle bundle,
508 uint32_t channel, bool master) const = 0;
509
510 /// Return the number of buffer descriptors supported by the DMA in the given
511 /// tile.
512 uint32_t getNumBDs(int col, int row) const {
513 return getNumBDs(getTileType(col, row));
514 }
515
516 /// Return the maximum number of BD addressing dimensions for the tile at
517 /// (`col`, `row`).
518 uint32_t getBDMaxDims(int col, int row) const {
519 return getBDMaxDims(getTileType(col, row));
520 }
521
522 uint64_t getDmaBdMaxLen(int col, int row) const {
523 return getDmaBdMaxLen(getTileType(col, row));
524 }
525
526 uint32_t getDmaBdWrapBits(int col, int row) const {
527 return getDmaBdWrapBits(getTileType(col, row));
528 }
529
530 uint32_t getDmaBdStepBits(int col, int row) const {
531 return getDmaBdStepBits(getTileType(col, row));
532 }
533
534 uint32_t getDmaBdIterBits(int col, int row) const {
535 return getDmaBdIterBits(getTileType(col, row));
536 }
537
538 // BD pools: each channel and direction draws from one pool of ids
539 // [start, start + size) within [0, getNumBDs()). BDs in different pools are
540 // distinct even if their ids coincide. Default: one pool holding every BD.
541
542 /// Return the pool `channel` in direction `dir` draws its BDs from.
543 virtual uint32_t getBdPoolId(int col, int row, int channel,
544 DMAChannelDir dir) const {
545 return 0;
546 }
547
548 virtual uint32_t getBdPoolStartId(int col, int row, uint32_t poolId) const {
549 return 0;
550 }
551
552 virtual uint32_t getNumBDsInPool(int col, int row, uint32_t poolId) const {
553 return getNumBDs(col, row);
554 }
555
556 /// Physical BDs over all pools; exceeds getNumBDs() where pools reuse ids.
557 virtual uint32_t getTotalNumBDs(AIETileType tileType) const {
558 return getNumBDs(tileType);
559 }
560
561 uint32_t getTotalNumBDs(int col, int row) const {
562 return getTotalNumBDs(getTileType(col, row));
563 }
564
565 /// Return the half-open range of BD ids `channel` in `dir` can submit.
566 std::pair<uint32_t, uint32_t>
567 getBdIdRangeForChannel(int col, int row, int channel,
568 DMAChannelDir dir) const {
569 uint32_t pool = getBdPoolId(col, row, channel, dir);
570 uint32_t first = getBdPoolStartId(col, row, pool);
571 return {first, first + getNumBDsInPool(col, row, pool)};
572 }
573
574 uint32_t getNumBDsForChannel(int col, int row, int channel,
575 DMAChannelDir dir) const {
576 return getNumBDsInPool(col, row, getBdPoolId(col, row, channel, dir));
577 }
578
579 /// True iff `bd_id` is in the channel's pool, whether or not it exists.
580 bool isBdInChannelPool(int col, int row, uint32_t bd_id, int channel,
581 DMAChannelDir dir) const {
582 auto [first, last] = getBdIdRangeForChannel(col, row, channel, dir);
583 return bd_id >= first && bd_id < last;
584 }
585
586 bool isBdChannelAccessible(int col, int row, uint32_t bd_id, int channel,
587 DMAChannelDir dir) const {
588 return isDmaChannelSupported({col, row}, dir, channel) &&
589 isBdInChannelPool(col, row, bd_id, channel, dir);
590 }
591
592 /// True iff the channel exists and can submit `bd_id` in every direction it
593 /// has. Conservative on AIE4, where pools depend on direction.
594 bool isBdChannelAccessible(int col, int row, uint32_t bd_id,
595 int channel) const {
596 bool exists = false;
597 for (DMAChannelDir dir : {DMAChannelDir::MM2S, DMAChannelDir::S2MM}) {
598 if (!isDmaChannelSupported({col, row}, dir, channel))
599 continue;
600 if (!isBdChannelAccessible(col, row, bd_id, channel, dir))
601 return false;
602 exists = true;
603 }
604 return exists;
605 }
606
607 uint32_t getNumBDsForChannel(int col, int row, int channel) const {
608 uint32_t count = 0;
609 for (uint32_t bd = 0; bd < getNumBDs(col, row); ++bd)
610 if (isBdChannelAccessible(col, row, bd, channel))
611 ++count;
612 return count;
613 }
614
615 /// Return the register layout of a buffer descriptor on the given tile
616 /// type, or null if the target has none modeled for it.
617 virtual const DmaBdLayout *getDmaBdLayout(AIETileType tileType) const {
618 return nullptr;
619 }
620
621 const DmaBdLayout *getDmaBdLayout(int col, int row) const {
622 return getDmaBdLayout(getTileType(col, row));
623 }
624
625 /// Return the BD layout for `direction`; control and trace BDs may differ.
626 virtual const DmaBdLayout *getDmaBdLayout(AIETileType tileType,
627 DMAChannelDir direction) const {
628 return getDMAChannelBundle(direction) == WireBundle::DMA
629 ? getDmaBdLayout(tileType)
630 : nullptr;
631 }
632
633 const DmaBdLayout *getDmaBdLayout(int col, int row,
634 DMAChannelDir direction) const {
635 return getDmaBdLayout(getTileType(col, row), direction);
636 }
637
638 /// DmaBdLayout::stepBias, or 1 without a layout.
639 uint32_t getDmaBdStepBias(AIETileType tileType) const {
640 const DmaBdLayout *layout = getDmaBdLayout(tileType);
641 return layout ? layout->stepBias : 1;
642 }
643 uint32_t getDmaBdStepBias(int col, int row) const {
644 return getDmaBdStepBias(getTileType(col, row));
645 }
646
647 /// True if data BD ids are channel-local, so a BD's address depends on its
648 /// channel and direction.
649 virtual bool hasChannelLocalBdIds(int col, int row) const { return false; }
650
651 /// Control and trace channels always have private, channel-local pools.
652 bool usesChannelLocalBdIds(int col, int row, DMAChannelDir direction) const {
653 return hasChannelLocalBdIds(col, row) ||
654 getDMAChannelBundle(direction) != WireBundle::DMA;
655 }
656
657 /// Return the array address of the dma buffer descriptor for the given
658 /// col, row, buffer descriptor id, channel and direction. Not all
659 /// architecture variants will use channel and direction so these have default
660 /// values.
661 virtual uint64_t getDmaBdAddress(
662 int col, int row, uint32_t bd_id, int channel = -1,
663 AIE::DMAChannelDir direction = AIE::DMAChannelDir::MM2S) const = 0;
664
665 /// Return the offset of the base address field within the shim dma buffer
666 /// descriptor.
667 virtual uint32_t getDmaBdAddressOffset(int col, int row) const = 0;
668
669 /// Return the array address of the dma task queue register for the given
670 /// col, row, channel and direction
671 virtual uint32_t getDmaControlAddress(int col, int row, int channel,
672 AIE::DMAChannelDir direction) const = 0;
673
674 /// Return the address of the DMA status register for a channel, or nullopt
675 /// when this target's layout has not been verified. The register carries the
676 /// live task-queue occupancy in getDmaTaskQueueSizeMask(), which is the only
677 /// way to observe queue space: the queue does not backpressure, so a push
678 /// onto a full queue is dropped rather than stalled.
679 virtual std::optional<uint32_t>
680 getDmaStatusAddress(int /*col*/, int /*row*/, int /*channel*/,
681 AIE::DMAChannelDir /*direction*/) const {
682 return std::nullopt;
683 }
684
685 /// Return the mask selecting the live task-queue occupancy field within the
686 /// getDmaStatusAddress() register (0 when unsupported). The field does not
687 /// count the task the channel is running.
688 virtual uint32_t getDmaTaskQueueSizeMask() const { return 0; }
689
690 /// Return the bits of the getDmaStatusAddress() register that are all clear
691 /// exactly when the channel has finished every task pushed to it: nothing
692 /// queued, nothing running, nothing stalled (0 when unsupported).
693 virtual uint32_t getDmaChannelIdleMask() const { return 0; }
694
695 /// Return the array address of the task queue register a push writes, the
696 /// word after the channel's control register.
697 uint32_t getDmaQueueAddress(int col, int row, int channel,
698 AIE::DMAChannelDir direction) const {
699 return getDmaControlAddress(col, row, channel, direction) + 0x4;
700 }
701
702 /// Return the DMA task-queue register address relative to its tile.
703 uint32_t getLocalDmaControlAddress(int col, int row, int channel,
704 AIE::DMAChannelDir direction) const {
705 return getDmaControlAddress(col, row, channel, direction) -
706 getTileAddress(col, row);
707 }
708
709 virtual uint32_t getNumMemTileRows() const = 0;
710 /// Return the size (in bytes) of a MemTile.
711 virtual uint32_t getMemTileSize() const = 0;
712 /// Return the number of memory banks of a given tile.
713 virtual uint32_t getNumBanks(int col, int row) const = 0;
714
715 virtual uint32_t getMaxChannelNumForAdjacentMemTile(int col,
716 int row) const = 0;
717
718 /// Return the number of destinations of connections inside a switchbox. These
719 /// are the targets of connect operations in the switchbox.
720 virtual uint32_t getNumDestSwitchboxConnections(int col, int row,
721 WireBundle bundle) const = 0;
722 /// Return the number of sources of connections inside a switchbox. These are
723 /// the origins of connect operations in the switchbox.
724 virtual uint32_t
726 WireBundle bundle) const = 0;
727 /// Return the number of destinations of connections inside a shimmux. These
728 /// are the targets of connect operations in the switchbox.
729 virtual uint32_t getNumDestShimMuxConnections(int col, int row,
730 WireBundle bundle) const = 0;
731 /// Return the number of sources of connections inside a shimmux. These are
732 /// the origins of connect operations in the switchbox.
733 virtual uint32_t getNumSourceShimMuxConnections(int col, int row,
734 WireBundle bundle) const = 0;
735 /// True if the tile's DMA/NOC/PLIO ports sit behind an `aie.shim_mux`;
736 /// otherwise its DMA is routed in the switchbox like any other tile's.
737 virtual bool hasShimMux(int col, int row) const {
738 return isShimNOCorPLTile(col, row);
739 }
740 /// Return the number of DMA channels a tile has in one direction. An MM2S
741 /// channel feeds the stream switch, or the shim mux if the tile has one, so
742 /// it is counted by that switch's DMA sources; an S2MM channel by its DMA
743 /// destinations. Prefer this to the TileOp connection accessors, which are
744 /// named from the switch's side and so read the other way round. Control
745 /// and trace DMAs are counted on their own bundles.
746 uint32_t getNumDMAChannels(int col, int row, AIE::DMAChannelDir dir) const;
747
748 bool isDmaChannelSupported(TileID tile, AIE::DMAChannelDir dir,
749 int channel) const {
750 return channel >= 0 && static_cast<uint32_t>(channel) <
751 getNumDMAChannels(tile.col, tile.row, dir);
752 }
753
754 /// Return the number of packet-rule slots per stream-switch slave port.
755 virtual uint32_t getNumSlaveSlots() const = 0;
756 /// Return the number of arbiters per stream switch.
757 virtual uint32_t getNumArbiters() const = 0;
758 /// Return the number of master select values per stream-switch arbiter.
759 virtual uint32_t getNumMselsPerArbiter() const = 0;
760 /// Return the largest packet id the stream switch can route.
761 virtual uint32_t getMaxPacketId() const = 0;
762
763 /// Bits a packet id spans, and the mask a switch's id match uses.
764 int getPacketIdBits() const {
765 return llvm::Log2_32_Ceil(getMaxPacketId() + 1);
766 }
767 int getPacketIdMask() const { return (1 << getPacketIdBits()) - 1; }
768 /// Return the largest out-of-order BD id (unsupported = 0).
769 virtual uint32_t getMaxOutOfOrderId() const = 0;
770 /// Return the largest DMA task repeat count (unsupported = 0).
771 virtual uint32_t getMaxRepeatCount() const = 0;
772
773 /// Return how many DMA tasks a single channel's task queue holds
774 /// (unsupported = 0). Pushing to a full queue drops the push and sets the
775 /// channel's sticky Task_Queue_Overflow bit, stranding whoever waits on that
776 /// transfer. Flat rather than per-tile-type because aie-codegen's
777 /// XAie_DmaGetMaxQueueSize (XAIE_DMA_MAX_QUEUE_SIZE) returns the same depth
778 /// for every tile type and architecture.
779 virtual uint32_t getDmaTaskQueueDepth() const = 0;
780
781 /// Return the task-queue depth for one channel. The queue is a per-channel
782 /// resource in hardware, but no shipping target gives channels different
783 /// depths, so this forwards to the flat accessor; carrying the parameters
784 /// spares call sites churn if one ever does.
785 uint32_t getDmaTaskQueueDepth(int /*col*/, int /*row*/, int /*channel*/,
786 AIE::DMAChannelDir /*direction*/) const {
787 return getDmaTaskQueueDepth();
788 }
789
790 // Return true if the stream switch connection is legal, false otherwise.
791 virtual bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
792 int srcChan, WireBundle dstBundle,
793 int dstChan) const = 0;
794
795 // Run consistency checks on the target model.
796 void validate() const;
797
798 uint32_t getModelProperties() const { return ModelProperties; }
799 void addModelProperty(uint32_t prop) { ModelProperties |= prop; }
800 // Return true if this device has a given property.
801 bool hasProperty(ModelProperty Prop) const {
802 return (getModelProperties() & Prop) == Prop;
803 }
804
805 // Return the bit offset of the column within a tile address.
806 // This is used to compute the control address of a tile from it's column
807 // location.
808 virtual uint32_t getColumnShift() const = 0;
809
810 // Return the bit offset of the row within a tile address.
811 // This is used to compute the control address of a tile from it's row
812 // location.
813 virtual uint32_t getRowShift() const = 0;
814
815 /// Return the base address of the tile's window. Override together with
816 /// getRowFromAddress() if tiles span more than one address row.
817 virtual uint32_t getTileAddress(int col, int row) const {
818 return (static_cast<uint32_t>(col & 0xff) << getColumnShift()) |
819 (static_cast<uint32_t>(row & 0xff) << getRowShift());
820 }
821
822 uint32_t getRowFieldMask() const {
823 return (1u << (getColumnShift() - getRowShift())) - 1;
824 }
825
826 uint32_t getColumnFromAddress(uint32_t address) const {
827 return (address >> getColumnShift()) & 0xff;
828 }
829
830 /// Inverse of getTileAddress() for any address in the tile's window.
831 virtual uint32_t getRowFromAddress(uint32_t address) const {
832 return (address >> getRowShift()) & getRowFieldMask();
833 }
834
835 /// Offset of data memory in the tile's window; buffer addresses are
836 /// relative to it.
837 virtual uint32_t getDataMemoryOffset(int /*col*/, int /*row*/) const {
838 return 0;
839 }
840
841 // Returns the list of possible burst encodings (first) and
842 // their corresponding lengths in bytes (second).
843 virtual std::vector<std::pair<uint32_t, uint32_t>>
845
846 // Returns the default 4-bit AxCACHE value used for shim NOC DMA AXI-MM
847 // transfers when a `dma_bd`/`npu.writebd`'s `axcache` attribute is unset.
848 // Tuned to 2 to enable upsizing in the NoC; a target may override it.
849 virtual uint32_t getDefaultAxCache() const { return 2; }
850
851 // Returns true if the target model supports the given block format.
852 virtual bool isSupportedBlockFormat(std::string const &format) const;
853
854 // Returns true if the target supports a constant pad value on MemTile MM2S
855 // DMA channels (register=CONSTANT_PAD_VALUE).
856 virtual bool isMemTilePadValueSupported() const { return false; }
857
858 /// Register Database API - provides access to register and event information
859 /// for trace configuration and low-level register access.
860
861 /// Lookup register information by name and tile.
862 /// Return pointer to register info, or nullptr if not found
863 const RegisterInfo *lookupRegister(llvm::StringRef name, TileID tile,
864 bool isMem = false) const;
865
866 bool isOrdinaryWriteAddress(TileID tile, uint32_t offset) const;
867
868 /// Lookup event number by name and tile.
869 /// Return Event number if found, nullopt otherwise
870 std::optional<uint32_t> lookupEvent(llvm::StringRef name, TileID tile,
871 bool isMem = false) const;
872
873 /// Encode a field value with proper bit shifting.
874 /// Return nullopt if value does not fit in the field's bit width.
875 std::optional<uint32_t> encodeFieldValue(const BitFieldInfo &field,
876 uint32_t value) const;
877
878 /// Compute a 32-bit mask for a register field.
879 /// Return nullopt if the field does not fit in a 32-bit register.
880 std::optional<uint32_t> getFieldMask(const BitFieldInfo &field) const;
881
882 /// Return a mapping from tile coordinates to controller IDs.
883 /// When columnWiseUniqueIDs is true (default), IDs are unique within each
884 /// column. Otherwise they are globally unique across the device.
885 llvm::DenseMap<TileID, int>
886 getTileToControllerIdMap(bool columnWiseUniqueIDs = true) const;
887
888 /// Resolve stream switch port specification to port index.
889 /// Return Port index for stream switch register, or nullopt if invalid
890 std::optional<uint32_t> resolvePortValue(llvm::StringRef value, TileID tile,
891 bool master) const;
892};
893
895public:
897
898 AIEArch getTargetArch() const override;
899
900 uint32_t getNumSlaveSlots() const override { return 4; }
901 uint32_t getNumArbiters() const override { return 6; }
902 uint32_t getNumMselsPerArbiter() const override { return 4; }
903 uint32_t getMaxPacketId() const override { return 31; }
904 uint32_t getMaxOutOfOrderId() const override { return 0; }
905 uint32_t getMaxRepeatCount() const override { return 0; }
906 // AIE1 has no queued DMA-task model (BDs are started directly), so there is
907 // no queue to overflow.
908 uint32_t getDmaTaskQueueDepth() const override { return 0; }
909
910 std::optional<TileID> getMemWest(TileID src) const override;
911 std::optional<TileID> getMemEast(TileID src) const override;
912 std::optional<TileID> getMemNorth(TileID src) const override;
913 std::optional<TileID> getMemSouth(TileID src) const override;
914
915 bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override;
916 bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override;
917 bool isMemNorth(int srcCol, int srcRow, int dstCol,
918 int dstRow) const override;
919 bool isMemSouth(int srcCol, int srcRow, int dstCol,
920 int dstRow) const override;
921
922 bool isLegalMemAffinity(int coreCol, int coreRow, int memCol,
923 int memRow) const override;
924
925 uint32_t getMemInternalBaseAddress(TileID src) const override {
926 if (src.row % 2 == 0)
927 // Internal is West
928 return getMemWestBaseAddress();
929 // Internal is East
930 return getMemEastBaseAddress();
931 }
932
933 uint32_t getMemSouthBaseAddress() const override { return 0x00020000; }
934 uint32_t getMemWestBaseAddress() const override { return 0x00028000; }
935 uint32_t getMemNorthBaseAddress() const override { return 0x00030000; }
936 uint32_t getMemEastBaseAddress() const override { return 0x00038000; }
937 uint32_t getLocalMemorySize() const override { return 0x00008000; }
938 uint32_t getProgramMemorySize() const override { return 0x00004000; }
939 uint32_t getCoreDataAddressSpaceSize() const override { return 0x00100000; }
940 uint32_t getAccumulatorCascadeSize() const override { return 384; }
941 uint32_t getComputeTileLoadStoreBusWidth() const override { return 128; }
942 uint32_t getComputeTileMaxVectorAlignBits() const override { return 128; }
943
945 uint32_t getNumLocks(AIETileType tileType) const override {
946 return 16; // AIE1 has no MemTiles, always 16
947 }
948 uint32_t getMaxLockValue() const override { return 1; }
949 std::optional<uint32_t> getLocalLockAddress(uint32_t lockId,
950 TileID tile) const override;
951 uint32_t getNumBDs(AIETileType tileType) const override {
952 return 16; // AIE1 has no MemTiles, always 16
953 }
954 uint32_t getBDMaxDims(AIETileType tileType) const override {
955 // AIE1 has no MemTiles; preserve the historical BD dimension limit.
956 return 3;
957 }
958 uint64_t getDmaBdMaxLen(AIETileType tileType) const override {
959 // AIE1 has no mem tiles. Core tiles use a 13-bit length field with a +1
960 // hardware encoding (max 2^13 = 8192 32-bit words); shim tiles use a full
961 // 32-bit length register.
962 if (tileType == AIETileType::CoreTile)
963 return 1ull << 13;
964 return 0xFFFFFFFFull;
965 }
966 uint32_t getDmaBdWrapBits(AIETileType tileType) const override {
967 // AIE1 core tiles have 8-bit wrap fields; shim tiles have 10-bit.
968 return tileType == AIETileType::CoreTile ? 8 : 10;
969 }
970 uint32_t getDmaBdStepBits(AIETileType tileType) const override {
971 // AIE1 core tiles have 13-bit step fields; shim tiles have 20-bit.
972 return tileType == AIETileType::CoreTile ? 13 : 20;
973 }
974 uint32_t getDmaBdIterBits(AIETileType tileType) const override {
975 // AIE1 core and shim tiles both have a 6-bit Iteration_Wrap field.
976 return 6;
977 }
978 uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel,
979 AIE::DMAChannelDir direction) const override;
980
981 uint32_t getDmaBdAddressOffset(int col, int row) const override;
982
983 uint32_t getDmaControlAddress(int col, int row, int channel,
984 AIE::DMAChannelDir direction) const override;
985
986 uint32_t getNumMemTileRows() const override { return 0; }
987 uint32_t getMemTileSize() const override { return 0; }
988 uint32_t getNumBanks(int col, int row) const override { return 4; }
989
990 uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override {
991 return 0;
992 }
993
994 uint32_t getNumDestSwitchboxConnections(int col, int row,
995 WireBundle bundle) const override;
996 uint32_t getNumSourceSwitchboxConnections(int col, int row,
997 WireBundle bundle) const override;
998 uint32_t getNumDestShimMuxConnections(int col, int row,
999 WireBundle bundle) const override;
1000 uint32_t getNumSourceShimMuxConnections(int col, int row,
1001 WireBundle bundle) const override;
1002 bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
1003 int srcChan, WireBundle dstBundle,
1004 int dstChan) const override;
1005
1006 std::optional<uint32_t> getStreamSwitchPortIndex(int col, int row,
1007 WireBundle bundle,
1008 uint32_t port_num,
1009 bool master) const override;
1010
1011 uint32_t getColumnShift() const override { return 23; }
1012 uint32_t getRowShift() const override { return 18; }
1013
1014 static bool classof(const AIETargetModel *model) {
1015 return model->getKind() >= TK_AIE1_VC1902 &&
1016 model->getKind() < TK_AIE1_Last;
1017 }
1018
1019 std::vector<std::pair<uint32_t, uint32_t>>
1020 getShimBurstEncodingsAndLengths() const override;
1021};
1022
1024protected:
1025 std::unique_ptr<RegisterDatabase> loadRegisterDatabase() const override;
1026
1027public:
1036
1037 AIEArch getTargetArch() const override;
1038
1039 // Cascade input comes from the North or West, output goes South or East.
1040 llvm::ArrayRef<std::pair<int, int>> getCascadeSteps() const override {
1041 static constexpr std::pair<int, int> steps[] = {{0, -1}, {1, 0}};
1042 return steps;
1043 }
1044
1045 uint32_t getAddressGenGranularity() const override { return 32; }
1046
1047 uint32_t getNumSlaveSlots() const override { return 4; }
1048 uint32_t getNumArbiters() const override { return 6; }
1049 uint32_t getNumMselsPerArbiter() const override { return 4; }
1050 uint32_t getMaxPacketId() const override { return 31; }
1051 uint32_t getMaxOutOfOrderId() const override { return 63; }
1052 uint32_t getMaxRepeatCount() const override { return 255; }
1053 uint32_t getDmaTaskQueueDepth() const override { return 4; }
1054
1055 std::optional<TileID> getMemWest(TileID src) const override;
1056 std::optional<TileID> getMemEast(TileID src) const override;
1057 std::optional<TileID> getMemNorth(TileID src) const override;
1058 std::optional<TileID> getMemSouth(TileID src) const override;
1059
1060 bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override;
1061 bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override;
1062 bool isMemNorth(int srcCol, int srcRow, int dstCol,
1063 int dstRow) const override;
1064 bool isMemSouth(int srcCol, int srcRow, int dstCol,
1065 int dstRow) const override;
1066
1067 bool isLegalMemAffinity(int coreCol, int coreRow, int memCol,
1068 int memRow) const override;
1069
1070 uint32_t getMemInternalBaseAddress(TileID src) const override {
1071 return getMemEastBaseAddress();
1072 }
1073
1074 uint32_t getMemSouthBaseAddress() const override { return 0x00040000; }
1075 uint32_t getMemWestBaseAddress() const override { return 0x00050000; }
1076 uint32_t getMemNorthBaseAddress() const override { return 0x00060000; }
1077 uint32_t getMemEastBaseAddress() const override { return 0x00070000; }
1078 uint32_t getLocalMemorySize() const override { return 0x00010000; }
1079 uint32_t getProgramMemorySize() const override { return 0x00004000; }
1080 uint32_t getCoreDataAddressSpaceSize() const override { return 0x00100000; }
1081 uint32_t getAccumulatorCascadeSize() const override { return 512; }
1082 uint32_t getComputeTileLoadStoreBusWidth() const override { return 256; }
1083 uint32_t getComputeTileMaxVectorAlignBits() const override { return 256; }
1084
1086 uint32_t getNumLocks(AIETileType tileType) const override {
1087 return tileType == AIETileType::MemTile ? 64 : 16;
1088 }
1089
1090 uint32_t getMaxLockValue() const override { return 0x3F; }
1091
1092 std::optional<uint32_t> getLocalLockAddress(uint32_t lockId,
1093 TileID tile) const override;
1094
1095 uint32_t getNumBDs(AIETileType tileType) const override {
1096 return tileType == AIETileType::MemTile ? 48 : 16;
1097 }
1098 uint32_t getBDMaxDims(AIETileType tileType) const override {
1099 // MemTile BDs support 4 ND dimensions; core and shim BDs support 3.
1100 return tileType == AIETileType::MemTile ? 4 : 3;
1101 }
1102 // The field limits read off the BD layout the lowerings pack through, the
1103 // shim's for tiles without one.
1104 const DmaBdLayout &getDmaBdLimits(AIETileType tileType) const {
1105 const DmaBdLayout *layout = getDmaBdLayout(tileType);
1106 return layout ? *layout : *getDmaBdLayout(AIETileType::ShimNOCTile);
1107 }
1108 uint64_t getDmaBdMaxLen(AIETileType tileType) const override {
1109 return getDmaBdLimits(tileType).bufferLength.mask();
1110 }
1111 uint32_t getDmaBdWrapBits(AIETileType tileType) const override {
1112 return getDmaBdLimits(tileType).d0Size.width;
1113 }
1114 uint32_t getDmaBdStepBits(AIETileType tileType) const override {
1115 return getDmaBdLimits(tileType).d0Stride.width;
1116 }
1117 uint32_t getDmaBdIterBits(AIETileType tileType) const override {
1118 return getDmaBdLimits(tileType).iterationSize.width;
1119 }
1120
1121 /// Memtile: even channels use BDs 0-23, odd channels 24-47.
1122 uint32_t getBdPoolId(int col, int row, int channel,
1123 DMAChannelDir dir) const override {
1124 return isMemTile(col, row) ? channel & 1 : 0;
1125 }
1126 uint32_t getBdPoolStartId(int col, int row, uint32_t poolId) const override {
1127 return isMemTile(col, row) && poolId == 1 ? 24 : 0;
1128 }
1129 uint32_t getNumBDsInPool(int col, int row, uint32_t poolId) const override {
1130 return isMemTile(col, row) ? 24 : getNumBDs(getTileType(col, row));
1131 }
1132
1134 const DmaBdLayout *getDmaBdLayout(AIETileType tileType) const override;
1135
1136 uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel,
1137 AIE::DMAChannelDir direction) const override;
1138
1139 uint32_t getDmaBdAddressOffset(int col, int row) const override;
1140
1141 uint32_t getDmaControlAddress(int col, int row, int channel,
1142 AIE::DMAChannelDir direction) const override;
1143 std::optional<uint32_t>
1144 getDmaStatusAddress(int col, int row, int channel,
1145 AIE::DMAChannelDir direction) const override;
1146 // Task_Queue_Size, bits 22:20 of the DMA_{MM2S,S2MM}_Status_N register.
1147 uint32_t getDmaTaskQueueSizeMask() const override { return 0x7u << 20; }
1148 // Task_Queue_Size, Channel_Running (bit 19) and the four Stalled_* bits
1149 // (5:2): what aie-codegen's _XAieMl_DmaWaitForDone polls clear. aie-codegen's
1150 // pending count adds one to Task_Queue_Size for Channel_Running or a stall,
1151 // which is why the field alone does not cover the running task.
1152 uint32_t getDmaChannelIdleMask() const override {
1153 return getDmaTaskQueueSizeMask() | (1u << 19) | 0x3Cu;
1154 }
1155
1156 uint32_t getMemTileSize() const override { return 0x00080000; }
1157
1158 uint32_t getNumBanks(int col, int row) const override {
1159 return getTileType(col, row) == AIETileType::MemTile ? 8 : 4;
1160 }
1161
1162 uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override {
1163 return 4;
1164 }
1165
1166 uint32_t getNumDestSwitchboxConnections(int col, int row,
1167 WireBundle bundle) const override;
1168 uint32_t getNumSourceSwitchboxConnections(int col, int row,
1169 WireBundle bundle) const override;
1170 uint32_t getNumDestShimMuxConnections(int col, int row,
1171 WireBundle bundle) const override;
1172 uint32_t getNumSourceShimMuxConnections(int col, int row,
1173 WireBundle bundle) const override;
1174 bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
1175 int srcChan, WireBundle dstBundle,
1176 int dstChan) const override;
1177
1178 std::optional<uint32_t> getStreamSwitchPortIndex(int col, int row,
1179 WireBundle bundle,
1180 uint32_t port_num,
1181 bool master) const override;
1182
1183 uint32_t getColumnShift() const override { return 25; }
1184 uint32_t getRowShift() const override { return 20; }
1185
1186 static bool classof(const AIETargetModel *model) {
1187 return model->getKind() >= TK_AIE2_VE2302 &&
1188 model->getKind() < TK_AIE2_Last;
1189 }
1190
1191 std::vector<std::pair<uint32_t, uint32_t>>
1192 getShimBurstEncodingsAndLengths() const override;
1193};
1194
1195// AIE2PS base model
1197public:
1199 // AIE2PS is an NPU but uses CERT ELF, not CDO/xclbin.
1201 }
1202
1203 AIEArch getTargetArch() const override { return AIEArch::AIE2ps; }
1204 // AIE2P/AIE2PS: a full-width (512-bit) vector access requires 512-bit
1205 // alignment, stricter than the 256-bit load/store bus. See aie_api's
1206 // vector_ldst_align for __AIE_ARCH__ 21/22.
1207 uint32_t getComputeTileMaxVectorAlignBits() const override { return 512; }
1208
1209 uint32_t getNumControllersPerColumn() const override { return 1; }
1210
1211 // AIE2PS supports 512B burst (same as AIE2P)
1212 std::vector<std::pair<uint32_t, uint32_t>>
1214 return {std::pair(0, 64), std::pair(1, 128), std::pair(2, 256),
1215 std::pair(3, 512)};
1216 }
1217
1218 // TODO(aie2ps): AIE2PS changed block floating point from bfp16 to
1219 // MX9/MX6/MX4. isSupportedBlockFormat() currently returns false (inherited).
1220 // Override with correct MX format strings when ML kernels need it.
1221
1222 uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel,
1223 AIE::DMAChannelDir direction) const override;
1224 uint32_t getDmaControlAddress(int col, int row, int channel,
1225 AIE::DMAChannelDir direction) const override;
1226 std::optional<uint32_t>
1227 getDmaStatusAddress(int col, int row, int channel,
1228 AIE::DMAChannelDir direction) const override;
1229
1230 uint32_t getNumDestSwitchboxConnections(int col, int row,
1231 WireBundle bundle) const override;
1232 uint32_t getNumSourceSwitchboxConnections(int col, int row,
1233 WireBundle bundle) const override;
1234 std::optional<uint32_t> getStreamSwitchPortIndex(int col, int row,
1235 WireBundle bundle,
1236 uint32_t channel,
1237 bool master) const override;
1238
1239 static bool classof(const AIETargetModel *model) {
1240 return model->getKind() >= TK_AIE2PS_VE3858 &&
1241 model->getKind() < TK_AIE2PS_Last;
1242 }
1243};
1244
1245// VE3858 target model (AIE2PS, xc2ve3858 on VEK385)
1246// 36 columns, 7 rows: 1 shim + 2 memtile + 4 core
1248public:
1250
1251 int columns() const override { return 36; }
1252 int rows() const override { return 7; }
1253
1254 // AIE2PS Shim-South tiles (cols 1-23) have both NoC and PL.
1255 // Shim-Global (col 0) has NoC only. Modeling all as ShimNOC is a working
1256 // approximation for the CERT compilation path.
1257 AIETileType getTileType(int col, int row) const override {
1258 if (row == 0)
1259 return AIETileType::ShimNOCTile;
1260 if (row <= 2)
1261 return AIETileType::MemTile;
1262 return AIETileType::CoreTile;
1263 }
1264
1265 uint32_t getNumMemTileRows() const override { return 2; }
1266
1267 static bool classof(const AIETargetModel *model) {
1268 return model->getKind() == TK_AIE2PS_VE3858;
1269 }
1270};
1271
1273 llvm::SmallDenseSet<unsigned, 16> nocColumns = {
1274 2, 3, 6, 7, 10, 11, 18, 19, 26, 27, 34, 35, 42, 43, 46, 47};
1275
1276public:
1278
1279 uint32_t getAddressGenGranularity() const override { return 32; }
1280
1281 int columns() const override { return 50; }
1282
1283 int rows() const override { return 9; /* One Shim row and 8 Core rows. */ }
1284
1285 AIETileType getTileType(int col, int row) const override {
1286 if (row == 0) {
1287 return nocColumns.contains(col) ? AIETileType::ShimNOCTile
1288 : AIETileType::ShimPLTile;
1289 }
1290 return AIETileType::CoreTile; // AIE1 has no MemTiles
1291 }
1292
1293 static bool classof(const AIETargetModel *model) {
1294 return model->getKind() == TK_AIE1_VC1902;
1295 }
1296};
1297
1299 llvm::SmallDenseSet<unsigned, 8> nocColumns = {2, 3, 6, 7, 10, 11};
1300
1301public:
1303
1304 int columns() const override { return 17; }
1305
1306 int rows() const override {
1307 return 4; /* One Shim row, 1 memtile rows, and 2 Core rows. */
1308 }
1309
1310 AIETileType getTileType(int col, int row) const override {
1311 if (row == 0) {
1312 return nocColumns.contains(col) ? AIETileType::ShimNOCTile
1313 : AIETileType::ShimPLTile;
1314 }
1315 if (row == 1)
1316 return AIETileType::MemTile;
1317 return AIETileType::CoreTile;
1318 }
1319
1320 uint32_t getNumMemTileRows() const override { return 1; }
1321
1322 static bool classof(const AIETargetModel *model) {
1323 return model->getKind() == TK_AIE2_VE2302;
1324 }
1325};
1326
1328 llvm::SmallDenseSet<unsigned, 16> nocColumns = {2, 3, 6, 7, 14, 15,
1329 22, 23, 30, 31, 34, 35};
1330
1331public:
1333
1334 int columns() const override { return 38; }
1335
1336 int rows() const override {
1337 return 11; /* One Shim row, 2 memtile rows, and 8 Core rows. */
1338 }
1339
1340 AIETileType getTileType(int col, int row) const override {
1341 if (row == 0) {
1342 return nocColumns.contains(col) ? AIETileType::ShimNOCTile
1343 : AIETileType::ShimPLTile;
1344 }
1345 if (row == 1 || row == 2)
1346 return AIETileType::MemTile;
1347 return AIETileType::CoreTile;
1348 }
1349
1350 uint32_t getNumMemTileRows() const override { return 2; }
1351
1352 static bool classof(const AIETargetModel *model) {
1353 return model->getKind() == TK_AIE2_VE2802;
1354 }
1355};
1356
1358public:
1362
1363 int rows() const override {
1364 return 6; /* 1 Shim row, 1 memtile row, and 4 Core rows. */
1365 }
1366
1367 int physicalColumns() const override { return 4; }
1368
1369 uint32_t getNumMemTileRows() const override { return 1; }
1370
1371 uint32_t getNumControllers() const override { return 1; }
1372
1373 static bool classof(const AIETargetModel *model) {
1374 return model->getKind() >= TK_AIE2_NPU1_1Col &&
1375 model->getKind() < TK_AIE2_NPU1_Last;
1376 }
1377};
1378
1379// A sub-portion of the Phoenix NPU
1381 int cols;
1382
1383public:
1385 : BaseNPU1TargetModel(static_cast<TargetModelKind>(
1386 static_cast<std::underlying_type_t<TargetModelKind>>(
1388 _cols - 1)),
1389 cols(_cols) {
1390 // Device properties initialization
1392 }
1393
1394 int columns() const override { return cols; }
1395
1396 AIETileType getTileType(int col, int row) const override {
1397 if (row == 0)
1398 return AIETileType::ShimNOCTile; // NPU1 has no ShimPL tiles
1399 if (row == 1)
1400 return AIETileType::MemTile;
1401 return AIETileType::CoreTile;
1402 }
1403
1404 static bool classof(const AIETargetModel *model) {
1405 return model->getKind() >= TK_AIE2_NPU1_1Col &&
1406 model->getKind() < TK_AIE2_NPU1_Last;
1407 }
1408};
1409
1411public:
1415
1416 AIEArch getTargetArch() const override;
1417 // AIE2P/AIE2PS: a full-width (512-bit) vector access requires 512-bit
1418 // alignment, stricter than the 256-bit load/store bus. See aie_api's
1419 // vector_ldst_align for __AIE_ARCH__ 21/22.
1420 uint32_t getComputeTileMaxVectorAlignBits() const override { return 512; }
1421
1422 int rows() const override {
1423 return 6; /* 1 Shim row, 1 memtile row, and 4 Core rows. */
1424 }
1425
1426 int physicalColumns() const override { return 8; }
1427
1428 AIETileType getTileType(int col, int row) const override {
1429 if (row == 0)
1430 return AIETileType::ShimNOCTile;
1431 if (row == 1)
1432 return AIETileType::MemTile;
1433 return AIETileType::CoreTile;
1434 }
1435
1436 uint32_t getNumMemTileRows() const override { return 1; }
1437
1438 std::vector<std::pair<uint32_t, uint32_t>>
1439 getShimBurstEncodingsAndLengths() const override;
1440
1441 bool isSupportedBlockFormat(std::string const &format) const override;
1442
1443 bool isMemTilePadValueSupported() const override { return true; }
1444
1445 uint32_t getNumControllers() const override { return 1; }
1446
1447 static bool classof(const AIETargetModel *model) {
1448 return model->getKind() >= TK_AIE2_NPU2 &&
1449 model->getKind() < TK_AIE2_NPU2_Last;
1450 }
1451};
1452
1453// The full Strix NPU
1455public:
1457
1458 int columns() const override { return 8; }
1459
1460 static bool classof(const AIETargetModel *model) {
1461 return model->getKind() == TK_AIE2_NPU2;
1462 }
1463};
1464
1465// A sub-portion of the Strix NPU
1467 int cols;
1468
1469public:
1471 : BaseNPU2TargetModel(static_cast<TargetModelKind>(
1472 static_cast<std::underlying_type_t<TargetModelKind>>(TK_AIE2_NPU2) +
1473 _cols)),
1474 cols(_cols) {
1475 // Device properties initialization
1477 }
1478
1479 int columns() const override { return cols; }
1480
1481 static bool classof(const AIETargetModel *model) {
1482 return model->getKind() >= TK_AIE2_NPU2_1Col &&
1483 model->getKind() < TK_AIE2_NPU2_Last;
1484 }
1485};
1486
1487/// AIE4 (npu3) base model. Reports "unsupported" where the API cannot yet
1488/// describe AIE4 rather than an AIE2-shaped answer.
1490protected:
1491 std::unique_ptr<RegisterDatabase> loadRegisterDatabase() const override;
1492
1493public:
1501
1502 AIEArch getTargetArch() const override;
1503
1504 llvm::ArrayRef<std::pair<int, int>> getCascadeSteps() const override {
1505 static constexpr std::pair<int, int> steps[] = {{0, -1}, {1, 0}};
1506 return steps;
1507 }
1508
1509 uint32_t getAddressGenGranularity() const override { return 32; }
1510
1511 uint32_t getNumSlaveSlots() const override { return 4; }
1512 uint32_t getNumArbiters() const override { return 6; }
1513 uint32_t getNumMselsPerArbiter() const override { return 4; }
1514 uint32_t getMaxPacketId() const override { return 31; }
1515 /// 4-bit index into the receiving channel's 16-BD bank.
1516 uint32_t getMaxOutOfOrderId() const override { return 15; }
1517 uint32_t getMaxRepeatCount() const override { return 4095; }
1518 /// Not modelled yet.
1519 uint32_t getDmaTaskQueueDepth() const override { return 0; }
1520
1521 uint32_t getNumControllersPerColumn() const override { return 2; }
1522
1523 /// A core reaches only its own data memory, through the east window.
1524 std::optional<TileID> getMemWest(TileID) const override {
1525 return std::nullopt;
1526 }
1527 std::optional<TileID> getMemEast(TileID src) const override;
1528 std::optional<TileID> getMemNorth(TileID) const override {
1529 return std::nullopt;
1530 }
1531 std::optional<TileID> getMemSouth(TileID) const override {
1532 return std::nullopt;
1533 }
1534
1535 bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override;
1536 bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override;
1537 bool isMemNorth(int srcCol, int srcRow, int dstCol,
1538 int dstRow) const override;
1539 bool isMemSouth(int srcCol, int srcRow, int dstCol,
1540 int dstRow) const override;
1541
1542 bool isLegalMemAffinity(int coreCol, int coreRow, int memCol,
1543 int memRow) const override;
1544
1545 uint32_t getMemInternalBaseAddress(TileID src) const override {
1546 return getMemEastBaseAddress();
1547 }
1548 uint32_t getMemSouthBaseAddress() const override { return 0x00080000; }
1549 uint32_t getMemWestBaseAddress() const override { return 0x000A0000; }
1550 uint32_t getMemNorthBaseAddress() const override { return 0x000C0000; }
1551 uint32_t getMemEastBaseAddress() const override { return 0x000E0000; }
1552 uint32_t getLocalMemorySize() const override { return 0x00020000; }
1553 uint32_t getProgramMemorySize() const override { return 0x00008000; }
1554 uint32_t getCoreDataAddressSpaceSize() const override { return 0x00100000; }
1555 uint32_t getComputeTileLoadStoreBusWidth() const override { return 1024; }
1556 uint32_t getAccumulatorCascadeSize() const override { return 512; }
1557
1559 uint32_t getNumLocks(AIETileType tileType) const override {
1560 if (tileType == AIETileType::MemTile)
1561 return 64;
1562 if (tileType == AIETileType::ShimNOCTile)
1563 return 32;
1564 return 16;
1565 }
1566 uint32_t getMaxLockValue() const override { return 0x3F; }
1567 std::optional<uint32_t> getLocalLockAddress(uint32_t lockId,
1568 TileID tile) const override;
1569
1570 /// A memtile DMA reaches the locks and memory of the 15 memtiles within
1571 /// seven columns, westmost first; data windows start at 0xB00000.
1572 std::optional<uint32_t> getLockLocalBaseIndex(int localCol, int localRow,
1573 int lockCol,
1574 int lockRow) const override;
1575 std::optional<uint32_t> getMemLocalBaseAddress(int localCol, int localRow,
1576 int memCol,
1577 int memRow) const override;
1578
1579 /// 16 ids per core tile or memtile channel pool; 32 across two shim banks.
1580 uint32_t getNumBDs(AIETileType tileType) const override {
1581 return tileType == AIETileType::ShimNOCTile ? 32 : 16;
1582 }
1583 /// Memtile: 16 BDs per each of 10 MM2S + 8 S2MM channels. Shim: 32 data,
1584 /// 8 per ControlMM2S channel and 4 for TraceS2MM.
1585 uint32_t getTotalNumBDs(AIETileType tileType) const override {
1586 if (tileType == AIETileType::MemTile)
1587 return 16 * (10 + 8);
1588 if (tileType == AIETileType::ShimNOCTile)
1589 return 32 + 2 * 8 + 4;
1590 return getNumBDs(tileType);
1591 }
1592
1593 /// Shim: MM2S 0-1 and S2MM 0 use BDs 0-15, MM2S 2-3 and S2MM 1 BDs 16-31;
1594 /// ControlMM2S (8) and TraceS2MM (4) have private pools. Memtile: a private
1595 /// 16-BD pool per channel and direction.
1596 uint32_t getBdPoolId(int col, int row, int channel,
1597 DMAChannelDir dir) const override;
1598 uint32_t getBdPoolStartId(int col, int row, uint32_t poolId) const override;
1599 uint32_t getNumBDsInPool(int col, int row, uint32_t poolId) const override;
1600 bool hasChannelLocalBdIds(int col, int row) const override {
1601 return isMemTile(col, row);
1602 }
1603 uint32_t getBDMaxDims(AIETileType tileType) const override {
1604 return tileType == AIETileType::CoreTile ? 3 : 4;
1605 }
1606 /// Core BDs are 6 words, memtile 11, shim 9. Steps are unbiased and there is
1607 /// no d0 step. Control/trace BDs are shim BDs without dimensions or locks.
1609 const DmaBdLayout *getDmaBdLayout(AIETileType tileType) const override;
1610 const DmaBdLayout *getDmaBdLayout(AIETileType tileType,
1611 DMAChannelDir direction) const override;
1612 /// Field limits from the BD layout; the shim's for tiles without one.
1613 const DmaBdLayout &getDmaBdLimits(AIETileType tileType) const {
1614 const DmaBdLayout *layout = getDmaBdLayout(tileType);
1615 return layout ? *layout : *getDmaBdLayout(AIETileType::ShimNOCTile);
1616 }
1617 uint64_t getDmaBdMaxLen(AIETileType tileType) const override {
1618 return getDmaBdLimits(tileType).bufferLength.mask();
1619 }
1620 uint32_t getDmaBdWrapBits(AIETileType tileType) const override {
1621 return getDmaBdLimits(tileType).d0Size.width;
1622 }
1623 uint32_t getDmaBdStepBits(AIETileType tileType) const override {
1624 return getDmaBdLimits(tileType).d1Stride.width;
1625 }
1626 uint32_t getDmaBdIterBits(AIETileType tileType) const override {
1627 return getDmaBdLimits(tileType).iterationSize.width;
1628 }
1629
1630 /// Shim data BDs need no channel; control, trace and memtile BDs do (fatal
1631 /// error without one).
1632 uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel,
1633 AIE::DMAChannelDir direction) const override;
1634 uint32_t getDmaBdAddressOffset(int col, int row) const override;
1635 uint32_t getDmaControlAddress(int col, int row, int channel,
1636 AIE::DMAChannelDir direction) const override;
1637
1638 uint32_t getMemTileSize() const override { return 0x00300000; }
1639 uint32_t getNumBanks(int col, int row) const override {
1640 return isMemTile(col, row) ? 24 : 4;
1641 }
1642 uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override {
1643 return 10;
1644 }
1645
1646 uint32_t getNumDestSwitchboxConnections(int col, int row,
1647 WireBundle bundle) const override;
1648 uint32_t getNumSourceSwitchboxConnections(int col, int row,
1649 WireBundle bundle) const override;
1650 uint32_t getNumDestShimMuxConnections(int col, int row,
1651 WireBundle bundle) const override;
1652 uint32_t getNumSourceShimMuxConnections(int col, int row,
1653 WireBundle bundle) const override;
1654 bool hasShimMux(int col, int row) const override { return false; }
1655 bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
1656 int srcChan, WireBundle dstBundle,
1657 int dstChan) const override;
1658
1659 /// Not modelled yet.
1660 std::optional<uint32_t> getStreamSwitchPortIndex(int col, int row,
1661 WireBundle bundle,
1662 uint32_t channel,
1663 bool master) const override {
1664 return std::nullopt;
1665 }
1666
1667 uint32_t getColumnShift() const override { return 25; }
1668 uint32_t getRowShift() const override { return 20; }
1669
1670 std::vector<std::pair<uint32_t, uint32_t>>
1671 getShimBurstEncodingsAndLengths() const override;
1672 /// AxCACHE 0 is the hardware-proven value on AIE4.
1673 uint32_t getDefaultAxCache() const override { return 0; }
1674
1675 /// A memtile spans five address rows (registers, then 4 MiB of data), so
1676 /// memtile row m starts at address row 5m-4 and core row r at r + 4 * the
1677 /// number of memtile rows.
1678 uint32_t getTileAddress(int col, int row) const override;
1679 uint32_t getRowFromAddress(uint32_t address) const override;
1680 /// A memtile's data memory starts 1 MiB into its window.
1681 uint32_t getDataMemoryOffset(int col, int row) const override;
1682
1683 static bool classof(const AIETargetModel *model) {
1684 return model->getKind() >= TK_AIE4_NPU3 && model->getKind() < TK_AIE4_Last;
1685 }
1686};
1687
1689public:
1693
1694 int rows() const override {
1695 return 6; /* 1 Shim row, 1 memtile row, and 4 Core rows. */
1696 }
1697
1698 AIETileType getTileType(int col, int row) const override {
1699 if (row == 0)
1700 return AIETileType::ShimNOCTile;
1701 if (row <= static_cast<int>(getNumMemTileRows()))
1702 return AIETileType::MemTile;
1703 return AIETileType::CoreTile;
1704 }
1705
1706 uint32_t getNumMemTileRows() const override { return 1; }
1707
1708 static bool classof(const AIETargetModel *model) {
1709 return model->getKind() >= TK_AIE4_NPU3 &&
1710 model->getKind() < TK_AIE4_NPU3_Last;
1711 }
1712};
1713
1714// The full npu3 array.
1716public:
1718
1719 int columns() const override { return 3; }
1720
1721 static bool classof(const AIETargetModel *model) {
1722 return model->getKind() == TK_AIE4_NPU3;
1723 }
1724};
1725
1726// A sub-portion of the npu3 array.
1728 int cols;
1729
1730public:
1732 : BaseNPU3TargetModel(static_cast<TargetModelKind>(
1733 static_cast<std::underlying_type_t<TargetModelKind>>(TK_AIE4_NPU3) +
1734 _cols)),
1735 cols(_cols) {
1737 }
1738
1739 int columns() const override { return cols; }
1740
1741 static bool classof(const AIETargetModel *model) {
1742 return model->getKind() >= TK_AIE4_NPU3_1Col &&
1743 model->getKind() < TK_AIE4_NPU3_Last;
1744 }
1745};
1746
1747/// \brief Device generation ID written into the TXN header
1748/// (aie_runtime::TxnDeviceInfo::devGen). Both the static binary emitter and the
1749/// generated-C++ builder read it from here, so a new device family is one edit.
1750inline uint8_t txnDeviceGen(const AIETargetModel &tm) {
1751 if (llvm::isa<AIE4TargetModel>(tm))
1752 return 42; // XAIE_DEV_GEN_AIE4
1753 return llvm::isa<BaseNPU2TargetModel>(tm) ? 4 : 3;
1754}
1755
1756} // namespace xilinx::AIE
1757
1758namespace llvm {
1759template <>
1760struct DenseMapInfo<xilinx::AIE::TileID> {
1761 using FirstInfo = DenseMapInfo<int>;
1762 using SecondInfo = DenseMapInfo<int>;
1763
1764 static unsigned getHashValue(const xilinx::AIE::TileID &t) {
1765 return detail::combineHashValue(FirstInfo::getHashValue(t.col),
1766 SecondInfo::getHashValue(t.row));
1767 }
1768
1769 static bool isEqual(const xilinx::AIE::TileID &lhs,
1770 const xilinx::AIE::TileID &rhs) {
1771 return lhs == rhs;
1772 }
1773};
1774} // namespace llvm
1775
1776template <>
1777struct std::hash<xilinx::AIE::TileID> {
1778 std::size_t operator()(const xilinx::AIE::TileID &s) const noexcept {
1779 std::size_t h1 = std::hash<int>{}(s.col);
1780 std::size_t h2 = std::hash<int>{}(s.row);
1781 return h1 ^ (h2 << 1);
1782 }
1783};
1784
1785#endif
uint32_t getLocalMemorySize() const override
Return the size (in bytes) of the local data memory of a core.
uint32_t getDmaBdIterBits(AIETileType tileType) const override
Return the bit width of the iteration (repeat) wrap/stride fields in a DMA buffer descriptor for the ...
uint32_t getNumMemTileRows() const override
uint32_t getMaxOutOfOrderId() const override
Return the largest out-of-order BD id (unsupported = 0).
bool isMemNorth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is North of dst.
uint32_t getMemWestBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getNumBanks(int col, int row) const override
Return the number of memory banks of a given tile.
uint64_t getDmaBdMaxLen(AIETileType tileType) const override
Return the maximum transfer length, measured in address-generation granules (see getAddressGenGranula...
uint32_t getDmaBdWrapBits(AIETileType tileType) const override
Return the bit width of the wrap (size) field in a DMA buffer descriptor for the given tile type.
uint32_t getDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma task queue register for the given col, row, channel and direction...
std::optional< TileID > getMemSouth(TileID src) const override
Return the tile ID of the memory to the south of the given tile, if it exists.
std::optional< uint32_t > getLocalLockAddress(uint32_t lockId, TileID tile) const override
uint32_t getCoreDataAddressSpaceSize() const override
Return the size (in bytes) of the address space a core can issue data accesses into.
uint32_t getProgramMemorySize() const override
Return the size (in bytes) of a core's program memory.
static bool classof(const AIETargetModel *model)
std::optional< TileID > getMemNorth(TileID src) const override
Return the tile ID of the memory to the north of the given tile, if it exists.
uint32_t getMemInternalBaseAddress(TileID src) const override
Return the base address in the local address map for a core.
std::optional< uint32_t > getStreamSwitchPortIndex(int col, int row, WireBundle bundle, uint32_t port_num, bool master) const override
Get stream switch port index for a given port specification Return port index for Stream_Switch_Event...
uint32_t getDmaTaskQueueDepth() const override
Return how many DMA tasks a single channel's task queue holds (unsupported = 0).
uint32_t getDmaBdStepBits(AIETileType tileType) const override
Return the bit width of the step (stride) field in a DMA buffer descriptor for the given tile type.
bool isMemSouth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is South of dst.
uint32_t getMemEastBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getMaxRepeatCount() const override
Return the largest DMA task repeat count (unsupported = 0).
std::optional< TileID > getMemWest(TileID src) const override
Return the tile ID of the memory to the west of the given tile, if it exists.
bool isLegalMemAffinity(int coreCol, int coreRow, int memCol, int memRow) const override
Return true if core can access the memory in mem.
uint32_t getNumMselsPerArbiter() const override
Return the number of master select values per stream-switch arbiter.
uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma buffer descriptor for the given col, row, buffer descriptor id,...
uint32_t getRowShift() const override
uint32_t getBDMaxDims(AIETileType tileType) const override
Return the maximum number of addressing dimensions (wraps/strides) a single buffer descriptor support...
uint32_t getNumArbiters() const override
Return the number of arbiters per stream switch.
uint32_t getNumSlaveSlots() const override
Return the number of packet-rule slots per stream-switch slave port.
uint32_t getNumSourceShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a shimmux.
uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a switchbox.
uint32_t getColumnShift() const override
bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is East of dst.
uint32_t getComputeTileMaxVectorAlignBits() const override
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is West of dst.
uint32_t getNumLocks(AIETileType tileType) const override
Return the number of lock objects for a given tile type.
uint32_t getDmaBdAddressOffset(int col, int row) const override
Return the offset of the base address field within the shim dma buffer descriptor.
uint32_t getComputeTileLoadStoreBusWidth() const override
Return the data bus width (in bits) for load/store operations of a compute core.
uint32_t getAccumulatorCascadeSize() const override
Return the size (in bits) of the accumulator/cascade.
AIE1TargetModel(TargetModelKind k)
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
uint32_t getMemTileSize() const override
Return the size (in bytes) of a MemTile.
uint32_t getMemSouthBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override
AIEArch getTargetArch() const override
AIE1 TargetModel.
uint32_t getNumDestShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a shimmux.
uint32_t getMemNorthBaseAddress() const override
Return the base address in the local address map for a core.
std::optional< TileID > getMemEast(TileID src) const override
Return the tile ID of the memory to the east of the given tile, if it exists.
uint32_t getNumBDs(AIETileType tileType) const override
Return the size of the BD id space of a tile type (see getTotalNumBDs()).
bool isLegalTileConnection(int col, int row, WireBundle srcBundle, int srcChan, WireBundle dstBundle, int dstChan) const override
uint32_t getMaxLockValue() const override
Return the maximum value that can be stored in a lock register.
uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a switchbox.
uint32_t getMaxPacketId() const override
Return the largest packet id the stream switch can route.
uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a switchbox.
uint32_t getDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma task queue register for the given col, row, channel and direction...
uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a switchbox.
AIEArch getTargetArch() const override
Return the target architecture.
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
std::optional< uint32_t > getDmaStatusAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the address of the DMA status register for a channel, or nullopt when this target's layout has...
uint32_t getNumControllersPerColumn() const override
Number of microcontrollers (uC) per column.
uint32_t getComputeTileMaxVectorAlignBits() const override
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma buffer descriptor for the given col, row, buffer descriptor id,...
std::optional< uint32_t > getStreamSwitchPortIndex(int col, int row, WireBundle bundle, uint32_t channel, bool master) const override
Get stream switch port index for a given port specification Return port index for Stream_Switch_Event...
AIE2PSTargetModel(TargetModelKind k)
static bool classof(const AIETargetModel *model)
uint32_t getRowShift() const override
uint32_t getMemWestBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getMemSouthBaseAddress() const override
Return the base address in the local address map for a core.
bool isLegalTileConnection(int col, int row, WireBundle srcBundle, int srcChan, WireBundle dstBundle, int dstChan) const override
uint32_t getBdPoolStartId(int col, int row, uint32_t poolId) const override
llvm::ArrayRef< std::pair< int, int > > getCascadeSteps() const override
The steps (destination column - source column, destination row - source row) from one core's cascade ...
uint32_t getNumMselsPerArbiter() const override
Return the number of master select values per stream-switch arbiter.
uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a switchbox.
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
uint32_t getComputeTileMaxVectorAlignBits() const override
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
uint32_t getCoreDataAddressSpaceSize() const override
Return the size (in bytes) of the address space a core can issue data accesses into.
uint32_t getNumLocks(AIETileType tileType) const override
Return the number of lock objects for a given tile type.
std::optional< uint32_t > getDmaStatusAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the address of the DMA status register for a channel, or nullopt when this target's layout has...
uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override
uint32_t getAddressGenGranularity() const override
Return the data bus width of the device.
std::optional< TileID > getMemWest(TileID src) const override
Return the tile ID of the memory to the west of the given tile, if it exists.
std::optional< uint32_t > getStreamSwitchPortIndex(int col, int row, WireBundle bundle, uint32_t port_num, bool master) const override
Get stream switch port index for a given port specification Return port index for Stream_Switch_Event...
uint32_t getAccumulatorCascadeSize() const override
Return the size (in bits) of the accumulator/cascade.
uint32_t getMaxRepeatCount() const override
Return the largest DMA task repeat count (unsupported = 0).
std::unique_ptr< RegisterDatabase > loadRegisterDatabase() const override
AIE2 TargetModel.
uint32_t getNumBDsInPool(int col, int row, uint32_t poolId) const override
uint32_t getDmaBdIterBits(AIETileType tileType) const override
Return the bit width of the iteration (repeat) wrap/stride fields in a DMA buffer descriptor for the ...
AIEArch getTargetArch() const override
Return the target architecture.
bool isLegalMemAffinity(int coreCol, int coreRow, int memCol, int memRow) const override
Return true if core can access the memory in mem.
std::optional< TileID > getMemEast(TileID src) const override
Return the tile ID of the memory to the east of the given tile, if it exists.
uint32_t getDmaChannelIdleMask() const override
Return the bits of the getDmaStatusAddress() register that are all clear exactly when the channel has...
uint32_t getMaxOutOfOrderId() const override
Return the largest out-of-order BD id (unsupported = 0).
uint32_t getMaxLockValue() const override
Return the maximum value that can be stored in a lock register.
uint64_t getDmaBdMaxLen(AIETileType tileType) const override
Return the maximum transfer length, measured in address-generation granules (see getAddressGenGranula...
uint32_t getDmaBdWrapBits(AIETileType tileType) const override
Return the bit width of the wrap (size) field in a DMA buffer descriptor for the given tile type.
uint32_t getBDMaxDims(AIETileType tileType) const override
Return the maximum number of addressing dimensions (wraps/strides) a single buffer descriptor support...
uint32_t getNumArbiters() const override
Return the number of arbiters per stream switch.
bool isMemNorth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is North of dst.
uint32_t getMaxPacketId() const override
Return the largest packet id the stream switch can route.
uint32_t getLocalMemorySize() const override
Return the size (in bytes) of the local data memory of a core.
uint32_t getMemNorthBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getNumDestShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a shimmux.
const DmaBdLayout & getDmaBdLimits(AIETileType tileType) const
uint32_t getColumnShift() const override
uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma buffer descriptor for the given col, row, buffer descriptor id,...
uint32_t getDmaBdStepBits(AIETileType tileType) const override
Return the bit width of the step (stride) field in a DMA buffer descriptor for the given tile type.
uint32_t getMemEastBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getMemInternalBaseAddress(TileID src) const override
Return the base address in the local address map for a core.
uint32_t getBdPoolId(int col, int row, int channel, DMAChannelDir dir) const override
Memtile: even channels use BDs 0-23, odd channels 24-47.
uint32_t getNumBanks(int col, int row) const override
Return the number of memory banks of a given tile.
static bool classof(const AIETargetModel *model)
AIE2TargetModel(TargetModelKind k)
uint32_t getDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma task queue register for the given col, row, channel and direction...
uint32_t getNumBDs(AIETileType tileType) const override
Return the size of the BD id space of a tile type (see getTotalNumBDs()).
std::optional< uint32_t > getLocalLockAddress(uint32_t lockId, TileID tile) const override
uint32_t getComputeTileLoadStoreBusWidth() const override
Return the data bus width (in bits) for load/store operations of a compute core.
std::optional< TileID > getMemSouth(TileID src) const override
Return the tile ID of the memory to the south of the given tile, if it exists.
const DmaBdLayout * getDmaBdLayout(AIETileType tileType) const override
Return the register layout of a buffer descriptor on the given tile type, or null if the target has n...
uint32_t getMemTileSize() const override
Return the size (in bytes) of a MemTile.
uint32_t getProgramMemorySize() const override
Return the size (in bytes) of a core's program memory.
uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a switchbox.
bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is West of dst.
uint32_t getDmaTaskQueueSizeMask() const override
Return the mask selecting the live task-queue occupancy field within the getDmaStatusAddress() regist...
bool isMemSouth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is South of dst.
uint32_t getDmaTaskQueueDepth() const override
Return how many DMA tasks a single channel's task queue holds (unsupported = 0).
uint32_t getNumSlaveSlots() const override
Return the number of packet-rule slots per stream-switch slave port.
std::optional< TileID > getMemNorth(TileID src) const override
Return the tile ID of the memory to the north of the given tile, if it exists.
bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is East of dst.
uint32_t getNumSourceShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a shimmux.
uint32_t getDmaBdAddressOffset(int col, int row) const override
Return the offset of the base address field within the shim dma buffer descriptor.
uint32_t getNumLocks(AIETileType tileType) const override
Return the number of lock objects for a given tile type.
uint32_t getRowShift() const override
std::optional< TileID > getMemEast(TileID src) const override
Return the tile ID of the memory to the east of the given tile, if it exists.
uint32_t getBDMaxDims(AIETileType tileType) const override
Return the maximum number of addressing dimensions (wraps/strides) a single buffer descriptor support...
uint32_t getTotalNumBDs(AIETileType tileType) const override
Memtile: 16 BDs per each of 10 MM2S + 8 S2MM channels.
uint32_t getComputeTileLoadStoreBusWidth() const override
Return the data bus width (in bits) for load/store operations of a compute core.
std::optional< TileID > getMemWest(TileID) const override
A core reaches only its own data memory, through the east window.
const DmaBdLayout * getDmaBdLayout(AIETileType tileType) const override
Return the register layout of a buffer descriptor on the given tile type, or null if the target has n...
uint32_t getDmaBdWrapBits(AIETileType tileType) const override
Return the bit width of the wrap (size) field in a DMA buffer descriptor for the given tile type.
uint32_t getNumSlaveSlots() const override
Return the number of packet-rule slots per stream-switch slave port.
static bool classof(const AIETargetModel *model)
AIE4TargetModel(TargetModelKind k)
uint32_t getDefaultAxCache() const override
AxCACHE 0 is the hardware-proven value on AIE4.
std::optional< TileID > getMemNorth(TileID) const override
Return the tile ID of the memory to the north of the given tile, if it exists.
uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel, AIE::DMAChannelDir direction) const override
Shim data BDs need no channel; control, trace and memtile BDs do (fatal error without one).
uint32_t getProgramMemorySize() const override
Return the size (in bytes) of a core's program memory.
uint32_t getNumArbiters() const override
Return the number of arbiters per stream switch.
uint32_t getDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma task queue register for the given col, row, channel and direction...
uint32_t getBdPoolStartId(int col, int row, uint32_t poolId) const override
bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is West of dst.
uint32_t getTileAddress(int col, int row) const override
A memtile spans five address rows (registers, then 4 MiB of data), so memtile row m starts at address...
bool isLegalMemAffinity(int coreCol, int coreRow, int memCol, int memRow) const override
Return true if core can access the memory in mem.
uint32_t getMemEastBaseAddress() const override
Return the base address in the local address map for a core.
std::unique_ptr< RegisterDatabase > loadRegisterDatabase() const override
AIE4 TargetModel.
bool isMemSouth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is South of dst.
uint32_t getMemSouthBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getNumBDsInPool(int col, int row, uint32_t poolId) const override
uint32_t getMaxPacketId() const override
Return the largest packet id the stream switch can route.
uint32_t getMaxLockValue() const override
Return the maximum value that can be stored in a lock register.
uint32_t getMaxRepeatCount() const override
Return the largest DMA task repeat count (unsupported = 0).
uint32_t getCoreDataAddressSpaceSize() const override
Return the size (in bytes) of the address space a core can issue data accesses into.
uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a switchbox.
uint32_t getAccumulatorCascadeSize() const override
Return the size (in bits) of the accumulator/cascade.
bool hasChannelLocalBdIds(int col, int row) const override
True if data BD ids are channel-local, so a BD's address depends on its channel and direction.
uint32_t getDataMemoryOffset(int col, int row) const override
A memtile's data memory starts 1 MiB into its window.
uint32_t getNumMselsPerArbiter() const override
Return the number of master select values per stream-switch arbiter.
bool isMemNorth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is North of dst.
uint32_t getDmaBdIterBits(AIETileType tileType) const override
Return the bit width of the iteration (repeat) wrap/stride fields in a DMA buffer descriptor for the ...
uint32_t getMemNorthBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getNumControllersPerColumn() const override
Number of microcontrollers (uC) per column.
AIEArch getTargetArch() const override
Return the target architecture.
uint32_t getMemTileSize() const override
Return the size (in bytes) of a MemTile.
llvm::ArrayRef< std::pair< int, int > > getCascadeSteps() const override
The steps (destination column - source column, destination row - source row) from one core's cascade ...
uint32_t getDmaTaskQueueDepth() const override
Not modelled yet.
uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override
uint32_t getMaxOutOfOrderId() const override
4-bit index into the receiving channel's 16-BD bank.
uint32_t getBdPoolId(int col, int row, int channel, DMAChannelDir dir) const override
Shim: MM2S 0-1 and S2MM 0 use BDs 0-15, MM2S 2-3 and S2MM 1 BDs 16-31; ControlMM2S (8) and TraceS2MM ...
const DmaBdLayout & getDmaBdLimits(AIETileType tileType) const
Field limits from the BD layout; the shim's for tiles without one.
uint32_t getNumBanks(int col, int row) const override
Return the number of memory banks of a given tile.
uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a switchbox.
std::optional< uint32_t > getLocalLockAddress(uint32_t lockId, TileID tile) const override
std::optional< uint32_t > getLockLocalBaseIndex(int localCol, int localRow, int lockCol, int lockRow) const override
A memtile DMA reaches the locks and memory of the 15 memtiles within seven columns,...
bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is East of dst.
uint64_t getDmaBdMaxLen(AIETileType tileType) const override
Return the maximum transfer length, measured in address-generation granules (see getAddressGenGranula...
std::optional< uint32_t > getStreamSwitchPortIndex(int col, int row, WireBundle bundle, uint32_t channel, bool master) const override
Not modelled yet.
uint32_t getNumDestShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a shimmux.
uint32_t getDmaBdStepBits(AIETileType tileType) const override
Return the bit width of the step (stride) field in a DMA buffer descriptor for the given tile type.
std::optional< TileID > getMemSouth(TileID) const override
Return the tile ID of the memory to the south of the given tile, if it exists.
bool isLegalTileConnection(int col, int row, WireBundle srcBundle, int srcChan, WireBundle dstBundle, int dstChan) const override
std::optional< uint32_t > getMemLocalBaseAddress(int localCol, int localRow, int memCol, int memRow) const override
Return the memory base address (or offset) in the local tile when accessing a neighbor's memory or an...
uint32_t getNumSourceShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a shimmux.
uint32_t getNumBDs(AIETileType tileType) const override
16 ids per core tile or memtile channel pool; 32 across two shim banks.
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
uint32_t getColumnShift() const override
uint32_t getAddressGenGranularity() const override
Return the data bus width of the device.
uint32_t getRowFromAddress(uint32_t address) const override
Inverse of getTileAddress() for any address in the tile's window.
uint32_t getDmaBdAddressOffset(int col, int row) const override
Return the offset of the base address field within the shim dma buffer descriptor.
bool hasShimMux(int col, int row) const override
True if the tile's DMA/NOC/PLIO ports sit behind an aie.shim_mux; otherwise its DMA is routed in the ...
uint32_t getMemInternalBaseAddress(TileID src) const override
Return the base address in the local address map for a core.
uint32_t getMemWestBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getLocalMemorySize() const override
Return the size (in bytes) of the local data memory of a core.
virtual uint32_t getCoreDataAddressSpaceSize() const =0
Return the size (in bytes) of the address space a core can issue data accesses into.
std::pair< uint32_t, uint32_t > getBdIdRangeForChannel(int col, int row, int channel, DMAChannelDir dir) const
Return the half-open range of BD ids channel in dir can submit.
std::optional< uint32_t > encodeFieldValue(const BitFieldInfo &field, uint32_t value) const
Encode a field value with proper bit shifting.
uint32_t getDmaBdStepBias(AIETileType tileType) const
DmaBdLayout::stepBias, or 1 without a layout.
std::optional< uint32_t > resolvePortValue(llvm::StringRef value, TileID tile, bool master) const
Resolve stream switch port specification to port index.
llvm::DenseMap< TileID, int > getTileToControllerIdMap(bool columnWiseUniqueIDs=true) const
Return a mapping from tile coordinates to controller IDs.
virtual uint32_t getTileAddress(int col, int row) const
Return the base address of the tile's window.
virtual uint32_t getNumMselsPerArbiter() const =0
Return the number of master select values per stream-switch arbiter.
virtual std::optional< uint32_t > getMemLocalBaseAddress(int localCol, int localRow, int memCol, int memRow) const
Return the memory base address (or offset) in the local tile when accessing a neighbor's memory or an...
bool isNorth(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is North of dst.
bool isSouth(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is South of dst.
uint32_t getDmaBdWrapBits(int col, int row) const
bool isWest(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is West of dst.
virtual llvm::ArrayRef< std::pair< int, int > > getCascadeSteps() const
The steps (destination column - source column, destination row - source row) from one core's cascade ...
uint32_t getLocalDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const
Return the DMA task-queue register address relative to its tile.
TargetModelKind getKind() const
virtual bool isSupportedBlockFormat(std::string const &format) const
bool isBdInChannelPool(int col, int row, uint32_t bd_id, int channel, DMAChannelDir dir) const
True iff bd_id is in the channel's pool, whether or not it exists.
bool isCoreTile(int col, int row) const
Return true if the given tile is a Core tile.
virtual uint64_t getDmaBdMaxLen(AIETileType tileType) const =0
Return the maximum transfer length, measured in address-generation granules (see getAddressGenGranula...
uint32_t getModelProperties() const
virtual const DmaBdLayout * getDmaBdLayout(AIETileType tileType) const
Return the register layout of a buffer descriptor on the given tile type, or null if the target has n...
virtual AIEArch getTargetArch() const =0
Return the target architecture.
virtual bool isMemNorth(int srcCol, int srcRow, int dstCol, int dstRow) const =0
Return true if src has a memory tile which is North of dst.
virtual uint32_t getNumSourceShimMuxConnections(int col, int row, WireBundle bundle) const =0
Return the number of sources of connections inside a shimmux.
bool isMemTile(int col, int row) const
Return true if the given tile is a Mem tile.
virtual uint32_t getDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const =0
Return the array address of the dma task queue register for the given col, row, channel and direction...
virtual uint32_t getDmaBdWrapBits(AIETileType tileType) const =0
Return the bit width of the wrap (size) field in a DMA buffer descriptor for the given tile type.
virtual uint32_t getMemSouthBaseAddress() const =0
Return the base address in the local address map for a core.
virtual std::optional< uint32_t > getLockLocalBaseIndex(int localCol, int localRow, int lockCol, int lockRow) const
Return the lock base index (or offset) in the local tile when accessing a neighbor's lock or an empty...
virtual uint32_t getDmaChannelIdleMask() const
Return the bits of the getDmaStatusAddress() register that are all clear exactly when the channel has...
void addModelProperty(uint32_t prop)
AIETargetModel(TargetModelKind k)
virtual uint32_t getLocalMemorySize() const =0
Return the size (in bytes) of the local data memory of a core.
std::optional< uint32_t > getFieldMask(const BitFieldInfo &field) const
Compute a 32-bit mask for a register field.
virtual uint32_t getNumLocks(AIETileType tileType) const =0
Return the number of lock objects for a given tile type.
uint32_t getNumBDsForChannel(int col, int row, int channel, DMAChannelDir dir) const
uint32_t getDmaBdIterBits(int col, int row) const
uint32_t getColumnFromAddress(uint32_t address) const
virtual uint32_t getComputeTileLoadStoreBusWidth() const =0
Return the data bus width (in bits) for load/store operations of a compute core.
bool isOrdinaryWriteAddress(TileID tile, uint32_t offset) const
std::vector< int > partitionStartColumns(int numCols) const
Every physical column offset at which a numCols-wide partition still fits.
virtual uint32_t getTotalNumBDs(AIETileType tileType) const
Physical BDs over all pools; exceeds getNumBDs() where pools reuse ids.
std::optional< uint32_t > lookupEvent(llvm::StringRef name, TileID tile, bool isMem=false) const
Lookup event number by name and tile.
virtual std::optional< TileID > getMemNorth(TileID src) const =0
Return the tile ID of the memory to the north of the given tile, if it exists.
virtual int physicalColumns() const
Width of the physical array this (possibly virtualized) device is carved from.
virtual uint32_t getBdPoolId(int col, int row, int channel, DMAChannelDir dir) const
Return the pool channel in direction dir draws its BDs from.
virtual uint32_t getDmaBdIterBits(AIETileType tileType) const =0
Return the bit width of the iteration (repeat) wrap/stride fields in a DMA buffer descriptor for the ...
const RegisterInfo * lookupRegister(llvm::StringRef name, TileID tile, bool isMem=false) const
Register Database API - provides access to register and event information for trace configuration and...
virtual uint32_t getBDMaxDims(AIETileType tileType) const =0
Return the maximum number of addressing dimensions (wraps/strides) a single buffer descriptor support...
virtual std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const =0
const RegisterDatabase * getRegisterDatabase() const
Get the register database, loading it lazily on first access.
virtual bool isLegalTileConnection(int col, int row, WireBundle srcBundle, int srcChan, WireBundle dstBundle, int dstChan) const =0
virtual uint32_t getNumBanks(int col, int row) const =0
Return the number of memory banks of a given tile.
uint64_t getDmaBdMaxLen(int col, int row) const
virtual bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const =0
Return true if src has a memory tile which is East of dst.
virtual uint32_t getDmaTaskQueueDepth() const =0
Return how many DMA tasks a single channel's task queue holds (unsupported = 0).
virtual uint32_t getDmaBdStepBits(AIETileType tileType) const =0
Return the bit width of the step (stride) field in a DMA buffer descriptor for the given tile type.
virtual uint32_t getRowFromAddress(uint32_t address) const
Inverse of getTileAddress() for any address in the tile's window.
bool isShimPLTile(int col, int row) const
Return true if the given tile is a ShimPL tile.
uint32_t getDmaTaskQueueDepth(int, int, int, AIE::DMAChannelDir) const
Return the task-queue depth for one channel.
const DmaBdLayout * getDmaBdLayout(int col, int row, DMAChannelDir direction) const
virtual uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel=-1, AIE::DMAChannelDir direction=AIE::DMAChannelDir::MM2S) const =0
Return the array address of the dma buffer descriptor for the given col, row, buffer descriptor id,...
uint32_t getDmaBdStepBias(int col, int row) const
bool isBdChannelAccessible(int col, int row, uint32_t bd_id, int channel, DMAChannelDir dir) const
virtual uint32_t getDmaBdAddressOffset(int col, int row) const =0
Return the offset of the base address field within the shim dma buffer descriptor.
virtual uint32_t getAccumulatorCascadeSize() const =0
Return the size (in bits) of the accumulator/cascade.
virtual std::optional< uint32_t > getLocalLockAddress(uint32_t lockId, TileID tile) const =0
virtual uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const =0
virtual AIETileType getTileType(int col, int row) const =0
Return the tile type for the given tile coordinates.
uint32_t getCoreStackAlignment() const
Stack-pointer alignment in bytes, matching Peano's AIE frame lowering: AIE1/AIE2 require 32B; AIE2P/A...
virtual uint32_t getNumArbiters() const =0
Return the number of arbiters per stream switch.
virtual bool isValidTile(TileID src) const
Return true if the given tile ID is valid.
bool isEast(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is East of dst.
virtual uint32_t getDmaTaskQueueSizeMask() const
Return the mask selecting the live task-queue occupancy field within the getDmaStatusAddress() regist...
virtual bool isMemSouth(int srcCol, int srcRow, int dstCol, int dstRow) const =0
Return true if src has a memory tile which is South of dst.
bool isShimNOCorPLTile(int col, int row) const
Return true if the given tile is either a ShimNOC or ShimPL tile.
virtual uint32_t getMaxRepeatCount() const =0
Return the largest DMA task repeat count (unsupported = 0).
virtual uint32_t getMemWestBaseAddress() const =0
Return the base address in the local address map for a core.
bool isDmaChannelSupported(TileID tile, AIE::DMAChannelDir dir, int channel) const
virtual uint32_t getNumControllersPerColumn() const
Number of microcontrollers (uC) per column.
virtual int rows() const =0
Return the number of rows in the device.
uint32_t getBDMaxDims(int col, int row) const
Return the maximum number of BD addressing dimensions for the tile at (col, row).
uint32_t getTotalNumBDs(int col, int row) const
virtual std::optional< TileID > getMemSouth(TileID src) const =0
Return the tile ID of the memory to the south of the given tile, if it exists.
virtual std::optional< TileID > getMemEast(TileID src) const =0
Return the tile ID of the memory to the east of the given tile, if it exists.
bool isShimNOCTile(int col, int row) const
Return true if the given tile is a ShimNOC tile.
virtual uint32_t getNumBDs(AIETileType tileType) const =0
Return the size of the BD id space of a tile type (see getTotalNumBDs()).
virtual uint32_t getMaxPacketId() const =0
Return the largest packet id the stream switch can route.
virtual bool hasChannelLocalBdIds(int col, int row) const
True if data BD ids are channel-local, so a BD's address depends on its channel and direction.
virtual uint32_t getMaxLockValue() const =0
Return the maximum value that can be stored in a lock register.
virtual std::unique_ptr< RegisterDatabase > loadRegisterDatabase() const
Subclasses override to provide architecture-specific database loading.
bool isBdChannelAccessible(int col, int row, uint32_t bd_id, int channel) const
True iff the channel exists and can submit bd_id in every direction it has.
virtual uint32_t getComputeTileMaxVectorAlignBits() const
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
virtual uint32_t getProgramMemorySize() const =0
Return the size (in bytes) of a core's program memory.
virtual uint32_t getMaxOutOfOrderId() const =0
Return the largest out-of-order BD id (unsupported = 0).
virtual uint32_t getBdPoolStartId(int col, int row, uint32_t poolId) const
virtual std::optional< TileID > getMemWest(TileID src) const =0
Return the tile ID of the memory to the west of the given tile, if it exists.
virtual uint32_t getColumnShift() const =0
virtual uint32_t getMemNorthBaseAddress() const =0
Return the base address in the local address map for a core.
uint32_t getNumLocks(int col, int row) const
Return the number of lock objects for a tile at the given coordinates.
bool hasProperty(ModelProperty Prop) const
uint32_t getDmaQueueAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const
Return the array address of the task queue register a push writes, the word after the channel's contr...
bool usesChannelLocalBdIds(int col, int row, DMAChannelDir direction) const
Control and trace channels always have private, channel-local pools.
uint32_t getNumDMAChannels(int col, int row, AIE::DMAChannelDir dir) const
Return the number of DMA channels a tile has in one direction.
virtual uint32_t getDataMemoryOffset(int, int) const
Offset of data memory in the tile's window; buffer addresses are relative to it.
virtual int columns() const =0
Return the number of columns in the device.
int getPacketIdBits() const
Bits a packet id spans, and the mask a switch's id match uses.
uint32_t getNumBDsForChannel(int col, int row, int channel) const
virtual bool isMemTilePadValueSupported() const
virtual const DmaBdLayout * getDmaBdLayout(AIETileType tileType, DMAChannelDir direction) const
Return the BD layout for direction; control and trace BDs may differ.
bool isLegalCascade(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if a cascade can run from src to dst.
virtual uint32_t getDefaultCoreStackSize() const
Return the default stack reservation (in bytes) for a core that does not state one.
virtual uint32_t getMemEastBaseAddress() const =0
Return the base address in the local address map for a core.
const DmaBdLayout * getDmaBdLayout(int col, int row) const
virtual uint32_t getNumControllers() const
Total number of microcontrollers (uC) in the device.
virtual uint32_t getMemTileLoadStoreBusWidth() const
Return the data bus width (in bits) for load/store operations of a memory tile.
uint32_t getDmaBdStepBits(int col, int row) const
virtual uint32_t getNumMemTileRows() const =0
virtual uint32_t getNumBDsInPool(int col, int row, uint32_t poolId) const
virtual uint32_t getNumDestShimMuxConnections(int col, int row, WireBundle bundle) const =0
Return the number of destinations of connections inside a shimmux.
virtual bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const =0
Return true if src has a memory tile which is West of dst.
virtual uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const =0
Return the number of destinations of connections inside a switchbox.
virtual uint32_t getMemInternalBaseAddress(TileID src) const =0
Return the base address in the local address map for a core.
virtual uint32_t getDefaultAxCache() const
SharedMemory
Which of two tiles' memory modules both of them can address.
@ None
Neither tile can address the other's memory module.
@ First
Only the first tile's module.
@ Second
Only the second tile's module.
virtual std::optional< uint32_t > getDmaStatusAddress(int, int, int, AIE::DMAChannelDir) const
Return the address of the DMA status register for a channel, or nullopt when this target's layout has...
bool isInternal(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is the internal memory of dst.
virtual uint32_t getRowShift() const =0
virtual uint32_t getNumSlaveSlots() const =0
Return the number of packet-rule slots per stream-switch slave port.
uint32_t getRowFieldMask() const
SharedMemory getSharedMemory(TileID a, TileID b) const
Return the memory module a and b can both reach, if any.
virtual int firstPlaceableColumn() const
First physical column at which a partition may be anchored.
virtual bool isLegalMemAffinity(int coreCol, int coreRow, int memCol, int memRow) const =0
Return true if core can access the memory in mem.
virtual bool hasShimMux(int col, int row) const
True if the tile's DMA/NOC/PLIO ports sit behind an aie.shim_mux; otherwise its DMA is routed in the ...
uint32_t getNumBDs(int col, int row) const
Return the number of buffer descriptors supported by the DMA in the given tile.
virtual uint32_t getAddressGenGranularity() const =0
Return the data bus width of the device.
virtual uint32_t getMemTileSize() const =0
Return the size (in bytes) of a MemTile.
virtual std::optional< uint32_t > getStreamSwitchPortIndex(int col, int row, WireBundle bundle, uint32_t channel, bool master) const =0
Get stream switch port index for a given port specification Return port index for Stream_Switch_Event...
virtual uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const =0
Return the number of sources of connections inside a switchbox.
uint32_t getNumMemTileRows() const override
static bool classof(const AIETargetModel *model)
int physicalColumns() const override
Width of the physical array this (possibly virtualized) device is carved from.
uint32_t getNumControllers() const override
Total number of microcontrollers (uC) in the device.
int rows() const override
Return the number of rows in the device.
uint32_t getNumControllers() const override
Total number of microcontrollers (uC) in the device.
static bool classof(const AIETargetModel *model)
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
uint32_t getNumMemTileRows() const override
AIEArch getTargetArch() const override
Return the target architecture.
uint32_t getComputeTileMaxVectorAlignBits() const override
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
bool isSupportedBlockFormat(std::string const &format) const override
int rows() const override
Return the number of rows in the device.
int physicalColumns() const override
Width of the physical array this (possibly virtualized) device is carved from.
bool isMemTilePadValueSupported() const override
static bool classof(const AIETargetModel *model)
uint32_t getNumMemTileRows() const override
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
int rows() const override
Return the number of rows in the device.
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
Register and event database for a specific architecture.
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
uint32_t getAddressGenGranularity() const override
Return the data bus width of the device.
int rows() const override
Return the number of rows in the device.
int columns() const override
Return the number of columns in the device.
int rows() const override
Return the number of rows in the device.
uint32_t getNumMemTileRows() const override
static bool classof(const AIETargetModel *model)
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
static bool classof(const AIETargetModel *model)
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
uint32_t getNumMemTileRows() const override
int columns() const override
Return the number of columns in the device.
int rows() const override
Return the number of rows in the device.
static bool classof(const AIETargetModel *model)
int rows() const override
Return the number of rows in the device.
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
uint32_t getNumMemTileRows() const override
int columns() const override
Return the number of columns in the device.
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
uint8_t txnDeviceGen(const AIETargetModel &tm)
Device generation ID written into the TXN header (aie_runtime::TxnDeviceInfo::devGen).
struct TileID { friend std::ostream &operator<<(std::ostream &os, const TileID &s) { os<< "TileID("<< s.col<< ", "<< s.row<< ")"; return os; } friend std::string to_string(const TileID &s) { std::ostringstream ss; ss<< s; return ss.str(); } friend llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const TileID &s) { os<< to_string(s); return os; } inline bool operator<(const TileID &rhs) const { return std::tie(col, row)< std::tie(rhs.col, rhs.row); } bool operator==(const TileID &rhs) const { return std::tie(col, row)==std::tie(rhs.col, rhs.row); } bool operator!=(const TileID &rhs) const { return !(*this==rhs);} int col, row;} TileID
llvm::raw_ostream & operator<<(llvm::raw_ostream &os, const SwitchSettings &ss)
WireBundle getDMAChannelBundle(DMAChannelDir dir)
The stream-switch bundle the channels of dir use.
Definition AIEEnums.h:29
static unsigned getHashValue(const xilinx::AIE::TileID &t)
static bool isEqual(const xilinx::AIE::TileID &lhs, const xilinx::AIE::TileID &rhs)
std::size_t operator()(const xilinx::AIE::TileID &s) const noexcept
Bit field information for a register.
Bits [shift, shift + width) of register word in a buffer descriptor's register block.
uint32_t place(uint64_t value) const
uint32_t mask() const
The register layout of one tile type's DMA buffer descriptor.
DmaBdField d2Size
Fourth-dimension fields; not programmed yet (buffer_length carries d2).
uint8_t stepBias
Step fields hold (step in granules - stepBias).
llvm::SmallVector< std::pair< DmaBdField, DmaBdField >, 3 > padFields() const
The (before, after) zero-padding fields, innermost dimension first.
DmaBdField d0Size
Without a d0Stride field the innermost dimension is contiguous.