30 bool isEvenRow = ((
src.row % 2) == 0);
31 std::optional<TileID> ret;
35 ret = {
src.col - 1,
src.row};
43 bool isEvenRow = (
src.row % 2) == 0;
44 std::optional<TileID> ret;
46 ret = {
src.col + 1,
src.row};
56 std::optional<TileID> ret({
src.col,
src.row + 1});
63 std::optional<TileID> ret({
src.col,
src.row - 1});
72 bool IsEvenRow = (srcRow % 2) == 0;
73 return (IsEvenRow &&
isInternal(srcCol, srcRow, dstCol, dstRow)) ||
74 (!IsEvenRow &&
isWest(srcCol, srcRow, dstCol, dstRow));
79 bool IsEvenRow = (srcRow % 2) == 0;
80 return (!IsEvenRow &&
isInternal(srcCol, srcRow, dstCol, dstRow)) ||
81 (IsEvenRow &&
isEast(srcCol, srcRow, dstCol, dstRow));
86 return isNorth(srcCol, srcRow, dstCol, dstRow);
91 return isSouth(srcCol, srcRow, dstCol, dstRow);
96 bool IsEvenRow = ((coreRow % 2) == 0);
98 bool IsMemWest = (
isWest(coreCol, coreRow, memCol, memRow) && !IsEvenRow) ||
99 (
isInternal(coreCol, coreRow, memCol, memRow) && IsEvenRow);
101 bool IsMemEast = (
isEast(coreCol, coreRow, memCol, memRow) && IsEvenRow) ||
102 (
isInternal(coreCol, coreRow, memCol, memRow) && !IsEvenRow);
104 bool IsMemNorth =
isNorth(coreCol, coreRow, memCol, memRow);
105 bool IsMemSouth =
isSouth(coreCol, coreRow, memCol, memRow);
107 return IsMemSouth || IsMemNorth || IsMemWest || IsMemEast;
112 AIE::DMAChannelDir direction)
const {
115 offset = 0x0001D000 + (bd_id * 0x14);
117 offset = 0x0001D000 + (bd_id * 0x20);
120 "AIE1TargetModel::getDmaBdAddress called for non-DMA tile");
131 "AIE1TargetModel::getDmaBdAddressOffset called for non-DMA tile");
136 AIE::DMAChannelDir direction)
const {
139 offset = 0x0001D140 + (
channel * 0x8);
141 offset = 0x0001DE00 + (
channel * 0x8);
144 "AIE1TargetModel::getDmaControlAddress called for non-DMA tile");
146 if (direction == AIE::DMAChannelDir::MM2S)
155 WireBundle bundle)
const {
158 case WireBundle::FIFO:
160 case WireBundle::North:
162 case WireBundle::West: {
167 case WireBundle::South:
169 case WireBundle::East: {
174 case WireBundle::TileControl:
181 case WireBundle::Core:
182 case WireBundle::DMA:
183 case WireBundle::FIFO:
185 case WireBundle::North: {
190 case WireBundle::West: {
195 case WireBundle::South:
197 case WireBundle::East: {
202 case WireBundle::TileControl:
211 WireBundle bundle)
const {
214 case WireBundle::FIFO:
216 case WireBundle::North:
218 case WireBundle::West: {
223 case WireBundle::South:
225 case WireBundle::East: {
230 case WireBundle::Trace:
232 case WireBundle::TileControl:
239 case WireBundle::Core:
240 case WireBundle::DMA:
241 case WireBundle::FIFO:
243 case WireBundle::North: {
248 case WireBundle::West: {
253 case WireBundle::South:
255 case WireBundle::East: {
260 case WireBundle::Trace:
262 case WireBundle::TileControl:
270 WireBundle bundle)
const {
273 case WireBundle::DMA:
275 case WireBundle::NOC:
277 case WireBundle::PLIO:
279 case WireBundle::South:
288 WireBundle bundle)
const {
291 case WireBundle::DMA:
293 case WireBundle::NOC:
295 case WireBundle::PLIO:
297 case WireBundle::South:
306 WireBundle srcBundle,
int srcChan,
307 WireBundle dstBundle,
321 if (srcBundle == WireBundle::Trace)
322 return dstBundle == WireBundle::South;
328 if (srcBundle == WireBundle::Trace)
329 return dstBundle == WireBundle::South;
336std::vector<std::pair<uint32_t, uint32_t>>
338 return {std::pair(0, 64), std::pair(1, 128), std::pair(2, 256)};
341std::optional<uint32_t>
357 std::optional<TileID> ret({
src.col - 1,
src.row});
366 std::optional ret =
src;
375 std::optional<TileID> ret({
src.col,
src.row + 1});
382 std::optional<TileID> ret({
src.col,
src.row - 1});
392 return isWest(srcCol, srcRow, dstCol, dstRow);
397 return isInternal(srcCol, srcRow, dstCol, dstRow);
402 return isNorth(srcCol, srcRow, dstCol, dstRow);
407 return isSouth(srcCol, srcRow, dstCol, dstRow);
413 bool IsMemWest =
isMemWest(coreCol, coreRow, memCol, memRow);
414 bool IsMemEast =
isMemEast(coreCol, coreRow, memCol, memRow);
415 bool IsMemNorth =
isMemNorth(coreCol, coreRow, memCol, memRow);
416 bool IsMemSouth =
isMemSouth(coreCol, coreRow, memCol, memRow);
419 return isEast(coreCol, coreRow, memCol, memRow) ||
420 isInternal(coreCol, coreRow, memCol, memRow) ||
421 isWest(coreCol, coreRow, memCol, memRow);
422 return (IsMemSouth && !
isMemTile(memCol, memRow)) || IsMemNorth ||
423 IsMemWest || IsMemEast;
428 AIE::DMAChannelDir direction)
const {
431 offset = 0x0001D000 + bd_id * 0x20;
433 offset = 0x000A0000 + bd_id * 0x20;
435 offset = 0x0001D000 + bd_id * 0x20;
438 "AIE2TargetModel::getDmaBdAddress called for non-DMA tile");
452 AIE::DMAChannelDir direction)
const {
455 offset = 0x0001D200 + (
channel * 0x8);
456 if (direction == AIE::DMAChannelDir::MM2S)
459 offset = 0x000A0600 + (
channel * 0x8);
460 if (direction == AIE::DMAChannelDir::MM2S)
463 offset = 0x0001DE00 + (
channel * 0x8);
464 if (direction == AIE::DMAChannelDir::MM2S)
468 "AIE2TargetModel::getDmaControlAddress called for non-DMA tile");
477 WireBundle bundle)
const {
480 case WireBundle::DMA:
481 case WireBundle::North:
483 case WireBundle::South:
485 case WireBundle::TileControl:
493 case WireBundle::FIFO:
495 case WireBundle::North:
497 case WireBundle::West: {
502 case WireBundle::South:
504 case WireBundle::East: {
509 case WireBundle::TileControl:
516 case WireBundle::Core:
518 case WireBundle::DMA:
520 case WireBundle::FIFO:
522 case WireBundle::North: {
527 case WireBundle::West: {
532 case WireBundle::South:
534 case WireBundle::East: {
539 case WireBundle::TileControl:
548 WireBundle bundle)
const {
551 case WireBundle::DMA:
553 case WireBundle::North:
555 case WireBundle::South:
557 case WireBundle::Trace:
558 case WireBundle::TileControl:
566 case WireBundle::FIFO:
568 case WireBundle::North:
570 case WireBundle::West: {
575 case WireBundle::South:
577 case WireBundle::East: {
582 case WireBundle::Trace:
584 case WireBundle::TileControl:
592 case WireBundle::Core:
594 case WireBundle::DMA:
596 case WireBundle::FIFO:
598 case WireBundle::North: {
603 case WireBundle::West: {
608 case WireBundle::South:
610 case WireBundle::East: {
615 case WireBundle::Trace:
618 case WireBundle::TileControl:
627 WireBundle bundle)
const {
630 case WireBundle::DMA:
632 case WireBundle::NOC:
634 case WireBundle::PLIO:
636 case WireBundle::South:
647 WireBundle bundle)
const {
650 case WireBundle::DMA:
652 case WireBundle::NOC:
654 case WireBundle::PLIO:
656 case WireBundle::South:
666 WireBundle srcBundle,
int srcChan,
667 WireBundle dstBundle,
676 auto isBundleInList = [](WireBundle bundle,
677 std::initializer_list<WireBundle> bundles) {
678 return std::find(bundles.begin(), bundles.end(), bundle) != bundles.end();
683 if (srcBundle == WireBundle::DMA) {
684 if (dstBundle == WireBundle::DMA)
685 return srcChan == dstChan;
686 if (isBundleInList(dstBundle, {WireBundle::TileControl, WireBundle::South,
690 if (srcBundle == WireBundle::TileControl) {
691 if (dstBundle == WireBundle::DMA)
693 if (isBundleInList(dstBundle, {WireBundle::South, WireBundle::North}))
696 if (isBundleInList(srcBundle, {WireBundle::South, WireBundle::North})) {
697 if (isBundleInList(dstBundle, {WireBundle::DMA, WireBundle::TileControl}))
699 if (isBundleInList(dstBundle, {WireBundle::South, WireBundle::North}))
700 return srcChan == dstChan;
702 if (srcBundle == WireBundle::Trace) {
703 if (dstBundle == WireBundle::DMA)
705 if (dstBundle == WireBundle::South)
711 if (srcBundle == WireBundle::TileControl)
712 return dstBundle != WireBundle::TileControl;
713 if (isBundleInList(srcBundle, {WireBundle::FIFO, WireBundle::South}))
714 return isBundleInList(dstBundle,
715 {WireBundle::TileControl, WireBundle::FIFO,
716 WireBundle::South, WireBundle::West,
717 WireBundle::North, WireBundle::East});
718 if (isBundleInList(srcBundle,
719 {WireBundle::West, WireBundle::North, WireBundle::East}))
720 return (srcBundle == dstBundle)
721 ? (srcChan == dstChan)
722 : isBundleInList(dstBundle,
723 {WireBundle::TileControl, WireBundle::FIFO,
724 WireBundle::South, WireBundle::West,
725 WireBundle::North, WireBundle::East});
726 if (srcBundle == WireBundle::Trace) {
727 if (isBundleInList(dstBundle, {WireBundle::FIFO, WireBundle::South}))
729 if (isBundleInList(dstBundle, {WireBundle::West, WireBundle::East}))
735 if (isBundleInList(srcBundle,
736 {WireBundle::DMA, WireBundle::FIFO, WireBundle::South,
737 WireBundle::West, WireBundle::North, WireBundle::East}))
738 if (isBundleInList(dstBundle, {WireBundle::Core, WireBundle::DMA,
739 WireBundle::TileControl, WireBundle::FIFO,
740 WireBundle::South, WireBundle::West,
741 WireBundle::North, WireBundle::East}))
742 return (srcBundle == dstBundle) ? (srcChan == dstChan) :
true;
743 if (srcBundle == WireBundle::Core)
744 return dstBundle != WireBundle::Core;
745 if (srcBundle == WireBundle::TileControl)
746 return dstBundle != WireBundle::TileControl &&
747 dstBundle != WireBundle::DMA;
748 if (srcBundle == WireBundle::Trace) {
749 if (dstBundle == WireBundle::DMA)
751 if (isBundleInList(dstBundle, {WireBundle::FIFO, WireBundle::South}))
758std::vector<std::pair<uint32_t, uint32_t>>
760 return {std::pair(0, 64), std::pair(1, 128), std::pair(2, 256)};
763std::optional<uint32_t>
765 auto computeTileBaseAddress = 0x0001F000;
766 auto memTileBaseAddress = 0x000C0000;
767 auto shimTileBaseAddress = 0x00014000;
768 auto lockAddrOffset = 0x10;
772 return computeTileBaseAddress + lockAddrOffset * lockId;
775 return memTileBaseAddress + lockAddrOffset * lockId;
779 return shimTileBaseAddress + lockAddrOffset * lockId;
787 for (
int j = 0; j <
columns(); j++) {
795 for (
int j = 0; j <
columns(); j++)
801 for (
int j = 0; j <
columns(); j++)
806 for (
int i = 0; i <
rows() - 1; i++)
807 for (
int j = 0; j <
columns(); j++)
811 for (
int i = 1; i <
rows(); i++)
812 for (
int j = 0; j <
columns(); j++)
816 for (
int i = 0; i <
rows(); i++)
817 for (
int j = 0; j <
columns() - 1; j++)
821 for (
int i = 0; i <
rows(); i++)
822 for (
int j = 1; j <
columns(); j++)
826 for (
int j = 0; j <
columns(); j++)
829 for (
int i = 0; i <
rows(); i++)
831 WireBundle::East) == 0);
832 for (
int i = 0; i <
rows(); i++)
836 for (
int i = 0; i <
rows(); i++)
837 for (
int j = 0; j <
columns(); j++)
842std::optional<uint32_t>
846 if (
isMemSouth(localCol, localRow, lockCol, lockRow))
848 if (
isMemWest(localCol, localRow, lockCol, lockRow))
850 if (
isMemNorth(localCol, localRow, lockCol, lockRow))
852 if (
isMemEast(localCol, localRow, lockCol, lockRow))
857 if (
isWest(localCol, localRow, lockCol, lockRow))
859 if (
isInternal(localCol, localRow, lockCol, lockRow))
861 if (
isEast(localCol, localRow, lockCol, lockRow))
868std::optional<uint32_t>
872 if (
isMemSouth(localCol, localRow, memCol, memRow))
874 if (
isMemWest(localCol, localRow, memCol, memRow))
876 if (
isMemNorth(localCol, localRow, memCol, memRow))
878 if (
isMemEast(localCol, localRow, memCol, memRow))
883 if (
isWest(localCol, localRow, memCol, memRow))
885 if (
isInternal(localCol, localRow, memCol, memRow))
887 if (
isEast(localCol, localRow, memCol, memRow))
900std::vector<std::pair<uint32_t, uint32_t>>
902 return {std::pair(0, 64), std::pair(1, 128), std::pair(2, 256),
907 std::string
const &format)
const {
908 std::set<std::string> supportedTypes = {
"v8bfp16ebs8",
"v16bfp16ebs16"};
909 return static_cast<bool>(supportedTypes.find(format) != supportedTypes.end());
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 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
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 isMemSouth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is South of dst.
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.
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 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.
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 getDmaBdAddressOffset(int col, int row) const override
Return the offset of the base address field within the shim dma buffer descriptor.
bool isCoreTile(int col, int row) const override
Return true if the given tile is a 'Core' tile.
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() 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.
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.
bool isLegalTileConnection(int col, int row, WireBundle srcBundle, int srcChan, WireBundle dstBundle, int dstChan) const override
bool isMemTile(int col, int row) const override
Return true if the given tile is an AIE2 'Memory' tile.
uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a switchbox.
uint32_t getRowShift() const override
bool isLegalTileConnection(int col, int row, WireBundle srcBundle, int srcChan, WireBundle dstBundle, int dstChan) const override
uint32_t getNumLocks(int col, int row) const override
Return the number of lock objects.
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
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.
AIEArch getTargetArch() const override
AIE2 TargetModel.
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.
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 getNumDestShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a shimmux.
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 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< uint32_t > getLocalLockAddress(uint32_t lockId, TileID tile) const override
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.
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.
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.
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.
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.
bool isWest(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is West of dst.
virtual bool isSupportedBlockFormat(std::string const &format) const
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 getMemSouthBaseAddress() const =0
Return the base address in the local address map for a core.
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 bool isCoreTile(int col, int row) const =0
Return true if the given tile is a 'Core' tile.
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 ~AIETargetModel()
virtual bool isMemTile(int col, int row) const =0
Return true if the given tile is an AIE2 'Memory' tile.
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 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.
virtual uint32_t getMemWestBaseAddress() const =0
Return the base address in the local address map for a core.
virtual uint32_t getNumLocks(int col, int row) const =0
Return the number of lock objects.
virtual int rows() const =0
Return the number of rows in the device.
virtual bool isShimNOCTile(int col, int row) const =0
Return true if the given tile is a Shim NOC tile.
virtual bool isShimNOCorPLTile(int col, int row) const =0
Return true if the given tile is either a Shim NOC or a Shim PL interface tile.
virtual bool isShimPLTile(int col, int row) const =0
Return true if the given tile is a Shim PL interface tile.
virtual uint32_t getMemNorthBaseAddress() const =0
Return the base address in the local address map for a core.
virtual int columns() const =0
Return the number of columns in the device.
virtual uint32_t getMemEastBaseAddress() const =0
Return the base address in the local address map for a core.
virtual uint32_t getNumMemTileRows() const =0
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.
bool isInternal(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is the internal memory of dst.
virtual uint32_t getMemTileSize() const =0
Return the size (in bytes) of a MemTile.
virtual uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const =0
Return the number of sources of connections inside a switchbox.
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
AIEArch getTargetArch() const override
AIE2 TargetModel.
bool isSupportedBlockFormat(std::string const &format) const override
TileID { friend std::ostream &operator<<(std::ostream &os, const TileID &s) { os<< "TileID("<< s.col<< ", "<< s.row<< ")" TileID