@@ -863,9 +863,8 @@ xilinx::AIE::convertTransactionBinaryToMLIR(mlir::MLIRContext *ctx,
863863// new ModuleOp containing a DeviceOp containing a runtime sequence with the
864864// control packet binary encoded as a sequence of aiex.control_packet
865865// operations. On failure return std::nullopt.
866- std::optional<mlir::ModuleOp>
867- xilinx::AIE::convertControlPacketBinaryToMLIR (mlir::MLIRContext *ctx,
868- std::vector<uint8_t > &binary) {
866+ std::optional<mlir::ModuleOp> xilinx::AIE::convertControlPacketBinaryToMLIR (
867+ mlir::MLIRContext *ctx, std::vector<uint8_t > &binary, AIEDevice device) {
869868
870869 // parse the binary
871870 auto maybeOps = parseControlPacket (binary);
@@ -882,13 +881,13 @@ xilinx::AIE::convertControlPacketBinaryToMLIR(mlir::MLIRContext *ctx,
882881 OpBuilder builder (module .getBodyRegion ());
883882 builder.setInsertionPointToStart (module .getBody ());
884883
885- // Create aie.device - default to npu1_1col
886- // Note: Control packets don't have device info in the binary format
887- auto device = builder.create <DeviceOp>(loc, AIEDevice::npu1_1col,
888- StringAttr::get (builder.getContext ()));
889- device .getRegion ().emplaceBlock ();
890- DeviceOp::ensureTerminator (device .getBodyRegion (), builder, loc);
891- builder.setInsertionPointToStart (device .getBody ());
884+ // Create aie.device with specified device type
885+ auto deviceAttr = AIEDeviceAttr::get (ctx, device);
886+ auto deviceOp = builder.create <DeviceOp>(
887+ loc, deviceAttr, StringAttr::get (builder.getContext ()));
888+ deviceOp .getRegion ().emplaceBlock ();
889+ DeviceOp::ensureTerminator (deviceOp .getBodyRegion (), builder, loc);
890+ builder.setInsertionPointToStart (deviceOp .getBody ());
892891
893892 // Create tiles and set controller_id attributes based on packet info
894893 // Group operations by (pktType, pktId) to determine which tile they target
@@ -897,13 +896,13 @@ xilinx::AIE::convertControlPacketBinaryToMLIR(mlir::MLIRContext *ctx,
897896 auto key = std::make_pair (op.pktType , op.pktId );
898897 if (tileMap.find (key) == tileMap.end ()) {
899898 // Extract col/row from address using target model
900- const AIETargetModel &targetModel = device .getTargetModel ();
899+ const AIETargetModel &targetModel = deviceOp .getTargetModel ();
901900 uint32_t colInt = (op.address >> targetModel.getColumnShift ()) & 0x1f ;
902901 uint32_t rowInt = (op.address >> targetModel.getRowShift ()) & 0x1f ;
903902 tileMap[key] = std::make_pair (colInt, rowInt);
904903
905904 // Create tile and set controller_id attribute
906- auto tile = TileOp::getOrCreate (builder, device , colInt, rowInt);
905+ auto tile = TileOp::getOrCreate (builder, deviceOp , colInt, rowInt);
907906 auto packetInfoAttr =
908907 AIE::PacketInfoAttr::get (builder.getContext (), op.pktType , op.pktId );
909908 tile->setAttr (" controller_id" , packetInfoAttr);
0 commit comments