Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
dd9af93
Revert "remove port index functionality"
fifield Jan 12, 2026
c0ea31c
Commit 1: Add TableGen definitions for trace operations
fifield Nov 8, 2025
e80c2d7
Commit 2: Add verification tests for trace operations
fifield Nov 8, 2025
c45c97d
Commit 4: Implement AIETraceToConfigPass
fifield Nov 8, 2025
a31b6ef
Commit 5: Implement AIEInlineTraceConfigPass
fifield Nov 8, 2025
d8fb764
Commit 6: Add AIEConfigToNPUPass stub implementation
fifield Nov 8, 2025
8fa40ef
Commit 7: Add end-to-end trace pipeline test
fifield Nov 8, 2025
29c9c34
Complete Pass 3 implementation with RegisterDatabase integration
fifield Nov 8, 2025
53a781b
Refactor: Fix design issue with col/row preservation
fifield Nov 8, 2025
438f75e
Move trace NPU passes to AIEX dialect (fixes AIEX loading issue)
fifield Nov 8, 2025
343038d
Move and update trace tests to AIEX dialect
fifield Nov 8, 2025
0637192
Update AIEX tests to use runtime_sequence
fifield Nov 8, 2025
80c9396
start a test
fifield Nov 11, 2025
b445f19
remove aie-config-to-npu placeholder
fifield Nov 12, 2025
1bfb035
fixes for core mem events
fifield Nov 12, 2025
87c05bc
fix test location
fifield Nov 12, 2025
3febccb
Add stream switch port event monitoring to AIE trace infrastructure
fifield Nov 13, 2025
cde323c
implement trace and combo event op tablegen
fifield Nov 14, 2025
ffb3e17
Update dialect to use generated enums for events
fifield Nov 15, 2025
b160a20
implement AIETargetModel getStreamSwitchPortIndex
fifield Nov 17, 2025
4bcb50c
add python TraceEventAttr and trace region_op
fifield Nov 18, 2025
b7772ca
Add visualization to parse_trace.py
fifield Nov 18, 2025
f547e09
fixes after rebase
fifield Jan 16, 2026
02ebebd
remove extra copy of AIERegisterDatabase; update aiecc.py to set MLIR…
fifield Jan 20, 2026
71b4fd2
minor fixes from code review
fifield Feb 26, 2026
7b487c2
start to cleanup example
fifield Mar 3, 2026
992d3cb
clang format
fifield Mar 3, 2026
8f45044
cleanup
fifield Mar 3, 2026
019b75a
review
fifield Mar 3, 2026
19bb01f
minor fixes; change aiex-inline-trace-config to aie-inline-trace-config
fifield Mar 3, 2026
818ab5a
clang format
fifield Mar 3, 2026
c6b17ae
more code review
fifield Mar 3, 2026
4b616a1
more code review and cleanup
fifield Mar 3, 2026
aadbd05
fixups
fifield Mar 3, 2026
af9c0f4
revert: drop generate_timeline support from parse_trace
fifield Mar 3, 2026
486e896
fixup
fifield Mar 3, 2026
3c928d3
cleanup and enable lit for programming_example
fifield Mar 3, 2026
d34dfc1
cleanups
fifield Mar 3, 2026
e09bab0
update readme
fifield Mar 3, 2026
b988084
update
fifield Mar 3, 2026
5b0cfea
more fixup
fifield Mar 3, 2026
4e8336b
Update lib/Dialect/AIE/Transforms/AIETraceToConfig.cpp
fifield Mar 3, 2026
064c2a7
remove hard coded path
fifield Mar 3, 2026
fec10c5
refine search for direction flag
fifield Mar 3, 2026
4315202
fix it
fifield Mar 3, 2026
8040a53
fix strix
fifield Mar 4, 2026
714b152
fix strix again
fifield Mar 4, 2026
bf3bb65
test trace ops python binding; update example to set device in makefile
fifield Mar 4, 2026
673fecd
add missing files
fifield Mar 4, 2026
170e2ad
format
fifield Mar 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/aie/Dialect/AIE/IR/AIEAttrs.td
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define AIE_ATTRS

include "aie/Dialect/AIE/IR/AIE.td"
include "aie/Dialect/AIE/IR/AIETraceAttrs.td"

include "mlir/IR/AttrTypeBase.td"
include "mlir/IR/EnumAttr.td"
Expand Down Expand Up @@ -221,7 +222,7 @@ def InitValuesArrayAttr
// Generated AIE event enumerations
//===----------------------------------------------------------------------===//

