@@ -879,9 +879,8 @@ xilinx::AIE::convertTransactionBinaryToMLIR(mlir::MLIRContext *ctx,
879879// new ModuleOp containing a DeviceOp containing a runtime sequence with the
880880// control packet binary encoded as a sequence of aiex.control_packet
881881// operations. On failure return std::nullopt.
882- std::optional<mlir::ModuleOp>
883- xilinx::AIE::convertControlPacketBinaryToMLIR (mlir::MLIRContext *ctx,
884- std::vector<uint8_t > &binary) {
882+ std::optional<mlir::ModuleOp> xilinx::AIE::convertControlPacketBinaryToMLIR (
883+ mlir::MLIRContext *ctx, std::vector<uint8_t > &binary, AIEDevice device) {
885884
886885 // parse the binary
887886 auto maybeOps = parseControlPacket (binary);
@@ -898,13 +897,13 @@ xilinx::AIE::convertControlPacketBinaryToMLIR(mlir::MLIRContext *ctx,
898897 OpBuilder builder (module .getBodyRegion ());
899898 builder.setInsertionPointToStart (module .getBody ());
900899
901- // Create aie.device - default to npu1_1col
902- // Note: Control packets don't have device info in the binary format
903- auto device = builder.create <DeviceOp>(loc, AIEDevice::npu1_1col,
904- StringAttr::get (builder.getContext ()));
905- device .getRegion ().emplaceBlock ();
906- DeviceOp::ensureTerminator (device .getBodyRegion (), builder, loc);
907- builder.setInsertionPointToStart (device .getBody ());
900+ // Create aie.device with specified device type
901+ auto deviceAttr = AIEDeviceAttr::get (ctx, device);
902+ auto deviceOp = builder.create <DeviceOp>(
903+ loc, deviceAttr, StringAttr::get (builder.getContext ()));
904+ deviceOp .getRegion ().emplaceBlock ();
905+ DeviceOp::ensureTerminator (deviceOp .getBodyRegion (), builder, loc);
906+ builder.setInsertionPointToStart (deviceOp .getBody ());
908907
909908 // Create tiles and set controller_id attributes based on packet info
910909 // Group operations by (pktType, pktId) to determine which tile they target
@@ -913,13 +912,13 @@ xilinx::AIE::convertControlPacketBinaryToMLIR(mlir::MLIRContext *ctx,
913912 auto key = std::make_pair (op.pktType , op.pktId );
914913 if (tileMap.find (key) == tileMap.end ()) {
915914 // Extract col/row from address using target model
916- const AIETargetModel &targetModel = device .getTargetModel ();
915+ const AIETargetModel &targetModel = deviceOp .getTargetModel ();
917916 uint32_t colInt = (op.address >> targetModel.getColumnShift ()) & 0x1f ;
918917 uint32_t rowInt = (op.address >> targetModel.getRowShift ()) & 0x1f ;
919918 tileMap[key] = std::make_pair (colInt, rowInt);
920919
921920 // Create tile and set controller_id attribute
922- auto tile = TileOp::getOrCreate (builder, device , colInt, rowInt);
921+ auto tile = TileOp::getOrCreate (builder, deviceOp , colInt, rowInt);
923922 auto packetInfoAttr =
924923 AIE::PacketInfoAttr::get (builder.getContext (), op.pktType , op.pktId );
925924 tile->setAttr (" controller_id" , packetInfoAttr);
0 commit comments