11#include "llvm/ADT/STLExtras.h"
12#include "llvm/Support/ErrorHandling.h"
25 if (model.isShimNOCorPLTile(tile.col, tile.row))
27 if (model.isMemTile(tile.col, tile.row))
29 return isMem ? std::string(
"memory") : std::string(
"core");
35 if (model.isShimNOCorPLTile(tile.col, tile.row))
37 if (model.isMemTile(tile.col, tile.row))
41 if (isMem && model.getTargetArch() == AIEArch::AIE4)
43 return isMem ? std::string(
"memory") : std::string(
"core");
68 return db->lookupRegister(name, getModuleForTile(*
this, tile, isMem));
72 uint32_t offset)
const {
76 auto inRange = [offset](uint32_t base, uint32_t bytes) {
77 return offset >= base && offset - base < bytes;
88 for (uint32_t descriptor = 0; descriptor <
getNumBDs(tile.col, tile.row);
92 4 * layout->numWords))
97 offset, getModuleForTile(*
this, tile,
false))
101 getModuleForTile(*
this, tile,
true));
104 llvm::StringRef name = reg->
name;
105 return name.starts_with(
"Stream_Switch_Master_Config_") ||
106 name.starts_with(
"Stream_Switch_Slave_Config_") ||
107 (name.starts_with(
"Stream_Switch_Slave_") && name.contains(
"_Slot")) ||
109 (name ==
"Mux_Config" || name ==
"Demux_Config"));
118 return db->lookupEvent(name, getModuleForTileEvents(*
this, tile, isMem));
121std::optional<uint32_t>
123 uint32_t value)
const {
127 return db->encodeFieldValue(field, value);
130std::optional<uint32_t>
133 if (width == 0 || width > 32 || field.
bit_end >= 32)
136 uint64_t mask = (width == 32) ? 0xFFFFFFFFULL : ((1ULL << width) - 1ULL);
138 if (mask > UINT32_MAX)
141 return static_cast<uint32_t
>(mask);
150 SmallVector<SmallVector<int>> validTileIds = {{15, 26, 27, 29, 30, 31},
151 {14, 21, 22, 23, 24, 25},
152 {13, 11, 17, 18, 19, 20},
153 {12, 28, 7, 8, 9, 10}};
154 if (!columnWiseUniqueIDs &&
columns() > (
int)validTileIds.size())
155 llvm::report_fatal_error(
156 "Device has " + llvm::Twine(
columns()) +
" columns but only " +
157 llvm::Twine(validTileIds.size()) +
158 " globally-unique controller ID sets are defined; "
159 "use column-wise unique IDs mode.");
160 DenseMap<TileID, int> tileIDMap;
161 for (
int col = 0; col <
columns(); col++) {
162 for (
int row = 0; row <
rows(); row++) {
163 if (columnWiseUniqueIDs)
164 tileIDMap[{col, row}] = validTileIds[0][row];
166 tileIDMap[{col, row}] = validTileIds[col][row];
173 assert(columnWiseUniqueIDs &&
174 "Device has more tiles than candidate packet ids; "
175 "use column-wise unique IDs mode.");
176 DenseMap<TileID, int> tileIDMap;
177 int unusedPacketIdFrom = 0;
178 for (
int col = 0; col <
columns(); col++) {
179 if (columnWiseUniqueIDs)
180 unusedPacketIdFrom = 0;
181 for (
int row = 0; row <
rows(); row++)
182 tileIDMap[{col, row}] = unusedPacketIdFrom++;
190 auto colonPos = value.find(
':');
191 if (colonPos == StringRef::npos)
194 StringRef portName = value.substr(0, colonPos);
195 StringRef channelStr = value.substr(colonPos + 1);
198 if (channelStr.getAsInteger(10, channel) || channel < 0)
202 if (portName.equals_insensitive(
"north")) {
203 bundle = WireBundle::North;
204 }
else if (portName.equals_insensitive(
"south")) {
205 bundle = WireBundle::South;
206 }
else if (portName.equals_insensitive(
"east")) {
207 bundle = WireBundle::East;
208 }
else if (portName.equals_insensitive(
"west")) {
209 bundle = WireBundle::West;
210 }
else if (portName.equals_insensitive(
"dma")) {
211 bundle = WireBundle::DMA;
212 }
else if (portName.equals_insensitive(
"fifo")) {
213 bundle = WireBundle::FIFO;
214 }
else if (portName.equals_insensitive(
"core")) {
215 bundle = WireBundle::Core;
216 }
else if (portName.equals_insensitive(
"ctrl")) {
217 bundle = WireBundle::TileControl;
223 static_cast<uint32_t
>(channel), master);
234 bool isEvenRow = ((src.row % 2) == 0);
235 std::optional<TileID> ret;
239 ret = {src.col - 1, src.row};
247 bool isEvenRow = (src.row % 2) == 0;
248 std::optional<TileID> ret;
250 ret = {src.col + 1, src.row};
260 std::optional<TileID> ret({src.col, src.row + 1});
267 std::optional<TileID> ret({src.col, src.row - 1});
276 bool IsEvenRow = (srcRow % 2) == 0;
277 return (IsEvenRow &&
isInternal(srcCol, srcRow, dstCol, dstRow)) ||
278 (!IsEvenRow &&
isWest(srcCol, srcRow, dstCol, dstRow));
283 bool IsEvenRow = (srcRow % 2) == 0;
284 return (!IsEvenRow &&
isInternal(srcCol, srcRow, dstCol, dstRow)) ||
285 (IsEvenRow &&
isEast(srcCol, srcRow, dstCol, dstRow));
290 return isNorth(srcCol, srcRow, dstCol, dstRow);
295 return isSouth(srcCol, srcRow, dstCol, dstRow);
300 bool IsEvenRow = ((coreRow % 2) == 0);
302 bool IsMemWest = (
isWest(coreCol, coreRow, memCol, memRow) && !IsEvenRow) ||
303 (
isInternal(coreCol, coreRow, memCol, memRow) && IsEvenRow);
305 bool IsMemEast = (
isEast(coreCol, coreRow, memCol, memRow) && IsEvenRow) ||
306 (
isInternal(coreCol, coreRow, memCol, memRow) && !IsEvenRow);
308 bool IsMemNorth =
isNorth(coreCol, coreRow, memCol, memRow);
309 bool IsMemSouth =
isSouth(coreCol, coreRow, memCol, memRow);
311 return IsMemSouth || IsMemNorth || IsMemWest || IsMemEast;
316 AIE::DMAChannelDir direction)
const {
319 offset = 0x0001D000 + (bd_id * 0x14);
321 offset = 0x0001D000 + (bd_id * 0x20);
324 "AIE1TargetModel::getDmaBdAddress called for non-DMA tile");
334 "AIE1TargetModel::getDmaBdAddressOffset called for non-DMA tile");
339 AIE::DMAChannelDir direction)
const {
342 offset = 0x0001D140 + (channel * 0x8);
344 offset = 0x0001DE00 + (channel * 0x8);
347 "AIE1TargetModel::getDmaControlAddress called for non-DMA tile");
349 if (direction == AIE::DMAChannelDir::MM2S)
357 WireBundle bundle)
const {
360 case WireBundle::FIFO:
362 case WireBundle::North:
364 case WireBundle::West: {
369 case WireBundle::South:
371 case WireBundle::East: {
376 case WireBundle::TileControl:
383 case WireBundle::Core:
384 case WireBundle::DMA:
385 case WireBundle::FIFO:
387 case WireBundle::North: {
388 if (row ==
rows() - 1)
392 case WireBundle::West: {
397 case WireBundle::South:
399 case WireBundle::East: {
404 case WireBundle::TileControl:
413 WireBundle bundle)
const {
416 case WireBundle::FIFO:
418 case WireBundle::North:
420 case WireBundle::West: {
425 case WireBundle::South:
427 case WireBundle::East: {
432 case WireBundle::Trace:
434 case WireBundle::TileControl:
441 case WireBundle::Core:
442 case WireBundle::DMA:
443 case WireBundle::FIFO:
445 case WireBundle::North: {
446 if (row ==
rows() - 1)
450 case WireBundle::West: {
455 case WireBundle::South:
457 case WireBundle::East: {
462 case WireBundle::Trace:
464 case WireBundle::TileControl:
472 WireBundle bundle)
const {
475 case WireBundle::DMA:
477 case WireBundle::NOC:
479 case WireBundle::PLIO:
481 case WireBundle::South:
490 WireBundle bundle)
const {
493 case WireBundle::DMA:
495 case WireBundle::NOC:
497 case WireBundle::PLIO:
499 case WireBundle::South:
508 WireBundle srcBundle,
int srcChan,
509 WireBundle dstBundle,
527 if (srcBundle == WireBundle::Trace)
528 return dstBundle == WireBundle::South;
533 if (srcBundle == WireBundle::Trace)
534 return dstBundle == WireBundle::South;
541std::vector<std::pair<uint32_t, uint32_t>>
543 return {std::pair(0, 64), std::pair(1, 128), std::pair(2, 256)};
546std::optional<uint32_t>
559static constexpr uint32_t S_CORE_OFFSET = 0;
560static constexpr uint32_t S_CORE_SIZE = 2;
561static constexpr uint32_t S_CTRL_OFFSET = 4;
562static constexpr uint32_t S_CTRL_SIZE = 1;
563static constexpr uint32_t S_DMA_OFFSET = 2;
564static constexpr uint32_t S_DMA_SIZE = 2;
565static constexpr uint32_t S_EAST_OFFSET = 21;
566static constexpr uint32_t S_EAST_SIZE = 4;
567static constexpr uint32_t S_FIFO_OFFSET = 5;
568static constexpr uint32_t S_FIFO_SIZE = 2;
569static constexpr uint32_t S_NORTH_OFFSET = 17;
570static constexpr uint32_t S_NORTH_SIZE = 4;
571static constexpr uint32_t S_SOUTH_OFFSET = 7;
572static constexpr uint32_t S_SOUTH_SIZE = 6;
573static constexpr uint32_t S_TRACE_OFFSET = 25;
574static constexpr uint32_t S_TRACE_SIZE = 2;
575static constexpr uint32_t S_WEST_OFFSET = 13;
576static constexpr uint32_t S_WEST_SIZE = 4;
579static constexpr uint32_t M_CORE_OFFSET = 0;
580static constexpr uint32_t M_CORE_SIZE = 2;
581static constexpr uint32_t M_CTRL_OFFSET = 4;
582static constexpr uint32_t M_CTRL_SIZE = 1;
583static constexpr uint32_t M_DMA_OFFSET = 2;
584static constexpr uint32_t M_DMA_SIZE = 2;
585static constexpr uint32_t M_EAST_OFFSET = 21;
586static constexpr uint32_t M_EAST_SIZE = 4;
587static constexpr uint32_t M_FIFO_OFFSET = 5;
588static constexpr uint32_t M_FIFO_SIZE = 2;
589static constexpr uint32_t M_NORTH_OFFSET = 15;
590static constexpr uint32_t M_NORTH_SIZE = 6;
591static constexpr uint32_t M_SOUTH_OFFSET = 7;
592static constexpr uint32_t M_SOUTH_SIZE = 4;
593static constexpr uint32_t M_WEST_OFFSET = 11;
594static constexpr uint32_t M_WEST_SIZE = 4;
601static constexpr uint32_t S_CTRL_OFFSET = 0;
602static constexpr uint32_t S_CTRL_SIZE = 1;
603static constexpr uint32_t S_EAST_OFFSET = 19;
604static constexpr uint32_t S_EAST_SIZE = 4;
605static constexpr uint32_t S_FIFO_OFFSET = 1;
606static constexpr uint32_t S_FIFO_SIZE = 2;
607static constexpr uint32_t S_NORTH_OFFSET = 15;
608static constexpr uint32_t S_NORTH_SIZE = 4;
609static constexpr uint32_t S_SOUTH_OFFSET = 3;
610static constexpr uint32_t S_SOUTH_SIZE = 8;
611static constexpr uint32_t S_TRACE_OFFSET = 23;
612static constexpr uint32_t S_TRACE_SIZE = 1;
613static constexpr uint32_t S_WEST_OFFSET = 11;
614static constexpr uint32_t S_WEST_SIZE = 4;
617static constexpr uint32_t M_CTRL_OFFSET = 0;
618static constexpr uint32_t M_CTRL_SIZE = 1;
619static constexpr uint32_t M_EAST_OFFSET = 19;
620static constexpr uint32_t M_EAST_SIZE = 4;
621static constexpr uint32_t M_FIFO_OFFSET = 1;
622static constexpr uint32_t M_FIFO_SIZE = 2;
623static constexpr uint32_t M_NORTH_OFFSET = 13;
624static constexpr uint32_t M_NORTH_SIZE = 6;
625static constexpr uint32_t M_SOUTH_OFFSET = 3;
626static constexpr uint32_t M_SOUTH_SIZE = 6;
627static constexpr uint32_t M_WEST_OFFSET = 9;
628static constexpr uint32_t M_WEST_SIZE = 4;
635 int col,
int row, WireBundle bundle, uint32_t port_num,
bool master)
const {
639 case WireBundle::Core:
640 if (port_num >= aie1_port_id::core::M_CORE_SIZE)
642 return aie1_port_id::core::M_CORE_OFFSET + port_num;
643 case WireBundle::TileControl:
644 if (port_num >= aie1_port_id::core::M_CTRL_SIZE)
646 return aie1_port_id::core::M_CTRL_OFFSET + port_num;
647 case WireBundle::DMA:
648 if (port_num >= aie1_port_id::core::M_DMA_SIZE)
650 return aie1_port_id::core::M_DMA_OFFSET + port_num;
651 case WireBundle::East:
652 if (port_num >= aie1_port_id::core::M_EAST_SIZE)
654 return aie1_port_id::core::M_EAST_OFFSET + port_num;
655 case WireBundle::FIFO:
656 if (port_num >= aie1_port_id::core::M_FIFO_SIZE)
658 return aie1_port_id::core::M_FIFO_OFFSET + port_num;
659 case WireBundle::North:
660 if (port_num >= aie1_port_id::core::M_NORTH_SIZE)
662 return aie1_port_id::core::M_NORTH_OFFSET + port_num;
663 case WireBundle::South:
664 if (port_num >= aie1_port_id::core::M_SOUTH_SIZE)
666 return aie1_port_id::core::M_SOUTH_OFFSET + port_num;
667 case WireBundle::West:
668 if (port_num >= aie1_port_id::core::M_WEST_SIZE)
670 return aie1_port_id::core::M_WEST_OFFSET + port_num;
676 case WireBundle::TileControl:
677 if (port_num >= aie1_port_id::shim::M_CTRL_SIZE)
679 return aie1_port_id::shim::M_CTRL_OFFSET + port_num;
680 case WireBundle::East:
681 if (port_num >= aie1_port_id::shim::M_EAST_SIZE)
683 return aie1_port_id::shim::M_EAST_OFFSET + port_num;
684 case WireBundle::FIFO:
685 if (port_num >= aie1_port_id::shim::M_FIFO_SIZE)
687 return aie1_port_id::shim::M_FIFO_OFFSET + port_num;
688 case WireBundle::North:
689 if (port_num >= aie1_port_id::shim::M_NORTH_SIZE)
691 return aie1_port_id::shim::M_NORTH_OFFSET + port_num;
692 case WireBundle::South:
693 if (port_num >= aie1_port_id::shim::M_SOUTH_SIZE)
695 return aie1_port_id::shim::M_SOUTH_OFFSET + port_num;
696 case WireBundle::West:
697 if (port_num >= aie1_port_id::shim::M_WEST_SIZE)
699 return aie1_port_id::shim::M_WEST_OFFSET + port_num;
709 case WireBundle::Core:
710 if (port_num >= aie1_port_id::core::S_CORE_SIZE)
712 return aie1_port_id::core::S_CORE_OFFSET + port_num;
713 case WireBundle::TileControl:
714 if (port_num >= aie1_port_id::core::S_CTRL_SIZE)
716 return aie1_port_id::core::S_CTRL_OFFSET + port_num;
717 case WireBundle::DMA:
718 if (port_num >= aie1_port_id::core::S_DMA_SIZE)
720 return aie1_port_id::core::S_DMA_OFFSET + port_num;
721 case WireBundle::East:
722 if (port_num >= aie1_port_id::core::S_EAST_SIZE)
724 return aie1_port_id::core::S_EAST_OFFSET + port_num;
725 case WireBundle::FIFO:
726 if (port_num >= aie1_port_id::core::S_FIFO_SIZE)
728 return aie1_port_id::core::S_FIFO_OFFSET + port_num;
729 case WireBundle::North:
730 if (port_num >= aie1_port_id::core::S_NORTH_SIZE)
732 return aie1_port_id::core::S_NORTH_OFFSET + port_num;
733 case WireBundle::South:
734 if (port_num >= aie1_port_id::core::S_SOUTH_SIZE)
736 return aie1_port_id::core::S_SOUTH_OFFSET + port_num;
737 case WireBundle::Trace:
738 if (port_num >= aie1_port_id::core::S_TRACE_SIZE)
740 return aie1_port_id::core::S_TRACE_OFFSET + port_num;
741 case WireBundle::West:
742 if (port_num >= aie1_port_id::core::S_WEST_SIZE)
744 return aie1_port_id::core::S_WEST_OFFSET + port_num;
750 case WireBundle::TileControl:
751 if (port_num >= aie1_port_id::shim::S_CTRL_SIZE)
753 return aie1_port_id::shim::S_CTRL_OFFSET + port_num;
754 case WireBundle::East:
755 if (port_num >= aie1_port_id::shim::S_EAST_SIZE)
757 return aie1_port_id::shim::S_EAST_OFFSET + port_num;
758 case WireBundle::FIFO:
759 if (port_num >= aie1_port_id::shim::S_FIFO_SIZE)
761 return aie1_port_id::shim::S_FIFO_OFFSET + port_num;
762 case WireBundle::North:
763 if (port_num >= aie1_port_id::shim::S_NORTH_SIZE)
765 return aie1_port_id::shim::S_NORTH_OFFSET + port_num;
766 case WireBundle::South:
767 if (port_num >= aie1_port_id::shim::S_SOUTH_SIZE)
769 return aie1_port_id::shim::S_SOUTH_OFFSET + port_num;
770 case WireBundle::Trace:
771 if (port_num >= aie1_port_id::shim::S_TRACE_SIZE)
773 return aie1_port_id::shim::S_TRACE_OFFSET + port_num;
774 case WireBundle::West:
775 if (port_num >= aie1_port_id::shim::S_WEST_SIZE)
777 return aie1_port_id::shim::S_WEST_OFFSET + port_num;
791std::unique_ptr<RegisterDatabase>
800 std::optional<TileID> ret({src.col - 1, src.row});
809 std::optional ret = src;
818 std::optional<TileID> ret({src.col, src.row + 1});
825 std::optional<TileID> ret({src.col, src.row - 1});
835 return isWest(srcCol, srcRow, dstCol, dstRow);
840 return isInternal(srcCol, srcRow, dstCol, dstRow);
845 return isNorth(srcCol, srcRow, dstCol, dstRow);
850 return isSouth(srcCol, srcRow, dstCol, dstRow);
856 bool IsMemWest =
isMemWest(coreCol, coreRow, memCol, memRow);
857 bool IsMemEast =
isMemEast(coreCol, coreRow, memCol, memRow);
858 bool IsMemNorth =
isMemNorth(coreCol, coreRow, memCol, memRow);
859 bool IsMemSouth =
isMemSouth(coreCol, coreRow, memCol, memRow);
862 return isEast(coreCol, coreRow, memCol, memRow) ||
863 isInternal(coreCol, coreRow, memCol, memRow) ||
864 isWest(coreCol, coreRow, memCol, memRow);
865 return (IsMemSouth && !
isMemTile(memCol, memRow)) || IsMemNorth ||
866 IsMemWest || IsMemEast;
871 AIE::DMAChannelDir direction)
const {
879 offset = 0x0001D000 + bd_id * 0x20;
881 offset = 0x000A0000 + bd_id * 0x20;
883 offset = 0x0001D000 + bd_id * 0x20;
886 "AIE2TargetModel::getDmaBdAddress called for non-DMA tile");
927 l.enablePacket = {0, 31, 1};
928 l.packetType = {0, 28, 3};
929 l.packetId = {0, 23, 5};
930 l.outOfOrderId = {0, 17, 6};
931 l.bufferLength = {0, 0, 17};
932 l.d0ZeroBefore = {1, 26, 6};
933 l.nextBd = {1, 20, 6};
934 l.useNextBd = {1, 19, 1};
935 l.bufferOffset = {1, 0, 19};
936 l.d0Size = {2, 17, 10};
937 l.d0Stride = {2, 0, 17};
938 l.d1ZeroBefore = {3, 27, 5};
939 l.d1Size = {3, 17, 10};
940 l.d1Stride = {3, 0, 17};
941 l.d2ZeroBefore = {4, 27, 4};
942 l.d2Stride = {4, 0, 17};
943 l.d2ZeroAfter = {5, 28, 4};
944 l.d1ZeroAfter = {5, 23, 5};
945 l.d0ZeroAfter = {5, 17, 6};
946 l.iterationCurrent = {6, 23, 6};
947 l.iterationSize = {6, 17, 6};
948 l.iterationStride = {6, 0, 17};
949 l.validBd = {7, 31, 1};
950 l.lockRelValue = {7, 24, 7};
951 l.lockRelId = {7, 16, 8};
952 l.lockAcqEnable = {7, 15, 1};
953 l.lockAcqValue = {7, 8, 7};
954 l.lockAcqId = {7, 0, 8};
962 l.bufferOffset = {0, 14, 14};
963 l.bufferLength = {0, 0, 14};
964 l.enablePacket = {1, 30, 1};
965 l.outOfOrderId = {1, 24, 6};
966 l.packetId = {1, 19, 5};
967 l.packetType = {1, 16, 3};
968 l.d1Stride = {2, 13, 13};
969 l.d0Stride = {2, 0, 13};
970 l.d1Size = {3, 21, 8};
971 l.d0Size = {3, 13, 8};
972 l.d2Stride = {3, 0, 13};
973 l.iterationCurrent = {4, 19, 6};
974 l.iterationSize = {4, 13, 6};
975 l.iterationStride = {4, 0, 13};
976 l.nextBd = {5, 27, 4};
977 l.useNextBd = {5, 26, 1};
978 l.validBd = {5, 25, 1};
979 l.lockRelValue = {5, 18, 7};
980 l.lockRelId = {5, 13, 4};
981 l.lockAcqEnable = {5, 12, 1};
982 l.lockAcqValue = {5, 5, 7};
983 l.lockAcqId = {5, 0, 4};
988 static const DmaBdLayout shim = makeAIE2ShimBdLayout();
989 static const DmaBdLayout mem = makeAIE2MemTileBdLayout();
990 static const DmaBdLayout core = makeAIE2CoreTileBdLayout();
992 case AIETileType::ShimNOCTile:
994 case AIETileType::MemTile:
996 case AIETileType::CoreTile:
1011 AIE::DMAChannelDir direction)
const {
1012 uint32_t offset = 0;
1014 offset = 0x0001D200 + (channel * 0x8);
1015 if (direction == AIE::DMAChannelDir::MM2S)
1018 offset = 0x000A0600 + (channel * 0x8);
1019 if (direction == AIE::DMAChannelDir::MM2S)
1022 offset = 0x0001DE00 + (channel * 0x8);
1023 if (direction == AIE::DMAChannelDir::MM2S)
1027 "AIE2TargetModel::getDmaControlAddress called for non-DMA tile");
1033std::optional<uint32_t>
1035 AIE::DMAChannelDir direction)
const {
1038 uint32_t offset = 0;
1040 offset = 0x0001D220 + (channel * 0x4);
1041 if (direction == AIE::DMAChannelDir::MM2S)
1044 offset = 0x000A0660 + (channel * 0x4);
1045 if (direction == AIE::DMAChannelDir::MM2S)
1048 offset = 0x0001DF00 + (channel * 0x4);
1049 if (direction == AIE::DMAChannelDir::MM2S)
1052 return std::nullopt;
1060 WireBundle bundle)
const {
1063 case WireBundle::DMA:
1064 case WireBundle::North:
1066 case WireBundle::South:
1068 case WireBundle::TileControl:
1076 case WireBundle::FIFO:
1078 case WireBundle::North:
1080 case WireBundle::West: {
1085 case WireBundle::South:
1087 case WireBundle::East: {
1092 case WireBundle::TileControl:
1099 case WireBundle::Core:
1101 case WireBundle::DMA:
1103 case WireBundle::FIFO:
1105 case WireBundle::North: {
1106 if (row ==
rows() - 1)
1110 case WireBundle::West: {
1115 case WireBundle::South:
1117 case WireBundle::East: {
1122 case WireBundle::TileControl:
1131 WireBundle bundle)
const {
1134 case WireBundle::DMA:
1136 case WireBundle::North:
1138 case WireBundle::South:
1140 case WireBundle::Trace:
1141 case WireBundle::TileControl:
1149 case WireBundle::FIFO:
1151 case WireBundle::North:
1153 case WireBundle::West: {
1158 case WireBundle::South:
1160 case WireBundle::East: {
1165 case WireBundle::Trace:
1167 case WireBundle::TileControl:
1175 case WireBundle::Core:
1177 case WireBundle::DMA:
1179 case WireBundle::FIFO:
1181 case WireBundle::North: {
1182 if (row ==
rows() - 1)
1186 case WireBundle::West: {
1191 case WireBundle::South:
1193 case WireBundle::East: {
1198 case WireBundle::Trace:
1201 case WireBundle::TileControl:
1210 WireBundle bundle)
const {
1213 case WireBundle::DMA:
1215 case WireBundle::NOC:
1217 case WireBundle::PLIO:
1219 case WireBundle::South:
1230 WireBundle bundle)
const {
1233 case WireBundle::DMA:
1235 case WireBundle::NOC:
1237 case WireBundle::PLIO:
1239 case WireBundle::South:
1249 WireBundle srcBundle,
int srcChan,
1250 WireBundle dstBundle,
1251 int dstChan)
const {
1259 auto isBundleInList = [](WireBundle bundle,
1260 std::initializer_list<WireBundle> bundles) {
1261 return llvm::find(bundles, bundle) != bundles.end();
1266 if (srcBundle == WireBundle::DMA) {
1267 if (dstBundle == WireBundle::DMA)
1268 return srcChan == dstChan;
1269 if (isBundleInList(dstBundle, {WireBundle::TileControl, WireBundle::South,
1270 WireBundle::North}))
1273 if (srcBundle == WireBundle::TileControl) {
1274 if (dstBundle == WireBundle::DMA)
1275 return dstChan == 5;
1276 if (isBundleInList(dstBundle, {WireBundle::South, WireBundle::North}))
1279 if (isBundleInList(srcBundle, {WireBundle::South, WireBundle::North})) {
1280 if (isBundleInList(dstBundle, {WireBundle::DMA, WireBundle::TileControl}))
1282 if (isBundleInList(dstBundle, {WireBundle::South, WireBundle::North}))
1283 return srcChan == dstChan;
1285 if (srcBundle == WireBundle::Trace) {
1286 if (dstBundle == WireBundle::DMA)
1287 return dstChan == 5;
1288 if (dstBundle == WireBundle::South)
1294 if (srcBundle == WireBundle::TileControl)
1295 return dstBundle != WireBundle::TileControl;
1296 if (isBundleInList(srcBundle, {WireBundle::FIFO, WireBundle::South}))
1297 return isBundleInList(dstBundle,
1298 {WireBundle::TileControl, WireBundle::FIFO,
1299 WireBundle::South, WireBundle::West,
1300 WireBundle::North, WireBundle::East});
1301 if (isBundleInList(srcBundle,
1302 {WireBundle::West, WireBundle::North, WireBundle::East}))
1303 return (srcBundle == dstBundle)
1304 ? (srcChan == dstChan)
1305 : isBundleInList(dstBundle,
1306 {WireBundle::TileControl, WireBundle::FIFO,
1307 WireBundle::South, WireBundle::West,
1308 WireBundle::North, WireBundle::East});
1309 if (srcBundle == WireBundle::Trace) {
1310 if (isBundleInList(dstBundle, {WireBundle::FIFO, WireBundle::South}))
1312 if (isBundleInList(dstBundle, {WireBundle::West, WireBundle::East}))
1313 return dstChan == 0;
1318 if (isBundleInList(srcBundle,
1319 {WireBundle::DMA, WireBundle::FIFO, WireBundle::South,
1320 WireBundle::West, WireBundle::North, WireBundle::East}))
1321 if (isBundleInList(dstBundle, {WireBundle::Core, WireBundle::DMA,
1322 WireBundle::TileControl, WireBundle::FIFO,
1323 WireBundle::South, WireBundle::West,
1324 WireBundle::North, WireBundle::East}))
1325 return (srcBundle == dstBundle) ? (srcChan == dstChan) :
true;
1326 if (srcBundle == WireBundle::Core)
1327 return dstBundle != WireBundle::Core;
1328 if (srcBundle == WireBundle::TileControl)
1329 return dstBundle != WireBundle::TileControl &&
1330 dstBundle != WireBundle::DMA;
1331 if (srcBundle == WireBundle::Trace) {
1332 if (dstBundle == WireBundle::DMA)
1333 return dstChan == 0;
1334 if (isBundleInList(dstBundle, {WireBundle::FIFO, WireBundle::South}))
1341std::vector<std::pair<uint32_t, uint32_t>>
1343 return {std::pair(0, 64), std::pair(1, 128), std::pair(2, 256)};
1346std::optional<uint32_t>
1348 auto computeTileBaseAddress = 0x0001F000;
1349 auto memTileBaseAddress = 0x000C0000;
1350 auto shimTileBaseAddress = 0x00014000;
1351 auto lockAddrOffset = 0x10;
1355 return computeTileBaseAddress + lockAddrOffset * lockId;
1358 return memTileBaseAddress + lockAddrOffset * lockId;
1362 return shimTileBaseAddress + lockAddrOffset * lockId;
1364 return std::nullopt;
1372static constexpr uint32_t S_CORE_OFFSET = 0;
1373static constexpr uint32_t S_CORE_SIZE = 1;
1374static constexpr uint32_t S_CTRL_OFFSET = 3;
1375static constexpr uint32_t S_CTRL_SIZE = 1;
1376static constexpr uint32_t S_DMA_OFFSET = 1;
1377static constexpr uint32_t S_DMA_SIZE = 2;
1378static constexpr uint32_t S_EAST_OFFSET = 19;
1379static constexpr uint32_t S_EAST_SIZE = 4;
1380static constexpr uint32_t S_FIFO_OFFSET = 4;
1381static constexpr uint32_t S_FIFO_SIZE = 1;
1382static constexpr uint32_t S_NORTH_OFFSET = 15;
1383static constexpr uint32_t S_NORTH_SIZE = 4;
1384static constexpr uint32_t S_SOUTH_OFFSET = 5;
1385static constexpr uint32_t S_SOUTH_SIZE = 6;
1386static constexpr uint32_t S_TRACE_OFFSET = 23;
1387static constexpr uint32_t S_TRACE_SIZE = 2;
1388static constexpr uint32_t S_WEST_OFFSET = 11;
1389static constexpr uint32_t S_WEST_SIZE = 4;
1392static constexpr uint32_t M_CORE_OFFSET = 0;
1393static constexpr uint32_t M_CORE_SIZE = 1;
1394static constexpr uint32_t M_CTRL_OFFSET = 3;
1395static constexpr uint32_t M_CTRL_SIZE = 1;
1396static constexpr uint32_t M_DMA_OFFSET = 1;
1397static constexpr uint32_t M_DMA_SIZE = 2;
1398static constexpr uint32_t M_EAST_OFFSET = 19;
1399static constexpr uint32_t M_EAST_SIZE = 4;
1400static constexpr uint32_t M_FIFO_OFFSET = 4;
1401static constexpr uint32_t M_FIFO_SIZE = 1;
1402static constexpr uint32_t M_NORTH_OFFSET = 13;
1403static constexpr uint32_t M_NORTH_SIZE = 6;
1404static constexpr uint32_t M_SOUTH_OFFSET = 5;
1405static constexpr uint32_t M_SOUTH_SIZE = 4;
1406static constexpr uint32_t M_WEST_OFFSET = 9;
1407static constexpr uint32_t M_WEST_SIZE = 4;
1414static constexpr uint32_t S_CTRL_OFFSET = 6;
1415static constexpr uint32_t S_CTRL_SIZE = 1;
1416static constexpr uint32_t S_DMA_OFFSET = 0;
1417static constexpr uint32_t S_DMA_SIZE = 6;
1418static constexpr uint32_t S_NORTH_OFFSET = 13;
1419static constexpr uint32_t S_NORTH_SIZE = 4;
1420static constexpr uint32_t S_SOUTH_OFFSET = 7;
1421static constexpr uint32_t S_SOUTH_SIZE = 6;
1422static constexpr uint32_t S_TRACE_OFFSET = 17;
1423static constexpr uint32_t S_TRACE_SIZE = 1;
1426static constexpr uint32_t M_CTRL_OFFSET = 6;
1427static constexpr uint32_t M_CTRL_SIZE = 1;
1428static constexpr uint32_t M_DMA_OFFSET = 0;
1429static constexpr uint32_t M_DMA_SIZE = 6;
1430static constexpr uint32_t M_NORTH_OFFSET = 11;
1431static constexpr uint32_t M_NORTH_SIZE = 6;
1432static constexpr uint32_t M_SOUTH_OFFSET = 7;
1433static constexpr uint32_t M_SOUTH_SIZE = 4;
1440static constexpr uint32_t S_CTRL_OFFSET = 0;
1441static constexpr uint32_t S_CTRL_SIZE = 1;
1442static constexpr uint32_t S_EAST_OFFSET = 18;
1443static constexpr uint32_t S_EAST_SIZE = 4;
1444static constexpr uint32_t S_FIFO_OFFSET = 1;
1445static constexpr uint32_t S_FIFO_SIZE = 1;
1446static constexpr uint32_t S_NORTH_OFFSET = 14;
1447static constexpr uint32_t S_NORTH_SIZE = 4;
1448static constexpr uint32_t S_SOUTH_OFFSET = 2;
1449static constexpr uint32_t S_SOUTH_SIZE = 8;
1450static constexpr uint32_t S_TRACE_OFFSET = 22;
1451static constexpr uint32_t S_TRACE_SIZE = 2;
1452static constexpr uint32_t S_WEST_OFFSET = 10;
1453static constexpr uint32_t S_WEST_SIZE = 4;
1456static constexpr uint32_t M_CTRL_OFFSET = 0;
1457static constexpr uint32_t M_CTRL_SIZE = 1;
1458static constexpr uint32_t M_EAST_OFFSET = 18;
1459static constexpr uint32_t M_EAST_SIZE = 4;
1460static constexpr uint32_t M_FIFO_OFFSET = 1;
1461static constexpr uint32_t M_FIFO_SIZE = 1;
1462static constexpr uint32_t M_NORTH_OFFSET = 12;
1463static constexpr uint32_t M_NORTH_SIZE = 6;
1464static constexpr uint32_t M_SOUTH_OFFSET = 2;
1465static constexpr uint32_t M_SOUTH_SIZE = 6;
1466static constexpr uint32_t M_WEST_OFFSET = 8;
1467static constexpr uint32_t M_WEST_SIZE = 4;
1474 int col,
int row, WireBundle bundle, uint32_t port_num,
bool master)
const {
1479 case WireBundle::Core:
1480 if (port_num >= aie2_port_id::core::M_CORE_SIZE)
1481 return std::nullopt;
1482 return aie2_port_id::core::M_CORE_OFFSET + port_num;
1483 case WireBundle::TileControl:
1484 if (port_num >= aie2_port_id::core::M_CTRL_SIZE)
1485 return std::nullopt;
1486 return aie2_port_id::core::M_CTRL_OFFSET + port_num;
1487 case WireBundle::DMA:
1488 if (port_num >= aie2_port_id::core::M_DMA_SIZE)
1489 return std::nullopt;
1490 return aie2_port_id::core::M_DMA_OFFSET + port_num;
1491 case WireBundle::East:
1492 if (port_num >= aie2_port_id::core::M_EAST_SIZE)
1493 return std::nullopt;
1494 return aie2_port_id::core::M_EAST_OFFSET + port_num;
1495 case WireBundle::FIFO:
1496 if (port_num >= aie2_port_id::core::M_FIFO_SIZE)
1497 return std::nullopt;
1498 return aie2_port_id::core::M_FIFO_OFFSET + port_num;
1499 case WireBundle::North:
1500 if (port_num >= aie2_port_id::core::M_NORTH_SIZE)
1501 return std::nullopt;
1502 return aie2_port_id::core::M_NORTH_OFFSET + port_num;
1503 case WireBundle::South:
1504 if (port_num >= aie2_port_id::core::M_SOUTH_SIZE)
1505 return std::nullopt;
1506 return aie2_port_id::core::M_SOUTH_OFFSET + port_num;
1507 case WireBundle::West:
1508 if (port_num >= aie2_port_id::core::M_WEST_SIZE)
1509 return std::nullopt;
1510 return aie2_port_id::core::M_WEST_OFFSET + port_num;
1512 return std::nullopt;
1516 case WireBundle::TileControl:
1517 if (port_num >= aie2_port_id::mem::M_CTRL_SIZE)
1518 return std::nullopt;
1519 return aie2_port_id::mem::M_CTRL_OFFSET + port_num;
1520 case WireBundle::DMA:
1521 if (port_num >= aie2_port_id::mem::M_DMA_SIZE)
1522 return std::nullopt;
1523 return aie2_port_id::mem::M_DMA_OFFSET + port_num;
1524 case WireBundle::North:
1525 if (port_num >= aie2_port_id::mem::M_NORTH_SIZE)
1526 return std::nullopt;
1527 return aie2_port_id::mem::M_NORTH_OFFSET + port_num;
1528 case WireBundle::South:
1529 if (port_num >= aie2_port_id::mem::M_SOUTH_SIZE)
1530 return std::nullopt;
1531 return aie2_port_id::mem::M_SOUTH_OFFSET + port_num;
1533 return std::nullopt;
1537 case WireBundle::TileControl:
1538 if (port_num >= aie2_port_id::shim::M_CTRL_SIZE)
1539 return std::nullopt;
1540 return aie2_port_id::shim::M_CTRL_OFFSET + port_num;
1541 case WireBundle::East:
1542 if (port_num >= aie2_port_id::shim::M_EAST_SIZE)
1543 return std::nullopt;
1544 return aie2_port_id::shim::M_EAST_OFFSET + port_num;
1545 case WireBundle::FIFO:
1546 if (port_num >= aie2_port_id::shim::M_FIFO_SIZE)
1547 return std::nullopt;
1548 return aie2_port_id::shim::M_FIFO_OFFSET + port_num;
1549 case WireBundle::North:
1550 if (port_num >= aie2_port_id::shim::M_NORTH_SIZE)
1551 return std::nullopt;
1552 return aie2_port_id::shim::M_NORTH_OFFSET + port_num;
1553 case WireBundle::South:
1554 if (port_num >= aie2_port_id::shim::M_SOUTH_SIZE)
1555 return std::nullopt;
1556 return aie2_port_id::shim::M_SOUTH_OFFSET + port_num;
1557 case WireBundle::West:
1558 if (port_num >= aie2_port_id::shim::M_WEST_SIZE)
1559 return std::nullopt;
1560 return aie2_port_id::shim::M_WEST_OFFSET + port_num;
1562 return std::nullopt;
1570 case WireBundle::Core:
1571 if (port_num >= aie2_port_id::core::S_CORE_SIZE)
1572 return std::nullopt;
1573 return aie2_port_id::core::S_CORE_OFFSET + port_num;
1574 case WireBundle::TileControl:
1575 if (port_num >= aie2_port_id::core::S_CTRL_SIZE)
1576 return std::nullopt;
1577 return aie2_port_id::core::S_CTRL_OFFSET + port_num;
1578 case WireBundle::DMA:
1579 if (port_num >= aie2_port_id::core::S_DMA_SIZE)
1580 return std::nullopt;
1581 return aie2_port_id::core::S_DMA_OFFSET + port_num;
1582 case WireBundle::East:
1583 if (port_num >= aie2_port_id::core::S_EAST_SIZE)
1584 return std::nullopt;
1585 return aie2_port_id::core::S_EAST_OFFSET + port_num;
1586 case WireBundle::FIFO:
1587 if (port_num >= aie2_port_id::core::S_FIFO_SIZE)
1588 return std::nullopt;
1589 return aie2_port_id::core::S_FIFO_OFFSET + port_num;
1590 case WireBundle::North:
1591 if (port_num >= aie2_port_id::core::S_NORTH_SIZE)
1592 return std::nullopt;
1593 return aie2_port_id::core::S_NORTH_OFFSET + port_num;
1594 case WireBundle::South:
1595 if (port_num >= aie2_port_id::core::S_SOUTH_SIZE)
1596 return std::nullopt;
1597 return aie2_port_id::core::S_SOUTH_OFFSET + port_num;
1598 case WireBundle::Trace:
1599 if (port_num >= aie2_port_id::core::S_TRACE_SIZE)
1600 return std::nullopt;
1601 return aie2_port_id::core::S_TRACE_OFFSET + port_num;
1602 case WireBundle::West:
1603 if (port_num >= aie2_port_id::core::S_WEST_SIZE)
1604 return std::nullopt;
1605 return aie2_port_id::core::S_WEST_OFFSET + port_num;
1607 return std::nullopt;
1611 case WireBundle::TileControl:
1612 if (port_num >= aie2_port_id::mem::S_CTRL_SIZE)
1613 return std::nullopt;
1614 return aie2_port_id::mem::S_CTRL_OFFSET + port_num;
1615 case WireBundle::DMA:
1616 if (port_num >= aie2_port_id::mem::S_DMA_SIZE)
1617 return std::nullopt;
1618 return aie2_port_id::mem::S_DMA_OFFSET + port_num;
1619 case WireBundle::North:
1620 if (port_num >= aie2_port_id::mem::S_NORTH_SIZE)
1621 return std::nullopt;
1622 return aie2_port_id::mem::S_NORTH_OFFSET + port_num;
1623 case WireBundle::South:
1624 if (port_num >= aie2_port_id::mem::S_SOUTH_SIZE)
1625 return std::nullopt;
1626 return aie2_port_id::mem::S_SOUTH_OFFSET + port_num;
1627 case WireBundle::Trace:
1628 if (port_num >= aie2_port_id::mem::S_TRACE_SIZE)
1629 return std::nullopt;
1630 return aie2_port_id::mem::S_TRACE_OFFSET + port_num;
1632 return std::nullopt;
1636 case WireBundle::TileControl:
1637 if (port_num >= aie2_port_id::shim::S_CTRL_SIZE)
1638 return std::nullopt;
1639 return aie2_port_id::shim::S_CTRL_OFFSET + port_num;
1640 case WireBundle::East:
1641 if (port_num >= aie2_port_id::shim::S_EAST_SIZE)
1642 return std::nullopt;
1643 return aie2_port_id::shim::S_EAST_OFFSET + port_num;
1644 case WireBundle::FIFO:
1645 if (port_num >= aie2_port_id::shim::S_FIFO_SIZE)
1646 return std::nullopt;
1647 return aie2_port_id::shim::S_FIFO_OFFSET + port_num;
1648 case WireBundle::North:
1649 if (port_num >= aie2_port_id::shim::S_NORTH_SIZE)
1650 return std::nullopt;
1651 return aie2_port_id::shim::S_NORTH_OFFSET + port_num;
1652 case WireBundle::South:
1653 if (port_num >= aie2_port_id::shim::S_SOUTH_SIZE)
1654 return std::nullopt;
1655 return aie2_port_id::shim::S_SOUTH_OFFSET + port_num;
1656 case WireBundle::Trace:
1657 if (port_num >= aie2_port_id::shim::S_TRACE_SIZE)
1658 return std::nullopt;
1659 return aie2_port_id::shim::S_TRACE_OFFSET + port_num;
1660 case WireBundle::West:
1661 if (port_num >= aie2_port_id::shim::S_WEST_SIZE)
1662 return std::nullopt;
1663 return aie2_port_id::shim::S_WEST_OFFSET + port_num;
1665 return std::nullopt;
1669 return std::nullopt;
1675 for (
int j = 0; j <
columns(); j++) {
1683 for (
int j = 0; j <
columns(); j++)
1689 for (
int j = 0; j <
columns(); j++)
1694 for (
int i = 0; i <
rows() - 1; i++)
1695 for (
int j = 0; j <
columns(); j++)
1699 for (
int i = 1; i <
rows(); i++)
1700 for (
int j = 0; j <
columns(); j++)
1704 for (
int i = 0; i <
rows(); i++)
1705 for (
int j = 0; j <
columns() - 1; j++)
1709 for (
int i = 0; i <
rows(); i++)
1710 for (
int j = 1; j <
columns(); j++)
1714 for (
int j = 0; j <
columns(); j++)
1717 for (
int i = 0; i <
rows(); i++)
1719 WireBundle::East) == 0);
1720 for (
int i = 0; i <
rows(); i++)
1724 for (
int i = 0; i <
rows(); i++)
1725 for (
int j = 0; j <
columns(); j++)
1730std::optional<uint32_t>
1732 int lockRow)
const {
1734 if (
isMemSouth(localCol, localRow, lockCol, lockRow))
1736 if (
isMemWest(localCol, localRow, lockCol, lockRow))
1738 if (
isMemNorth(localCol, localRow, lockCol, lockRow))
1740 if (
isMemEast(localCol, localRow, lockCol, lockRow))
1745 if (
isWest(localCol, localRow, lockCol, lockRow))
1747 if (
isInternal(localCol, localRow, lockCol, lockRow))
1749 if (
isEast(localCol, localRow, lockCol, lockRow))
1753 return std::nullopt;
1756std::optional<uint32_t>
1760 if (
isMemSouth(localCol, localRow, memCol, memRow))
1762 if (
isMemWest(localCol, localRow, memCol, memRow))
1764 if (
isMemNorth(localCol, localRow, memCol, memRow))
1766 if (
isMemEast(localCol, localRow, memCol, memRow))
1771 if (
isWest(localCol, localRow, memCol, memRow))
1773 if (
isInternal(localCol, localRow, memCol, memRow))
1775 if (
isEast(localCol, localRow, memCol, memRow))
1779 return std::nullopt;
1783 AIE::DMAChannelDir dir)
const {
1786 !symbolizeDMAChannelDir(
static_cast<uint32_t
>(dir)))
1803std::vector<std::pair<uint32_t, uint32_t>>
1805 return {std::pair(0, 64), std::pair(1, 128), std::pair(2, 256),
1810 std::string
const &format)
const {
1811 std::set<std::string> supportedTypes = {
"v8bfp16ebs8",
"v16bfp16ebs16"};
1812 return static_cast<bool>(supportedTypes.find(format) != supportedTypes.end());
1820 AIE::DMAChannelDir direction)
const {
1822 uint64_t offset = 0x00009000 + bd_id * 0x30;
1831 AIE::DMAChannelDir direction)
const {
1833 uint32_t offset = 0x00009300 + (channel * 0x8);
1834 if (direction == AIE::DMAChannelDir::MM2S)
1842std::optional<uint32_t>
1844 AIE::DMAChannelDir direction)
const {
1850 return std::nullopt;
1857 WireBundle bundle)
const {
1858 if (
isShimNOCTile(col, row) && bundle == WireBundle::Controller32)
1865 WireBundle bundle)
const {
1866 if (
isShimNOCTile(col, row) && bundle == WireBundle::Controller32)
1872 int col,
int row, WireBundle bundle, uint32_t channel,
bool master)
const {
1874 if (
isShimNOCTile(col, row) && bundle == WireBundle::Controller32) {
1876 return std::nullopt;
1877 return master ? 22 : 23;
1887std::unique_ptr<RegisterDatabase>
1895 uint32_t addressRow =
static_cast<uint32_t
>(row);
1899 addressRow = 5 * addressRow - 4;
1907 if (addressRow == 0)
1909 if (addressRow <= 5 * memTileRows)
1910 return 1 + (addressRow - 1) / 5;
1911 return addressRow - 4 * memTileRows;
1915 return isMemTile(col, row) ? 0x00100000 : 0;
1919 std::optional ret = src;
1927 return isWest(srcCol, srcRow, dstCol, dstRow);
1932 return isInternal(srcCol, srcRow, dstCol, dstRow);
1937 return isNorth(srcCol, srcRow, dstCol, dstRow);
1942 return isSouth(srcCol, srcRow, dstCol, dstRow);
1948 return isEast(coreCol, coreRow, memCol, memRow) ||
1949 isInternal(coreCol, coreRow, memCol, memRow) ||
1950 isWest(coreCol, coreRow, memCol, memRow);
1951 return isMemEast(coreCol, coreRow, memCol, memRow);
1956static constexpr uint32_t aie4ShimControlPool = 2;
1957static constexpr uint32_t aie4ShimNumControlChannels = 2;
1958static constexpr uint32_t aie4ShimTracePool =
1959 aie4ShimControlPool + aie4ShimNumControlChannels;
1962 DMAChannelDir dir)
const {
1965 return 2 * channel + (mm2s ? 0 : 1);
1967 if (dir == DMAChannelDir::ControlMM2S)
1968 return aie4ShimControlPool + channel;
1969 if (dir == DMAChannelDir::TraceS2MM)
1970 return aie4ShimTracePool + channel;
1971 return channel >= (mm2s ? 2 : 1) ? 1 : 0;
1977 uint32_t poolId)
const {
1982 uint32_t poolId)
const {
1985 if (
isShimNOCTile(col, row) && poolId >= aie4ShimControlPool)
1990static void aie4ChannelOutOfRange(StringRef what,
int col,
int row,
1992 report_fatal_error(Twine(
"AIE4TargetModel::") + what +
": DMA channel " +
1993 Twine(channel) +
" is not available on tile (" +
1994 Twine(col) +
", " + Twine(row) +
")");
2000static DmaBdLayout makeAIE4CoreTileBdLayout() {
2004 l.bufferOffset = {0, 16, 15};
2005 l.bufferLength = {0, 0, 15};
2006 l.enablePacket = {1, 30, 1};
2007 l.outOfOrderId = {1, 24, 4};
2008 l.packetId = {1, 19, 5};
2009 l.packetType = {1, 16, 3};
2010 l.d1Stride = {2, 16, 15};
2011 l.iterationCurrent = {3, 26, 6};
2012 l.d0Size = {3, 17, 9};
2013 l.d2Stride = {3, 0, 15};
2014 l.d1Size = {4, 23, 9};
2015 l.iterationSize = {4, 17, 6};
2016 l.iterationStride = {4, 0, 15};
2017 l.nextBd = {5, 27, 4};
2018 l.useNextBd = {5, 26, 1};
2019 l.lockRelValue = {5, 18, 7};
2020 l.lockRelId = {5, 13, 4};
2021 l.lockAcqEnable = {5, 12, 1};
2022 l.lockAcqValue = {5, 5, 7};
2023 l.lockAcqId = {5, 0, 4};
2032 l.bufferOffset = {0, 0, 24};
2033 l.lockAcqValue = {1, 25, 7};
2034 l.bufferLength = {1, 0, 23};
2035 l.lockAcqId = {2, 20, 10};
2036 l.lockRelValue = {2, 11, 7};
2037 l.lockRelId = {2, 1, 10};
2038 l.lockAcqEnable = {2, 0, 1};
2039 l.d1Stride = {3, 0, 23};
2040 l.d2Stride = {4, 0, 23};
2041 l.d3Stride = {5, 0, 23};
2042 l.iterationStride = {6, 0, 23};
2043 l.iterationCurrent = {7, 22, 8};
2044 l.enablePacket = {7, 21, 1};
2045 l.packetId = {7, 16, 5};
2046 l.d0ZeroAfter = {7, 8, 8};
2047 l.d0ZeroBefore = {7, 0, 8};
2048 l.d2ZeroAfter = {8, 24, 8};
2049 l.d2ZeroBefore = {8, 16, 8};
2050 l.d1ZeroAfter = {8, 8, 8};
2051 l.d1ZeroBefore = {8, 0, 8};
2052 l.d1Size = {9, 19, 12};
2053 l.d0Size = {9, 5, 12};
2054 l.outOfOrderId = {9, 0, 4};
2055 l.nextBd = {10, 27, 4};
2056 l.useNextBd = {10, 26, 1};
2057 l.d2Size = {10, 14, 12};
2058 l.iterationSize = {10, 0, 8};
2068 l.bufferOffset = {1, 0, 32};
2069 l.bufferLength = {2, 0, 32};
2070 l.lockAcqId = {3, 27, 5};
2071 l.lockAcqEnable = {3, 26, 1};
2072 l.burstLength = {3, 24, 2};
2073 l.d1Size = {3, 12, 12};
2074 l.d2Size = {3, 0, 12};
2075 l.d0Size = {4, 19, 12};
2076 l.lockRelValue = {4, 12, 7};
2077 l.lockRelId = {4, 7, 5};
2078 l.lockAcqValue = {4, 0, 7};
2079 l.enablePacket = {5, 31, 1};
2080 l.nextBd = {5, 27, 4};
2081 l.useNextBd = {5, 26, 1};
2082 l.d1Stride = {5, 0, 22};
2083 l.iterationCurrent = {6, 24, 6};
2084 l.d2Stride = {6, 0, 22};
2085 l.axcache = {7, 28, 4};
2086 l.iterationSize = {7, 22, 6};
2087 l.iterationStride = {7, 0, 22};
2088 l.d3Stride = {8, 10, 22};
2089 l.outOfOrderId = {8, 5, 4};
2090 l.packetId = {8, 0, 5};
2096static DmaBdLayout makeAIE4ShimLinearBdLayout(
bool control) {
2100 l.bufferOffset = {1, 0, 32};
2101 l.bufferLength = {2, 0, uint8_t(control ? 24 : 32)};
2102 l.burstLength = {3, 24, 2};
2103 l.nextBd = {5, 27, 4};
2104 l.useNextBd = {5, 26, 1};
2105 l.iterationCurrent = {6, 24, 6};
2106 l.axcache = {7, 28, 4};
2107 l.iterationSize = {7, 22, 6};
2108 l.iterationStride = {7, 0, 22};
2110 l.enablePacket = {5, 31, 1};
2111 l.outOfOrderId = {8, 5, 4};
2112 l.packetId = {8, 0, 5};
2118 static const DmaBdLayout shim = makeAIE4ShimBdLayout();
2119 static const DmaBdLayout mem = makeAIE4MemTileBdLayout();
2120 static const DmaBdLayout core = makeAIE4CoreTileBdLayout();
2122 case AIETileType::ShimNOCTile:
2124 case AIETileType::MemTile:
2126 case AIETileType::CoreTile:
2135 DMAChannelDir direction)
const {
2136 static const DmaBdLayout control = makeAIE4ShimLinearBdLayout(
true);
2137 static const DmaBdLayout trace = makeAIE4ShimLinearBdLayout(
false);
2138 if (direction == DMAChannelDir::ControlMM2S)
2139 return tileType == AIETileType::ShimNOCTile ? &control :
nullptr;
2140 if (direction == DMAChannelDir::TraceS2MM)
2141 return tileType == AIETileType::ShimNOCTile ? &trace :
nullptr;
2147 AIE::DMAChannelDir direction)
const {
2148 bool mm2s =
isMM2S(direction);
2149 uint64_t offset = 0;
2153 report_fatal_error(
"AIE4TargetModel::getDmaBdAddress: a shim control "
2154 "or trace BD's address depends on its channel");
2155 if (bd_id >=
getNumBDs(AIETileType::ShimNOCTile))
2156 report_fatal_error(
"AIE4TargetModel::getDmaBdAddress: shim BD " +
2157 Twine(bd_id) +
" does not exist");
2158 offset = (bd_id < 16 ? 0x00018000 : 0x00058000) + (bd_id % 16) * 0x30;
2161 aie4ChannelOutOfRange(
"getDmaBdAddress", col, row, channel);
2163 report_fatal_error(
"AIE4TargetModel::getDmaBdAddress: shim BD " +
2164 Twine(bd_id) +
" is not in the pool of channel " +
2166 if (direction == AIE::DMAChannelDir::ControlMM2S) {
2168 offset = (channel == 0 ? 0x00018300 : 0x00058300) + bd_id * 0x30;
2169 }
else if (direction == AIE::DMAChannelDir::TraceS2MM) {
2170 offset = 0x00018480 + bd_id * 0x30;
2174 bool upper =
getBdPoolId(col, row, channel, direction) == 1;
2175 offset = (upper ? 0x00058000 : 0x00018000) + (bd_id % 16) * 0x30;
2179 report_fatal_error(
"AIE4TargetModel::getDmaBdAddress: a memtile BD's "
2180 "pool depends on its channel and direction");
2182 aie4ChannelOutOfRange(
"getDmaBdAddress", col, row, channel);
2185 int channelsPerBank = mm2s ? 5 : 4;
2186 offset = mm2s ? 0x00008C00 : 0x00008000;
2187 offset += (channel % channelsPerBank) * 16 * 0x30 + bd_id * 0x30;
2188 if (channel >= channelsPerBank)
2191 offset = 0x000AC000 + bd_id * 0x20;
2193 llvm_unreachable(
"AIE4TargetModel::getDmaBdAddress called for non-DMA "
2207 AIE::DMAChannelDir direction)
const {
2208 bool mm2s =
isMM2S(direction);
2211 aie4ChannelOutOfRange(
"getDmaControlAddress", col, row, channel);
2212 uint32_t offset = 0;
2214 static constexpr uint32_t s2mm[] = {0x00018540, 0x00058540};
2215 static constexpr uint32_t mm2s4[] = {0x00018550, 0x00018558, 0x00058550,
2217 static constexpr uint32_t control[] = {0x00018560, 0x00058560};
2218 if (direction == AIE::DMAChannelDir::ControlMM2S)
2219 offset = control[channel];
2220 else if (direction == AIE::DMAChannelDir::TraceS2MM)
2221 offset = 0x00018548;
2223 offset = mm2s ? mm2s4[channel] : s2mm[channel];
2225 int channelsPerBank = mm2s ? 5 : 4;
2226 offset = mm2s ? 0x00009E60 : 0x00009E00;
2227 offset += (channel % channelsPerBank) * 0x8;
2228 if (channel >= channelsPerBank)
2231 offset = (mm2s ? 0x000ACE10 : 0x000ACE00) + channel * 0x8;
2233 llvm_unreachable(
"AIE4TargetModel::getDmaControlAddress called for "
2239std::optional<uint32_t>
2241 constexpr uint32_t lockAddrOffset = 0x10;
2243 return std::nullopt;
2246 return 0x000AE000 + lockAddrOffset * lockId;
2249 uint32_t bankSize =
getNumLocks(tile.col, tile.row) / 2;
2251 if (lockId < bankSize)
2252 return 0x00010000 + lockAddrOffset * lockId;
2253 return 0x00050000 + lockAddrOffset * (lockId - bankSize);
2255 return std::nullopt;
2260static std::optional<uint32_t> aie4MemTileWindow(
const AIETargetModel &tm,
2261 int localCol,
int localRow,
2262 int memCol,
int memRow) {
2263 constexpr int reach = 7;
2266 return std::nullopt;
2267 int delta = memCol - localCol;
2268 if (delta < -reach || delta > reach)
2269 return std::nullopt;
2270 return delta + reach;
2273std::optional<uint32_t>
2275 int lockRow)
const {
2280 aie4MemTileWindow(*
this, localCol, localRow, lockCol, lockRow))
2282 return std::nullopt;
2285std::optional<uint32_t>
2291 constexpr uint32_t memTileWindowBase = 0x00B00000;
2293 aie4MemTileWindow(*
this, localCol, localRow, memCol, memRow))
2295 return std::nullopt;
2298std::vector<std::pair<uint32_t, uint32_t>>
2300 return {std::pair(0, 64), std::pair(1, 128), std::pair(2, 256),
2307 WireBundle bundle)
const {
2310 case WireBundle::DMA:
2311 case WireBundle::North:
2313 case WireBundle::South:
2315 case WireBundle::TileControl:
2317 case WireBundle::NorthControl:
2318 case WireBundle::Switch32:
2320 case WireBundle::South32:
2321 case WireBundle::North32:
2322 case WireBundle::Switch512:
2324 case WireBundle::West32:
2325 case WireBundle::East32:
2332 case WireBundle::DMATrace:
2334 case WireBundle::DMA:
2336 case WireBundle::North:
2338 case WireBundle::West: {
2343 case WireBundle::East: {
2348 case WireBundle::TileControl:
2350 case WireBundle::NorthControl:
2351 case WireBundle::Switch32:
2353 case WireBundle::North32:
2354 case WireBundle::Switch512:
2355 case WireBundle::Controller32:
2357 case WireBundle::West32:
2361 case WireBundle::East32:
2365 case WireBundle::PLIO32:
2371 case WireBundle::Core:
2372 case WireBundle::DMA:
2373 case WireBundle::NorthControl:
2375 case WireBundle::North: {
2376 if (row ==
rows() - 1)
2380 case WireBundle::West: {
2385 case WireBundle::South:
2387 case WireBundle::East: {
2392 case WireBundle::TileControl:
2393 case WireBundle::Switch32:
2396 case WireBundle::South32:
2397 case WireBundle::North32:
2399 case WireBundle::West32:
2400 case WireBundle::East32:
2401 case WireBundle::Switch512:
2411 WireBundle bundle)
const {
2415 case WireBundle::DMA:
2417 case WireBundle::North:
2418 case WireBundle::South:
2420 case WireBundle::SouthControl:
2421 case WireBundle::Switch32:
2424 case WireBundle::Trace32:
2426 case WireBundle::Control32:
2427 case WireBundle::South32:
2428 case WireBundle::North32:
2429 case WireBundle::Switch512:
2431 case WireBundle::West32:
2432 case WireBundle::East32:
2439 case WireBundle::DMA:
2440 case WireBundle::North:
2442 case WireBundle::West: {
2447 case WireBundle::East: {
2452 case WireBundle::DMAControl:
2453 case WireBundle::Switch32:
2456 case WireBundle::Trace32:
2458 case WireBundle::Control32:
2459 case WireBundle::North32:
2460 case WireBundle::Switch512:
2461 case WireBundle::Controller32:
2463 case WireBundle::West32:
2467 case WireBundle::East32:
2477 case WireBundle::Core:
2478 case WireBundle::DMA:
2480 case WireBundle::North: {
2481 if (row ==
rows() - 1)
2485 case WireBundle::West: {
2490 case WireBundle::South:
2492 case WireBundle::East: {
2497 case WireBundle::SouthControl:
2499 case WireBundle::Switch32:
2502 case WireBundle::Trace32:
2503 case WireBundle::South32:
2504 case WireBundle::North32:
2506 case WireBundle::Control32:
2507 case WireBundle::West32:
2508 case WireBundle::East32:
2509 case WireBundle::Switch512:
2529 WireBundle srcBundle,
int srcChan,
2530 WireBundle dstBundle,
2531 int dstChan)
const {
2537 auto isBundleInList = [](WireBundle bundle,
2538 std::initializer_list<WireBundle> bundles) ->
bool {
2539 return llvm::is_contained(bundles, bundle);
2542 auto isBundle32 = [&](WireBundle bundle) ->
bool {
2543 return isBundleInList(
2545 {WireBundle::Control32, WireBundle::Controller32, WireBundle::Trace32,
2546 WireBundle::South32, WireBundle::West32, WireBundle::North32,
2547 WireBundle::East32, WireBundle::Switch512, WireBundle::PLIO32});
2551 if (isBundle32(srcBundle) && isBundle32(dstBundle))
2555 if (isBundle32(srcBundle) != isBundle32(dstBundle))
2562 if (srcBundle == WireBundle::DMA) {
2564 if ((dstBundle == WireBundle::DMA) &&
2565 ((srcChan <= 3) || (srcChan >= 6 && srcChan <= 9)))
2566 return srcChan == dstChan;
2568 if (dstBundle == WireBundle::South) {
2572 return dstChan == 0;
2575 return dstChan == 1;
2578 return dstChan == 2;
2581 return dstChan == 3;
2590 if (dstBundle == WireBundle::North) {
2592 return dstChan == 0;
2594 return dstChan == 4;
2598 if (dstBundle == WireBundle::Switch32)
2601 if (isBundleInList(dstBundle,
2602 {WireBundle::NorthControl, WireBundle::TileControl})) {
2603 if (srcChan == 3 || srcChan == 4)
2604 return dstChan == 0;
2605 if (srcChan == 9 || srcChan == 10)
2606 return dstChan == 1;
2612 if (srcBundle == WireBundle::South) {
2614 if (dstBundle == WireBundle::DMA) {
2616 return dstChan == 0 || dstChan == 2 || dstChan == 3;
2618 return dstChan == 1 || dstChan == 2 || dstChan == 3;
2620 return dstChan == 4 || dstChan == 6 || dstChan == 7;
2622 return dstChan == 5 || dstChan == 6 || dstChan == 7;
2625 if (dstBundle == WireBundle::South)
2626 return srcChan == dstChan;
2628 return isBundleInList(dstBundle,
2629 {WireBundle::North, WireBundle::Switch32});
2633 if (srcBundle == WireBundle::North) {
2635 if (dstBundle == WireBundle::DMA) {
2639 return dstChan == 2;
2641 return dstChan == 3;
2643 return dstChan == 4 || dstChan == 5 || dstChan == 6;
2645 return dstChan == 4 || dstChan == 5 || dstChan == 7;
2648 if (dstBundle == WireBundle::North) {
2649 if (srcChan == 0 && dstChan == 0)
2651 if (srcChan == 1 && dstChan == 1)
2653 if (srcChan == 2 && dstChan == 4)
2655 if (srcChan == 3 && dstChan == 5)
2659 if (dstBundle == WireBundle::TileControl) {
2660 if (srcChan == 1 && dstChan == 0)
2666 return isBundleInList(dstBundle,
2667 {WireBundle::South, WireBundle::Switch32});
2671 if (srcBundle == WireBundle::SouthControl) {
2673 if (dstBundle == WireBundle::DMA) {
2674 if (srcChan == 0 && dstChan == 3)
2676 if (srcChan == 1 && dstChan == 7)
2680 if (dstBundle == WireBundle::NorthControl)
2681 return srcChan == dstChan;
2683 if (dstBundle == WireBundle::TileControl)
2684 return srcChan == 1 || dstChan == 0;
2686 if (dstBundle == WireBundle::Switch32)
2692 if (srcBundle == WireBundle::Switch32) {
2694 if (isBundleInList(dstBundle,
2695 {WireBundle::Switch32, WireBundle::Switch512}))
2697 if (isBundleInList(dstBundle,
2698 {WireBundle::TileControl, WireBundle::NorthControl}))
2699 return srcChan == dstChan;
2709 if (dstBundle == WireBundle::DMATrace)
2710 return isBundleInList(srcBundle,
2711 {WireBundle::North, WireBundle::East,
2712 WireBundle::West, WireBundle::Switch32});
2715 if (srcBundle == WireBundle::DMA) {
2716 if (dstBundle == WireBundle::DMA) {
2717 if (srcChan == 0 || srcChan == 2)
2718 return srcChan == dstChan;
2721 if (isBundleInList(dstBundle,
2722 {WireBundle::NorthControl, WireBundle::TileControl})) {
2723 if (srcChan <= 1 && dstChan == 0)
2725 if (srcChan >= 2 && dstChan == 1)
2729 return isBundleInList(dstBundle,
2730 {WireBundle::West, WireBundle::North,
2731 WireBundle::East, WireBundle::Switch32});
2734 if (isBundleInList(srcBundle, {WireBundle::West, WireBundle::North,
2735 WireBundle::East})) {
2736 if (srcBundle == dstBundle)
2737 return srcChan == dstChan;
2738 if (isBundleInList(dstBundle,
2739 {WireBundle::DMA, WireBundle::West, WireBundle::North,
2740 WireBundle::East, WireBundle::Switch32}))
2742 if (dstBundle == WireBundle::TileControl) {
2744 return (srcBundle == WireBundle::North) && (srcChan == 3);
2745 if (srcBundle == WireBundle::North)
2746 return (srcChan == 1) || (srcChan == 3);
2749 if (dstBundle == WireBundle::NorthControl) {
2750 if (srcBundle != WireBundle::North)
2754 if (srcChan == 1 && dstChan == 0)
2761 if (srcBundle == WireBundle::DMAControl) {
2762 if (isBundleInList(dstBundle, {WireBundle::West, WireBundle::East}))
2763 return (srcChan == 0) || (dstChan == 1);
2764 if (dstBundle == WireBundle::North) {
2766 return srcChan == 0;
2768 return srcChan == 1;
2770 if (isBundleInList(dstBundle,
2771 {WireBundle::NorthControl, WireBundle::TileControl,
2772 WireBundle::Switch32})) {
2773 if (srcChan == dstChan)
2775 if (dstBundle == WireBundle::TileControl)
2776 return dstChan == 0;
2781 if (srcBundle == WireBundle::Switch32) {
2782 if (isBundleInList(dstBundle,
2783 {WireBundle::DMA, WireBundle::West, WireBundle::North,
2784 WireBundle::East, WireBundle::NorthControl}))
2786 if (dstBundle == WireBundle::TileControl)
2787 return srcChan == dstChan;
2796 switch (srcBundle) {
2799 case WireBundle::Core:
2800 if (dstBundle == WireBundle::DMA)
2801 return dstChan == 1;
2802 if (dstBundle == WireBundle::NorthControl)
2803 return dstChan == 0;
2804 return isBundleInList(dstBundle,
2805 {WireBundle::South, WireBundle::East,
2806 WireBundle::West, WireBundle::North,
2807 WireBundle::TileControl, WireBundle::Switch32});
2809 case WireBundle::DMA:
2810 if (dstBundle == WireBundle::DMA)
2811 return dstChan == 0;
2812 return isBundleInList(dstBundle,
2813 {WireBundle::Core, WireBundle::South,
2814 WireBundle::East, WireBundle::West,
2815 WireBundle::North, WireBundle::NorthControl,
2816 WireBundle::TileControl, WireBundle::Switch32});
2818 case WireBundle::North:
2819 case WireBundle::South:
2820 if (srcBundle == dstBundle) {
2821 if (srcChan == 0 || srcChan == 1)
2822 return srcChan == dstChan;
2823 if (srcChan == 4 || srcChan == 5)
2824 return (srcChan - 2) == dstChan;
2827 return isBundleInList(dstBundle, {WireBundle::Core, WireBundle::DMA,
2828 WireBundle::West, WireBundle::North,
2829 WireBundle::South, WireBundle::East,
2830 WireBundle::Switch32});
2832 case WireBundle::East:
2833 case WireBundle::West:
2834 if (dstBundle == srcBundle)
2835 return srcChan == dstChan;
2836 return isBundleInList(
2837 dstBundle, {WireBundle::Core, WireBundle::DMA, WireBundle::South,
2838 WireBundle::East, WireBundle::West, WireBundle::North,
2839 WireBundle::NorthControl, WireBundle::TileControl,
2840 WireBundle::Switch32});
2842 case WireBundle::SouthControl:
2843 if (isBundleInList(dstBundle, {WireBundle::Core, WireBundle::DMA}))
2844 return srcChan == dstChan;
2845 if (isBundleInList(dstBundle, {WireBundle::East, WireBundle::West}))
2846 return dstChan == 1 || srcChan == 0;
2847 if (dstBundle == WireBundle::NorthControl)
2848 return srcChan == 1 || dstChan == 0;
2849 return isBundleInList(dstBundle,
2850 {WireBundle::TileControl, WireBundle::Switch32});
2852 case (WireBundle::Switch512):
2855 case (WireBundle::Switch32):
2856 return (isBundleInList(
2857 dstBundle, {WireBundle::Core, WireBundle::DMA, WireBundle::South,
2858 WireBundle::East, WireBundle::West, WireBundle::North,
2859 WireBundle::NorthControl, WireBundle::TileControl,
2860 WireBundle::Switch512}));
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.
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...
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 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.
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.
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
uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a switchbox.
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.
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...
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...
bool isLegalTileConnection(int col, int row, WireBundle srcBundle, int srcChan, WireBundle dstBundle, int dstChan) const override
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 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...
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...
std::unique_ptr< RegisterDatabase > loadRegisterDatabase() const override
AIE2 TargetModel.
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.
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.
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.
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 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.
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.
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...
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 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.
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 getNumBDsInPool(int col, int row, uint32_t poolId) const override
uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a switchbox.
uint32_t getDataMemoryOffset(int col, int row) const override
A memtile's data memory starts 1 MiB into its window.
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.
AIEArch getTargetArch() const override
Return the target architecture.
uint32_t getMemTileSize() const override
Return the size (in bytes) of a MemTile.
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 ...
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.
uint32_t getNumDestShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a shimmux.
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 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.
std::optional< uint32_t > encodeFieldValue(const BitFieldInfo &field, uint32_t value) const
Encode a field value with proper bit shifting.
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 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
bool isCoreTile(int col, int row) const
Return true if the given tile is a Core tile.
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 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 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.
bool isOrdinaryWriteAddress(TileID tile, uint32_t offset) const
std::optional< uint32_t > lookupEvent(llvm::StringRef name, TileID tile, bool isMem=false) const
Lookup event number by name and tile.
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...
const RegisterDatabase * getRegisterDatabase() const
Get the register database, loading it lazily on first access.
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.
bool isShimPLTile(int col, int row) const
Return true if the given tile is a ShimPL tile.
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,...
virtual ~AIETargetModel()
bool isBdChannelAccessible(int col, int row, uint32_t bd_id, int channel, DMAChannelDir dir) const
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.
bool isShimNOCorPLTile(int col, int row) const
Return true if the given tile is either a ShimNOC or ShimPL tile.
virtual uint32_t getMemWestBaseAddress() const =0
Return the base address in the local address map for a core.
virtual int rows() const =0
Return the number of rows in the device.
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 std::unique_ptr< RegisterDatabase > loadRegisterDatabase() const
Subclasses override to provide architecture-specific database loading.
virtual uint32_t getProgramMemorySize() const =0
Return the size (in bytes) of a core's program memory.
virtual uint32_t getMemNorthBaseAddress() const =0
Return the base address in the local address map for a core.
uint32_t getNumDMAChannels(int col, int row, AIE::DMAChannelDir dir) const
Return the number of DMA channels a tile has in one direction.
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 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.
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
uint32_t getRowFieldMask() const
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 ...
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.
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
AIEArch getTargetArch() const override
Return the target architecture.
bool isSupportedBlockFormat(std::string const &format) const override
Register and event database for a specific architecture.
static std::unique_ptr< RegisterDatabase > loadAIE2()
Load database for AIE2 architecture.
static std::unique_ptr< RegisterDatabase > loadAIE4()
Load database for AIE4 architecture.
const RegisterInfo * lookupRegisterByOffset(uint32_t offset, llvm::StringRef module) const
Lookup register by tile-relative offset and module name.
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
bool isMM2S(DMAChannelDir dir)
True if dir moves data out of memory onto a stream (MM2S, ControlMM2S).
WireBundle getDMAChannelBundle(DMAChannelDir dir)
The stream-switch bundle the channels of dir use.
Bit field information for a register.
uint32_t getWidth() const
The register layout of one tile type's DMA buffer descriptor.
DmaBdField iterationCurrent
DmaBdField iterationStride
DmaBdField d0Size
Without a d0Stride field the innermost dimension is contiguous.