include "AIEEvents.td.inc"
include "AIEEventsAIE.td.inc"
include "AIEEventsAIE2.td.inc"
include "AIEEventsAIE2P.td.inc"

Expand Down
5 changes: 5 additions & 0 deletions include/aie/Dialect/AIE/IR/AIEDialect.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ void printObjectFifoConsumerTiles(mlir::OpAsmPrinter &printer,

int32_t getBufferBaseAddress(mlir::Operation *bufOp);

// Trace Event Value Parsing/Printing (handles both string and typed enums)
mlir::ParseResult parseTraceEvent(mlir::AsmParser &parser,
mlir::Attribute &result);
void printTraceEventEnum(mlir::AsmPrinter &printer, mlir::Attribute attr);

} // namespace xilinx::AIE

// include TableGen generated Op definitions
Expand Down
2 changes: 2 additions & 0 deletions include/aie/Dialect/AIE/IR/AIEOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
class AIE_Op<string mnemonic, list<Trait> traits = []> :
Op<AIE_Dialect, mnemonic, traits>;

include "aie/Dialect/AIE/IR/AIETraceOps.td"


def AIE_DeviceOp: AIE_Op<"device", [
Symbol,
Expand Down
26 changes: 26 additions & 0 deletions include/aie/Dialect/AIE/IR/AIETargetModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ class AIETargetModel {
/// Return the number of buffer descriptors for a given tile type.
virtual uint32_t getNumBDs(AIETileType tileType) const = 0;

/// Get stream switch port index for a given port specification
/// Return port index for Stream_Switch_Event_Port_Selection register, or
/// nullopt if invalid
virtual std::optional<uint32_t>
getStreamSwitchPortIndex(int col, int row, WireBundle bundle,
uint32_t channel, bool master) const = 0;

/// Return the number of buffer descriptors supported by the DMA in the given
/// tile.
uint32_t getNumBDs(int col, int row) const {
Expand Down Expand Up @@ -383,6 +390,15 @@ class AIETargetModel {
/// Encode a field value with proper bit shifting.
/// Return Value shifted to correct bit position
uint32_t encodeFieldValue(const BitFieldInfo &field, uint32_t value) const;

/// Compute a 32-bit mask for a register field.
/// Return nullopt if the field does not fit in a 32-bit register.
std::optional<uint32_t> getFieldMask(const BitFieldInfo &field) const;

/// Resolve stream switch port specification to port index.
/// Return Port index for stream switch register, or nullopt if invalid
std::optional<uint32_t> resolvePortValue(llvm::StringRef value, TileID tile,
bool master) const;
};

class AIE1TargetModel : public AIETargetModel {
Expand Down Expand Up @@ -463,6 +479,11 @@ class AIE1TargetModel : public AIETargetModel {
int srcChan, WireBundle dstBundle,
int dstChan) const override;

std::optional<uint32_t> getStreamSwitchPortIndex(int col, int row,
WireBundle bundle,
uint32_t channel,
bool master) const override;

uint32_t getColumnShift() const override { return 23; }
uint32_t getRowShift() const override { return 18; }

Expand Down Expand Up @@ -573,6 +594,11 @@ class AIE2TargetModel : public AIETargetModel {
int srcChan, WireBundle dstBundle,
int dstChan) const override;

std::optional<uint32_t> getStreamSwitchPortIndex(int col, int row,
WireBundle bundle,
uint32_t channel,
bool master) const override;

uint32_t getColumnShift() const override { return 25; }
uint32_t getRowShift() const override { return 20; }

Expand Down
162 changes: 162 additions & 0 deletions include/aie/Dialect/AIE/IR/AIETraceAttrs.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
//===- AIETraceAttrs.td ------------------------------------*- tablegen -*-===//
//
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// Copyright (C) 2025, Advanced Micro Devices, Inc.
//
//===----------------------------------------------------------------------===//
// Defines attributes for AIE trace operations
//===----------------------------------------------------------------------===//

#ifndef AIE_TRACE_ATTRS
#define AIE_TRACE_ATTRS

include "aie/Dialect/AIE/IR/AIE.td"
include "mlir/IR/AttrTypeBase.td"
include "mlir/IR/EnumAttr.td"

//===----------------------------------------------------------------------===//
// Trace Mode Enumeration
//===----------------------------------------------------------------------===//

def TraceModeEventTime : I32EnumAttrCase<"EventTime", 0, "Event-Time">;
def TraceModeEventPC : I32EnumAttrCase<"EventPC", 1, "Event-PC">;
def TraceModeExecution : I32EnumAttrCase<"Execution", 2, "Execution">;

def TraceModeAttr : I32EnumAttr<"TraceMode",
"Trace capture mode",
[
TraceModeEventTime,
TraceModeEventPC,
TraceModeExecution
]> {
let cppNamespace = "::xilinx::AIE";
let description = [{
Specifies the trace mode:
- Event-Time (00): Captures event occurrence with timestamp
- Event-PC (01): Captures program counter when event occurs
- Execution (10): Instruction-level execution trace
}];
}

//===----------------------------------------------------------------------===//
// Packet Type Enumeration
//===----------------------------------------------------------------------===//

def TracePacketTypeCore : I32EnumAttrCase<"Core", 0, "core">;
def TracePacketTypeMem : I32EnumAttrCase<"Mem", 1, "mem">;
def TracePacketTypeShimTile : I32EnumAttrCase<"ShimTile", 2, "shimtile">;
def TracePacketTypeMemTile : I32EnumAttrCase<"MemTile", 3, "memtile">;

def TracePacketTypeAttr : I32EnumAttr<"TracePacketType",
"Packet type identifier for parsing",
[
TracePacketTypeCore,
TracePacketTypeMem,
TracePacketTypeShimTile,
TracePacketTypeMemTile
]> {
let cppNamespace = "::xilinx::AIE";
let description = [{
Packet Type Convention:
- 0: Core tile (CORE_MODULE)
- 1: Core tile (MEMORY_MODULE)
- 2: Shim tile
- 3: Mem tile
}];
}

//===----------------------------------------------------------------------===//
// Trace Event Attribute
//===----------------------------------------------------------------------===//

def TraceEventAttr : AttrDef<AIE_Dialect, "TraceEvent"> {
let mnemonic = "trace_event";
let summary = "Reference to a trace event by name or enum";

let description = [{
References an event by name string or typed enum. Strings are used for
generic references that are resolved during lowering. Enums provide
compile-time type checking.

Validated against:
- Tile type (core events only valid for core tiles, etc.)
- Architecture (AIE/AIE2/AIE2P/AIE4)

Examples:
"INSTR_EVENT_0" // String (resolved during lowering)
CoreEventAIE2::INSTR_EVENT_0 // Enum
}];

let parameters = (ins
"Attribute":$value
);

let assemblyFormat = "`<` custom<TraceEventValue>($value) `>`";

let extraClassDeclaration = [{
// Helper to get event name as string for lookups
std::string getEventName() const;

// Check if this is a string attribute (needs promotion)
bool isStringAttr() const;

// Get the underlying enum value if this is an enum
std::optional<int64_t> getEnumValue() const;
}];
}

//===----------------------------------------------------------------------===//
// Combo Event Logic Enumeration
//===----------------------------------------------------------------------===//

def ComboLogicAND : I32EnumAttrCase<"AND", 0, "AND">;
def ComboLogicAND_NOT : I32EnumAttrCase<"AND_NOT", 1, "AND_NOT">;
def ComboLogicOR : I32EnumAttrCase<"OR", 2, "OR">;
def ComboLogicOR_NOT : I32EnumAttrCase<"OR_NOT", 3, "OR_NOT">;

def ComboLogicAttr : I32EnumAttr<"ComboLogic",
"Combo event logic function",
[
ComboLogicAND,
ComboLogicAND_NOT,
ComboLogicOR,
ComboLogicOR_NOT
]> {
let cppNamespace = "::xilinx::AIE";
let description = [{
Logical operation for combining two events:
- AND (00): eventA AND eventB
- AND_NOT (01): eventA AND NOT eventB
- OR (10): eventA OR eventB
- OR_NOT (11): eventA OR NOT eventB
}];
}

//===----------------------------------------------------------------------===//
// Edge Detection Trigger Mode Enumeration
//===----------------------------------------------------------------------===//

def EdgeTriggerRISING : I32EnumAttrCase<"RISING", 1, "RISING">;
def EdgeTriggerFALLING : I32EnumAttrCase<"FALLING", 2, "FALLING">;
def EdgeTriggerBOTH : I32EnumAttrCase<"BOTH", 3, "BOTH">;

def EdgeTriggerAttr : I32EnumAttr<"EdgeTrigger",
"Edge detection trigger mode",
[
EdgeTriggerRISING,
EdgeTriggerFALLING,
EdgeTriggerBOTH
]> {
let cppNamespace = "::xilinx::AIE";
let description = [{
Edge detection trigger mode:
- RISING (01): Trigger on rising edge (0→1 transition)
- FALLING (10): Trigger on falling edge (1→0 transition)
- BOTH (11): Trigger on both edges
}];
}

#endif // AIE_TRACE_ATTRS
Loading
Loading