This section describes the interface between a core and its RISC-V trace module (see Figure 1). The trace interface conveys information about instruction-retirement and exception events.
Table 1 lists the fields of an instruction trace packet. The valid signal is 1 if and only if an instruction retires or traps (either by generating a synchronous exception or taking an interrupt). The remaining fields in the packet are only defined when valid is 1.
The iaddr field holds the address of the instruction that was retired or trapped. If address translation is enabled, it is a virtual address else it is a physical address. Virtual addresses narrower than XLEN bits are sign-extended, and physical addresses narrower than XLEN bits are zero-extended.
The insn field holds the instruction that was retired or trapped. For instructions narrower than the maximum width, for example, those in the RISC-V C extension, the unused high-order bits are zero-filled. The length of the instruction can be determined by examining the low-order bits of the instruction, as described in The RISC-V Instruction Set Manual, Volume I: User-Level ISA, Version 2.1. The width of the insn field, ILEN, is 32 bits for current implementations.
The priv field indicates the Privilege mode at the time of instruction execution. (On an exception, the next valid trace packet’s priv field gives the Privilege mode of the activated trap handler.) The width of the priv field, PRIVLEN, is 3, and it is encoded as shown in Table 1.
The exception field is 0 if this packet corresponds to a retired instruction, or 1 if it corresponds to an exception or interrupt. In the former case, the cause and interrupt fields are undefined, and the tval field is zero. In the latter case, the fields are set as follows:
Future optional extensions may define tval to provide ancillary information in cases where it currently supplies zero.
For cores that can retire N instructions per clock cycle, this interface is replicated N times. Lower numbered entries correspond to older instructions. If fewer than N instructions retire, the valid packets need not be consecutive, that is, there may be invalid packets between two valid packets. If one of the instructions is an exception, no recent instruction is valid.
Name | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
valid |
Indicates an instruction has retired or trapped. |
||||||||||
iaddr[XLEN-1:0] |
The address of the instruction. |
||||||||||
insn[ILEN-1:0] |
The instruction. |
||||||||||
priv[PRIVLEN-1:0] |
Privilege mode during execution. Encoding of the priv field is as follows:
Note: Unspecified values are reserved.
|
||||||||||
exception |
0 if the instruction retired; 1 if it trapped. |
||||||||||
interrupt |
0 if the exception was synchronous; 1 if interrupt. |
||||||||||
cause[CAUSELEN-1:0] |
Exception cause. |
||||||||||
tval[XLEN-1:0] |
Exception data. |