21 llvm::raw_ostream &output,
22 llvm::StringRef deviceName) {
24 AIE::DeviceOp::getForSymbolInModuleOrError(module, deviceName);
26 return mlir::failure();
28 AIEArch arch = targetOp.getTargetModel().getTargetArch();
29 if (arch == AIEArch::AIE4)
30 return targetOp.emitOpError(
"simulation files are not supported for the "
33 if (arch == AIEArch::AIE2p) {
35 <<
" \"SimulationConfig\": {\n"
36 <<
" \"device_json\": {\n"
37 <<
" \"directory\": \"data/aie2p/devices\",\n"
38 <<
" \"file\": \"aie2p_8x4_device.json\"\n"
40 <<
" \"phy_device_file\": \"aie2p_8x4_device\",\n"
41 <<
" \"aiearch\": \"aie2p\",\n"
42 <<
" \"aie_freq\": 1000000000.0,\n"
43 <<
" \"use_real_noc\": 1,\n"
44 <<
" \"evaluate_fifo_depth\": 0,\n"
45 <<
" \"noc_ip_block\": {\n"
46 <<
" \"lib_path\": \"./sim/noc/liblnoc_tlm.so\",\n"
47 <<
" \"traffic_file\": \"./sim/noc/noc_traffic.nts\",\n"
48 <<
" \"config_file\": \"./sim/noc/noc_soln.ncr\"\n"
50 <<
" \"pl_ip_block\": [\n"
52 <<
" \"name\": \"ps_ps_main\",\n"
53 <<
" \"ip\": \"ps\",\n"
54 <<
" \"lib_path\": \"ps/ps.so\",\n"
55 <<
" \"pl_freq\": 362500000.0,\n"
58 <<
" \"port_name\": \"ps_axi\",\n"
59 <<
" \"direction\": \"ps_to_gm\",\n"
60 <<
" \"noc_endpoint\": \"NOC_NMU128_X0Y5\",\n"
61 <<
" \"bus_width\": 0\n"
64 <<
" \"event_bus\": []\n"
69 }
else if (arch == AIEArch::AIE2) {
72 <<
" \"SimulationConfig\": {\n"
73 <<
" \"device_json\": {\n"
74 <<
" \"directory\": \"data/aie_ml/devices\",\n"
75 <<
" \"file\": \"VC2802.json\"\n"
77 <<
" \"phy_device_file\": \"xcve2802-vsvh1760-2LP-e-S-es1\",\n"
78 <<
" \"aiearch\": \"aie2\",\n"
79 <<
" \"aie_freq\": 1050000000.0,\n"
80 <<
" \"use_real_noc\": 1,\n"
81 <<
" \"evaluate_fifo_depth\": 0,\n"
82 <<
" \"noc_ip_block\": {\n"
83 <<
" \"lib_path\": \"./sim/noc/liblnoc_tlm.so\",\n"
84 <<
" \"traffic_file\": \"./sim/noc/noc_traffic.nts\",\n"
85 <<
" \"config_file\": \"./sim/noc/noc_soln.ncr\"\n"
87 <<
" \"pl_ip_block\": [\n"
89 <<
" \"name\": \"ps_ps_main\",\n"
90 <<
" \"ip\": \"ps\",\n"
91 <<
" \"lib_path\": \"ps/ps.so\",\n"
92 <<
" \"pl_freq\": 362500000.0,\n"
95 <<
" \"port_name\": \"ps_axi\",\n"
96 <<
" \"direction\": \"ps_to_gm\",\n"
97 <<
" \"noc_endpoint\": \"NOC_NMU128_X0Y5\",\n"
98 <<
" \"bus_width\": 0\n"
101 <<
" \"event_bus\": []\n"
106 }
else if (arch == AIEArch::AIE1) {
108 <<
" \"SimulationConfig\": {\n"
109 <<
" \"device_json\": {\n"
110 <<
" \"directory\": \"data/devices\",\n"
111 <<
" \"file\": \"VC1902.json\"\n"
113 <<
" \"phy_device_file\": \"xcvc1902-vsva2197-2MP-e-S\",\n"
114 <<
" \"aiearch\": \"aie\",\n"
115 <<
" \"aie_freq\": 1250000000.0,\n"
116 <<
" \"use_real_noc\": 1,\n"
117 <<
" \"evaluate_fifo_depth\": 0,\n"
118 <<
" \"noc_ip_block\": {\n"
119 <<
" \"lib_path\": \"./Work/noc/liblnoc_tlm.so\",\n"
120 <<
" \"traffic_file\": \"./Work/noc/noc_traffic.nts\",\n"
121 <<
" \"config_file\": \"./Work/noc/noc_soln.ncr\"\n"
123 <<
" \"pl_ip_block\": [\n"
125 <<
" \"name\": \"ps_ps_main\",\n"
126 <<
" \"ip\": \"ps\",\n"
127 <<
" \"lib_path\": \"ps/ps.so\",\n"
128 <<
" \"pl_freq\": 312500000.0,\n"
129 <<
" \"axi_mm\": [\n"
131 <<
" \"port_name\": \"ps_axi\",\n"
132 <<
" \"direction\": \"ps_to_gm\",\n"
133 <<
" \"noc_endpoint\": \"NOC_NMU128_X0Y5\",\n"
134 <<
" \"bus_width\": 0\n"
137 <<
" \"event_bus\": []\n"
143 return mlir::success();
157 llvm::raw_ostream &output,
158 llvm::StringRef deviceName) {
160 AIE::DeviceOp::getForSymbolInModuleOrError(module, deviceName);
162 return mlir::failure();
165 return mlir::failure();
166 if (targetOp.getTargetModel().getTargetArch() == AIEArch::AIE4)
167 return targetOp.emitOpError(
"simulation files are not supported for the "
168 "AIE4 architecture");
172 output <<
" \"Placement\": [\n";
174 int shim_MM2S_count = 0;
177 auto all_shim_ops = targetOp.getOps<ShimDMAOp>();
178 for (ShimDMAOp shimOp : all_shim_ops) {
179 for (DMAStartOp startOp : shimOp.getOps<DMAStartOp>()) {
181 if (startOp.getChannelDir() == DMAChannelDir::MM2S) {
182 if (shim_MM2S_count > 0)
185 std::string port_name =
"";
186 port_name.append(
"M");
187 port_name.append(shim_MM2S_count < 10 ?
"0" :
"");
188 port_name.append(std::to_string(shim_MM2S_count++));
189 port_name.append(
"_AXI");
194 << R
"( "LogicalInstance" : { "InstanceName" : )"
195 << R"("aie_engine_0", "PortName" : ")" << port_name << "\"},\n";
197 std::string col = std::to_string(shimOp.colIndex());
198 int ch = startOp.getChannelIndex();
199 std::string channel = std::to_string(ch);
201 std::string physical_name =
"";
202 physical_name.append(
"AIE_NOC_X").append(col).append(
"Y0_AIE_NOC_");
203 physical_name.append(
"M_AXI_ch").append(channel);
206 output << R
"( "PhysicalInstance" : [{ "name" : ")" << physical_name
207 << R"(", "column" : )" << col << ", \"channel\" : " << channel
209 <<
" \"IsSoft\" : true\n }";
217 return mlir::success();
221 llvm::raw_ostream &output,
222 llvm::StringRef deviceName) {
235 AIE::DeviceOp::getForSymbolInModuleOrError(module, deviceName);
237 return mlir::failure();
239 AIEArch arch = targetOp.getTargetModel().getTargetArch();
240 if (arch == AIEArch::AIE4)
241 return targetOp.emitOpError(
"simulation files are not supported for the "
242 "AIE4 architecture");
246 output <<
"<?xml version=\"1.0\"?>"
248 output <<
"<POWERDATA data=\"AI-Engine Compiler\" dataVersion=\"2022.2\" "
249 "design=\"graph\" date=\"2023\">\n";
250 if ((arch == AIEArch::AIE2) || (arch == AIEArch::AIE2p)) {
253 <<
" <DEVICE part=\"xcve2802\" grade=\"extended\" package=\"vsvh1760\" "
254 "speed=\"-2LP\" process=\"typical\" vid=\"No\"></DEVICE>\n";
260 <<
" <DEVICE part=\"xcvc1902\" grade=\"extended\" package=\"vsva2197\" "
261 "speed=\"-2MP\" process=\"typical\" vid=\"No\"></DEVICE>\n";
263 output <<
" <AIE status=\"COMPILER_OUTPUT\">\n";
266 auto module_tile_ops = targetOp.getOps<TileOp>();
267 int num_tiles = std::distance(module_tile_ops.begin(), module_tile_ops.end());
269 if ((arch == AIEArch::AIE2) || (arch == AIEArch::AIE2p)) {
270 output << R
"( <AIE_MODULE name="graph" num_tiles=")"
271 << std::to_string(num_tiles) << "\" clk_freq=\"1150\">\n";
273 output << R
"( <AIE_MODULE name="graph" num_tiles=")"
274 << std::to_string(num_tiles) << "\" clk_freq=\"1250\">\n";
279 std::map<std::pair<int, int>, std::vector<CoreOp>> coreMap;
280 for (CoreOp coreOp : targetOp.getOps<CoreOp>())
281 coreMap[std::make_pair(coreOp.colIndex(), coreOp.rowIndex())].push_back(
285 int kernel_count = 0;
286 for (TileOp tileOp : module_tile_ops) {
287 int col = tileOp.colIndex();
288 int row = tileOp.rowIndex();
291 if (tileOp.isShimNOCorPLTile() || tileOp.isMemTile())
294 if ((arch == AIEArch::AIE2) || (arch == AIEArch::AIE2p)) {
296 output <<
" <TILE name=\"CR(" <<
299 std::to_string(col) <<
","
301 row - targetOp.getTargetModel().getNumMemTileRows() - 1)
306 << R
"(type="int16" int_core_load="1.0" fp_core_load="0" )"
307 << "mem_banks=\"0\" mem_rw_rate=\"0.2\" stream_util=\"0.0\" "
313 std::to_string(col) <<
","
314 << std::to_string(row -
315 targetOp.getTargetModel().getNumMemTileRows())
319 output <<
" <TILE name=\"CR(" <<
321 std::to_string(col) <<
"," << std::to_string(row - 1) <<
")\" "
322 << R
"(type="int16" int_core_load="1.0" fp_core_load="0" )"
323 << "mem_banks=\"0\" mem_rw_rate=\"0.2\" stream_util=\"0.0\" "
329 std::to_string(col) <<
"," << std::to_string(row) <<
"\">\n";
333 auto coreOps_in_tile =
334 coreMap[std::make_pair(tileOp.colIndex(), tileOp.rowIndex())];
335 for (
auto coreOp : coreOps_in_tile) {
337 output <<
" <KERNEL name=\"i" << std::to_string(kernel_count++)
339 <<
"int_core_load=\"" << std::to_string(1 / coreOps_in_tile.size())
340 <<
"\" fp_core_load=\"0\"></KERNEL>\n";
342 output <<
" </TILE>\n";
346 for (ShimDMAOp shimOp : targetOp.getOps<ShimDMAOp>()) {
347 if ((arch == AIEArch::AIE2) || (arch == AIEArch::AIE2p)) {
348 const auto *noc_label = (targetOp.getTargetModel().isShimNOCTile(
349 shimOp.colIndex(), shimOp.rowIndex()))
352 output <<
" <SHIM name=\"SHIM(" << std::to_string(shimOp.colIndex())
353 <<
", " << std::to_string(shimOp.rowIndex())
357 << noc_label << R
"(" stream_util="0" num_pl_streams="0" )" <<
359 R
"(num_aximm_connections="1" coordinates=")"
360 << std::to_string(shimOp.colIndex()) << ","
361 << std::to_string(shimOp.rowIndex()) <<
"\" "
364 output <<
" <SHIM name=\"SHIM(" << std::to_string(shimOp.colIndex())
365 <<
", " << std::to_string(shimOp.rowIndex()) <<
")\" " <<
367 R
"(type="AIE_PL_NOC_SHIM" stream_util="0" num_pl_streams="0"
370 R
"(num_aximm_connections="1" coordinates=")"
371 << std::to_string(shimOp.colIndex()) << ","
372 << std::to_string(shimOp.rowIndex()) <<
"\" "
378 if ((arch == AIEArch::AIE2) || (arch == AIEArch::AIE2p)) {
379 for (TileOp tileOp : module_tile_ops) {
380 int col = tileOp.colIndex();
381 int row = tileOp.rowIndex();
385 row >
static_cast<int>(targetOp.getTargetModel().getNumMemTileRows()))
388 output <<
" <MEM name=\"MEM(" << std::to_string(col) <<
", "
389 << std::to_string(row - 1)
392 "type=\"AIE_MEM\" mem_banks=\"0\" mme_rw_rate=\"0.1\" "
393 << R
"(stream_util="0.1" coordinates=")" << std::to_string(col)
394 << "," << std::to_string(row - 1) <<
"\" "
399 output <<
" </AIE_MODULE>\n";
400 output <<
" </AIE>\n";
401 output <<
"</POWERDATA>\n";
403 return mlir::success();