Trace Encoder Control Interface
Many features of the Trace Encoder (TE for short) are optional. In most cases, optional features are enabled using a WARL (write any, read legal) register field. A debugger can determine if optional feature is present by writing to the register field and reading back the result.
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
0 |
trTeActive |
Primary activate/reset bit for the TE. When 0, the TE may have clocks gated off or be powered down, and other register locations may be inaccessible. Hardware may take an arbitrarily long time to process power-up and power-down and will indicate completion when the read value of this bit matches what was written. See Reset and Discovery chapter for more details. |
RW |
0 |
1 |
trTeEnable |
1: Trace Encoder is enabled. Allows |
RW |
0 |
2 |
trTeInstTracing |
1: Instruction trace is being generated. Written from a trace tool (after a write to |
RW |
|
3 |
trTeEmpty |
Reads as 1 when all generated trace have been emitted. |
RO |
1 |
6:4 |
trTeInstMode |
Instruction trace generation mode |
WARL |
|
8:7 |
— |
Reserved |
— |
0 |
9 |
trTeContext |
Enable sending trace messages/fields with scontext/mcontext values and/or privilege levels. |
WARL |
|
10 |
— |
Reserved |
— |
0 |
11 |
trTeInstTrigEnable |
1: Allows |
WARL |
|
12 |
trTeInstStallOrOverflow |
Set to 1 by hardware when trace buffer overflow (also known as trace lost) occurs, or when the TE requests a hart stall. Clears to 0 at TE reset or when the trace is enabled ( |
RW1C |
|
13 |
trTeInstStallEna |
0: If TE cannot send a message, the message is dropped. The protocol dependent overflow instruction trace synchronization message/packet is generated when the trace is restarted, so the decoder will know that trace is lost and must reset any internal decoder state. |
WARL |
|
14 |
— |
Reserved |
— |
0 |
15 |
trTeInhibitSrc |
0: Messages/packets generated by the trace encoder include a message source field if the
source width held in |
WARL |
|
17:16 |
trTeInstSyncMode |
Select the periodic instruction trace synchronization message/packet generation mechanism. At least one non-zero mechanism must be implemented. |
WARL |
|
19:18 |
— |
Reserved |
— |
0 |
23:20 |
trTeInstSyncMax |
The maximum interval (in units determined by |
WARL |
|
26:24 |
trTeFormat |
Trace recording/protocol format: |
WARL |
|
31:27 |
— |
Reserved |
— |
0 |
Writing to this register while trace is enabled may unintentionally change a value of trTeInstTracing bit because that bit may dynamically change by triggers.
|
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
3:0 |
trTeVerMajor |
Trace Encoder Component Major Version. Value 1 means the component is compliant with this document. Value 0 means pre-ratified/initial version - see 'Pre-ratified/Initial Interface Version' chapter at the end. |
RO |
1 |
7:4 |
trTeVerMinor |
Trace Encoder Component Minor Version. Value 0 means the component is compliant with this document. |
RO |
0 |
11:8 |
trTeCompType |
Trace Encoder Component Type (Trace Encoder) |
RO |
0x1 |
15:12 |
— |
Reserved for future versions of this standard |
— |
0 |
19:16 |
trTeProtocolMajor |
Trace Protocol Major Version. As specified by specification governing |
RO |
|
23:20 |
trTeProtocolMinor |
Trace Protocol Minor Version. As specified by specification governing |
RO |
|
31:24 |
— |
Reserved for vendor specific implementation details |
— |
trTeProtocol?? fields are separated from trTeVer?? as we may have the same control interface, but protocol itself may be extended with new packets/ messages/ fields.
|
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
0 |
trTeInstNoAddrDiff |
When set, trace messages/packets always carry a full address. |
WARL |
|
1 |
trTeInstNoTrapAddr |
When set, do not include trap handler address in trap messages/packets. |
WARL |
|
2 |
trTeInstEnSequentialJump |
When set, treat sequentially inferrable jumps as inferable PC discontinuities. |
WARL |
|
3 |
trTeInstEnImplicitReturn |
When set, treat returns as inferable PC discontinuities when returning from a recent call on a stack. Field |
WARL |
|
4 |
trTeInstEnBranchPrediction |
When set, Branch Predictor based compression is enabled. |
WARL |
|
5 |
trTeInstEnJumpTargetCache |
When set, Jump Target Cache based compression is enabled. |
WARL |
|
7:6 |
trTeInstImplicitReturnMode |
Defines how the decoder is handling stack of return addresses (if enabled by |
WARL |
|
8 |
trTeInstEnRepeatedHistory |
Enable repeated branch history/map detection when set. |
WARL |
|
9 |
trTeInstEnAllJumps |
Enable emitting of trace message or add history/map bit for direct unconditional/inferable control flow changes (jumps or calls). Normally these instructions do not generate any trace as the decoder can determine the next instruction. Trace will not compress well but timestamp accuracy will be better - may be used when profiling loops. |
WARL |
|
10 |
trTeInstExtendAddrMSB |
When set, allow extended handing of MSB address bits. Encoding details are trace protocol dependent. |
WARL |
|
15:11 |
— |
Reserved for additional instruction trace control/status bits |
— |
0 |
27:16 |
trTeSrcID |
Trace source ID assigned to this trace encoder. If |
WARL |
|
31:28 |
trTeSrcBits |
The number of bits in the trace source field (0..12), unless disabled by |
WARL |
Applicability of different trTeInst?? fields for each trace encoding protocol is described in a document which defines the protocol (and not all fields are applicable to all protocols).
|
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
15:0 |
trTeInstFilters |
Determine which filters defined in Trace Encoder Filter Registers chapter qualify an instruction trace. If bit n is a 1 then instructions will be traced when filter n matches. If all bits are 0, all instructions are traced. |
WARL |
|
31:16 |
— |
Reserved |
— |
0 |
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
0 |
trTeDataImplemented |
Read as 1 if data trace is implemented. |
RO |
|
1 |
trTeDataTracing |
1: Data trace is being generated. Written from a trace tool or controlled by triggers. When |
WARL |
|
2 |
trTeDataTrigEnable |
Global enable/disable for data trace triggers |
WARL |
|
3 |
trTeDataStallOrOverflow |
Set to 1 by hardware when data trace causes trace buffer overflow, or when the TE requests a hart stall due to data trace. Clears to 0 at TE reset or when the trace is enabled ( |
RW1C |
|
4 |
trTeDataStallEna |
0: If TE cannot send data trace messages, an overflow message is generated when the trace is restarted. |
WARL |
|
5 |
trTeDataDrop |
Written to 1 by hardware when the data trace packet was dropped (if enabled). Clears to 0 at TE reset or when the trace is enabled ( |
RW1C |
|
6 |
trTeDataDropEna |
1: Allow temporary suppression of data trace (at some watermark level) to prevent trace overflow or stall. This way instruction trace will have higher priority. |
WARL |
|
15:7 |
— |
Reserved for additional data trace control/status bits. |
— |
0 |
16 |
trTeDataNoValue |
When set, omit data values from data trace packets. |
WARL |
|
17 |
trTeDataNoAddr |
When set, omit data address from data trace packets. |
WARL |
|
19:18 |
trTeDataAddrCompress |
Data trace address compression selection: |
WARL |
|
31:20 |
— |
Reserved |
— |
0 |
Writing to this register while trace is enabled may unintentionally change a value of trTeDataTracing bit because that bit may dynamically change by triggers.
|
Applicability of different trTeData?? fields for each trace encoding protocol is described in a document which defines the protocol (and not all fields are applicable to all protocols).
|
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
15:0 |
trTeDataFilters |
Determine which filters defined in Trace Encoder Filter Registers chapter qualify data trace. If bit n is a 1 then data accessed will be traced when filter n matches. If all bits are 0, all data accesses are traced. |
WARL |
|
31:16 |
— |
Reserved |
— |
0 |
Timestamp Unit
Timestamp Unit is an optional sub-component present in either Trace Encoder or Trace Funnel. An implementation may choose from several modes of timestamps:
-
Internal System - fixed clock in a system (such as bus clock) is used to increment the timestamp counter (for both Trace Encoders and Trace Funnels)
-
Internal Core - core clock is used to increment the timestamp counter (only for Trace Encoders)
-
Shared - shares timestamp with another Trace Encoder or Trace Funnel
-
External - accepts a binary timestamp value from an outside source such as ARM CoreSight™ trace (for both Trace Encoders and Trace Funnels)
Implementations may have no timestamp, one timestamp mode, or more than one mode. The WARL field trTsMode is used to determine the system capability and to set the desired timestamp mode.
The width of the timestamp is implementation dependent, typically 40 or 48 bits (40-bit timestamp will overflow every 4.7 minutes assuming 1GHz timestamp clock).
In a system with Funnels, typically all the Funnels are built with a Timestamp Unit. The top-level Funnel is the source of the timestamp (Internal System or External) and all the Encoders and other Funnels have a Shared timestamp. This assures that all timestamps in the system are the same and trace from different harts may be time-correlated. To perform the forwarding function, the mid-level Funnels must be programmed with trFunnelActive = 1 (which is natural as all trace messages must pass through that funnel).
An Internal System or Core timestamp unit may include a timestamp clock pre-scaler divider, which can extend the range of a narrower timestamp and uses less power but has less resolution.
In a system with an Internal Core timestamp counter (implemented in Trace Encoder associated with a hart) an optional control bit is provided to stop the counter when the hart is halted by a debugger.
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
0 |
trTsActive |
Primary activate/reset bit for timestamp unit.
This must either be RW or, if separated reset for timestamp component is not implemented, a read-only copy of the corresponding |
WARL |
SD |
1 |
trTsCount |
Internal System or Core timestamp only. |
WARL |
|
2 |
trTsReset |
Internal System or Core timestamp only. |
W1 |
— |
3 |
trTsRunInDebug |
Internal Core timestamp only. |
WARL |
|
6:4 |
trTsMode |
Mode used by Timestamp unit: |
WARL |
|
7 |
— |
Reserved |
— |
0 |
9:8 |
trTsPrescale |
Internal System or Core timestamp only. |
WARL |
|
14:10 |
— |
Reserved |
— |
0 |
15 |
trTsEnable |
Enable for timestamp field in trace messages/packets (for Trace Encoder only). |
WARL |
|
23:16 |
Vendor-specific bits to control what message/packet types include timestamp fields. |
WARL |
||
29:24 |
trTsWidth |
Width of timestamp in bits (0..63) |
RO |
|
31:30 |
— |
Reserved |
— |
0 |
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
31:0 |
trTsCounterLow |
Lower 32 bits of timestamp counter. |
RO |
0 |
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
31:0 |
trTsCounterHigh |
Upper bits of timestamp counter, zero-extended. |
RO |
0 |
Trace Encoder Triggers
Debug Trigger Module
Debug module triggers are signals from the hart that a trigger was hit, but the action associated with that trigger is a trace-related action. Action identifiers 2-5 are reserved for trace actions in the RISC-V Debug Specification, where triggers are defined. Actions 2-4 are defined by the Efficient Trace for RISC-V (E-Trace) Specification. The desired action is written to the action field of the Match Control mcontrol CSR (0x7a1). As not all harts may support all trace actions, the debugger should read back the mcontrol CSR after setting the desired trace action to verify that the option exists.
| Trigger Action (from debug spec) | Effect |
|---|---|
0 |
Breakpoint exception (as defined in RISC-V Debug Specification) |
1 |
Debug exception (as defined in RISC-V Debug Specification) |
2 |
Trace-on action |
3 |
Trace-off action |
4 |
Trace-notify action |
5 |
Vendor-specific trace action (optional) |
If there are vendor-specific features that require control, the trTeTrigDbgControl register is used.
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
31:0 |
trTeTrigDbgControl |
Vendor-specific trigger setup |
WARL |
External Trace Triggers
The TE may be configured with up to 8 external trigger inputs for controlling trace. These are in addition to the external triggers present in the Debug Module when Halt Groups are implemented. The specific hardware signals comprising an external trigger are implementation dependent.
External Trigger Outputs may also be present. A trigger out may be generated by trace starting, trace stopping, a watchpoint, or by other system-specific events.
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
3:0 |
trTeTrigExtInAction0 |
Select action to perform when external trigger input #0 fires. If external trigger input #0 does not exist, then its action is fixed at 0. |
WARL |
|
31:4 |
trTeTrigExtInActionN |
Select actions (as defined for bits 3-0) for external trigger input #N (1..7). If an external trigger input does not exist, then its action is fixed at 0. |
WARL |
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
3:0 |
trTeTrigExtOutEvent0 |
Bitmap to select which event(s) cause external trigger #0 output to fire. If external trigger output #0 does not exist, then all bits are fixed at 0. Bits 2 and 3 may be fixed at 0 if the corresponding feature is not implemented. |
WARL |
|
31:4 |
trTeTrigExtOutEventN |
Select events for external trigger output #N (1..7). If an external trigger output does not exist, then its event bits are fixed at 0 |
WARL |
Triggers Precedence
It is implementation dependent what happens when triggers (from debug module or external) with conflicting actions occur simultaneously (signaled at the same ingress port cycle) or if triggers occur too frequently. It is recommended that tracing starts from the oldest instruction retired in the cycle that Trace-on is asserted, and stops following the newest instruction retired in the cycle that Trace-off is asserted.
Trace Encoder Filter Registers
All registers with offsets 0x400 .. 0x7FC are designated for additional trace encoder filter options (context, addresses, modes, etc.).
Trace encoder filters are an optional feature that can be used to control the generated trace in various ways.
The registers below divide the filter logic into filters and comparators to provide maximum flexibility at low cost. The number of filters and comparators depends on the system. Each filter unit can specify filtering against instruction and optionally against data trace inputs from the hart. When filter i is implemented, the registers trTeFilteriControl and trTeInstFilters must be implemented to enable it. And to apply filter i to the data trace, the trTeDataFilters register must also be present. And if a match bit in the trTeFilteriControl register can be set to 1 (= enabling a filter option), the corresponding register from the bit’s description must have a correct value already set as otherwise the trigger may fire unintentionally. Each of the mentioned comparator units is a pair of comparators (primary and secondary, or P and S), so a limited range can be matched with a single comparator unit if needed.
Each enabled filter define independent condition where trace is enabled - if several filters are enabled they act as logical OR. Several conditions for single filter act as logical AND.
| Filter and comparator registers refer to values of some signals (as priv, itype, ecause, dtype, dsize, …) available on Trace Ingress Port. See E-Trace specification for details of encoding of these values. |
| Address Offset | Register Name | Compliance | Description |
|---|---|---|---|
0x400 + 0x20*i |
trTeFilteriControl |
Optional |
Filter i control |
0x404 + 0x20*i |
trTeFilteriMatchInst |
Optional |
Filter i instruction match control |
0x408 + 0x20*i |
trTeFilteriMatchEcauseLow |
Optional |
Filter i Ecause match control (bits 31:0) |
0x40C + 0x20*i |
trTeFilteriMatchEcauseHigh |
Optional |
Filter i Ecause match control (bits 63:32) |
0x410 + 0x20*i |
trTeFilteriMatchValueImpdef |
Optional |
Filter i impdef value |
0x414 + 0x20*i |
trTeFilteriMatchMaskImpdef |
Optional |
Filter i impdef mask |
0x418 + 0x20*i |
trTeFilteriMatchData |
Optional |
Filter i Data trace match control |
0x41C + 0x20*i |
— |
Optional |
Reserved |
| Address Offset | Register Name | Compliance | Description |
|---|---|---|---|
0x600 + 0x20*j |
trTeCompjControl |
Optional |
Comparator j control |
0x604 + 0x20*j |
— |
Optional |
Reserved |
0x608 + 0x20*j |
— |
Optional |
Reserved |
0x60c + 0x20*j |
— |
Optional |
Reserved |
0x610 + 0x20*j |
trTeCompjPmatchLow |
Optional |
Comparator j primary match (bits 31:0) |
0x614 + 0x20*j |
trTeCompjPmatchHigh |
Optional |
Comparator j primary match (bits 63:32) |
0x618 + 0x20*j |
trTeCompjSmatchLow |
Optional |
Comparator j secondary match (bits 31:0) |
0x61C + 0x20*j |
trTeCompjSmatchHigh |
Optional |
Comparator j secondary match (bits 63:32) |
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
0 |
trTeFilterEnable |
Overall filter enable for filter #i |
WARL |
|
1 |
trTeFilterMatchPrivilege |
When set, match privilege levels specified by |
WARL |
|
2 |
trTeFilterMatchEcause |
When set, start matching from exception cause codes specified by |
WARL |
|
3 |
trTeFilterMatchInterrupt |
When set, start matching from either an interrupt or exception as specified by
|
WARL |
|
4 |
trTeFilterMatchComp1 |
When set, the output of the comparator selected by |
WARL |
|
7:5 |
trTeFilterComp1 |
Specifies the comparator unit to use for the 1st comparison. |
WARL |
|
8 |
trTeFilterMatchComp2 |
When set, the output of the comparator selected by |
WARL |
|
11:9 |
trTeFilterComp2 |
Specifies the comparator unit to use for the 2nd comparison. |
WARL |
|
12 |
trTeFilterMatchComp3 |
When set, the output of the comparator selected by |
WARL |
|
15:13 |
trTeFilterComp3 |
Specifies the comparator unit to use for the 3rd comparison. |
WARL |
|
16 |
trTeFilterMatchImpdef |
When set, match impdef values as specified by |
WARL |
|
23:17 |
— |
Reserved |
— |
0 |
24 |
trTeFilterMatchDtype |
When set, match dtype values as specified by |
WARL |
|
25 |
trTeFilterMatchDsize |
When set, match dsize values as specified by |
WARL |
|
31:26 |
— |
Reserved |
— |
0 |
Handling of trTeFilterMatchEcause and trTeFilterMatchInterrupt should include a count of nested traps. The size of the counter is implementation dependent. If the number of nested traps exceeds the number that can be counted, the counter will saturate, meaning that the filtering will turn off prematurely.
|
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
7:0 |
trTeFilterMatchChoicePrivilege |
When |
WARL |
|
8 |
trTeFilterMatchValueInterrupt |
When |
WARL |
|
31:9 |
— |
Reserved |
— |
0 |
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
31:0 |
trTeFilterMatchChoiceEcauseLow |
When |
WARL |
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
31:0 |
trTeFilterMatchChoiceEcauseHigh |
Stores bits 63:32 to allow matching of higher ecause codes. If bit N is 1, then match if the ecause is N+32. |
WARL |
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
31:0 |
trTeFilterMatchValueImpdef |
When |
WARL |
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
31:0 |
trTeFilterMatchMaskImpdef |
When |
WARL |
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
15:0 |
trTeFilterMatchChoiceDtype |
When |
WARL |
|
23:16 |
trTeFilterMatchChoiceDsize |
When |
WARL |
|
31:24 |
— |
Reserved |
— |
0 |
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
1:0 |
trTeCompPInput |
Determines which input to compare against the primary comparator. |
WARL |
|
3:2 |
trTeCompSInput |
Determines which input to compare against the secondary comparator. Same encoding as |
WARL |
|
6:4 |
trTeCompPFunction |
Selects the primary comparator function. Primary result is true if input selected via |
WARL |
|
7 |
— |
Reserved |
— |
0 |
10:8 |
trTeCompSFunction |
Selects the secondary comparator function. Secondary result is true if input selected via |
WARL |
|
11 |
— |
Reserved |
— |
0 |
13:12 |
trTeCompMatchMode |
Selects the match condition used to assert the overall comparator output |
WARL |
|
14 |
trTeCompPNotify |
Generate a trace packet explicitly reporting the address
of the final instruction in a block that causes a
primary match. This is also known as a watchpoint.
Requires |
WARL |
|
15 |
trTeCompSNotify |
Generate a trace packet explicitly reporting the address
of the final instruction in a block that causes a
secondary match. This is also known as a watchpoint.
Requires |
WARL |
|
31:16 |
— |
Reserved |
— |
0 |
Comparisions are performed as unsigned numbers. Only bits from an input signal (as defined by trTeCompPInput and/or trTeCompSInput fields), should be compared. Additional most significant bits from the trTeCompjPMatchLow/High registers must be ignored.
|
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
31:0 |
trTeCompPMatchLow |
The match value for the primary comparator (bits 31:0). |
WARL |
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
31:0 |
trTeCompPMatchHigh |
The match value for the primary comparator (bits 63:32). |
WARL |
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
31:0 |
trTeCompSMatchLow |
The match value for the secondary comparator (bits 31:0). |
WARL |
| Bit | Field | Description | RW | Reset |
|---|---|---|---|---|
31:0 |
trTeCompSMatchHigh |
The match value for the secondary comparator (bits 63:32). |
WARL |