Skip to content

Conversation

IainCRobertson
Copy link
Collaborator

Draft PR with informative clarifications on partial timestamps in packet encapsulation.


Where packets are encapsulated according to the https://github.com/riscv-non-isa/e-trace-encap/releases/latest/[Unformatted Trace & Diagnostic Data Packet Encapsulation for RISC-V Specification], this includes provision for an optional N-byte timestamp within the encapsulation itself. This can be used to include a timestamp value with any of the trace packets defined in this specification. It is not usually desirable to include full timestamps (e.g. up to 64-bits) in each packet, as this adds a significant overhead, and the difference in timestamp values between successive packets is usually quite small. Using smaller, partial encapsulation timestamps (e.g. 16 bits) is typical.

With partial encapsulation timestamps, software can reconstruct the full timestamp value of any packet, provided that it initially receives a full timestamp (either in a sync packet, or possibly a dedicated timestamp packet), and then the interval between successive packets carrying only a partial encapsulation timestamp is less than 2^N^*8 ticks of the timestamp clock. When a packet is received with a timestmap value smaller than the previous one, software can deduce that time has moved forward by an additional 2^N^*8 ticks.
Copy link
Contributor

@pdonahue-ventana pdonahue-ventana Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo:

Suggested change
With partial encapsulation timestamps, software can reconstruct the full timestamp value of any packet, provided that it initially receives a full timestamp (either in a sync packet, or possibly a dedicated timestamp packet), and then the interval between successive packets carrying only a partial encapsulation timestamp is less than 2^N^*8 ticks of the timestamp clock. When a packet is received with a timestmap value smaller than the previous one, software can deduce that time has moved forward by an additional 2^N^*8 ticks.
With partial encapsulation timestamps, software can reconstruct the full timestamp value of any packet, provided that it initially receives a full timestamp (either in a sync packet, or possibly a dedicated timestamp packet), and then the interval between successive packets carrying only a partial encapsulation timestamp is less than 2^N^*8 ticks of the timestamp clock. When a packet is received with a timestamp value smaller than the previous one, software can deduce that time has moved forward by an additional 2^N^*8 ticks.

Also, I don't think that time has moved forward by an additional 2N*8 (which is a fixed amount) but rather that bit N*8-1 overflowed. The saved value of [63:N*8] should be incremented from the previous value and then the timestamp of width N*8 should be pasted onto the bottom in bits [N*8-1:0]. (There has to be a more concise way to say this.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think all that was missing from the description was to make it explicitly clear that the bottom bits of the reconstructed timestamp are taken from the encapsulation timestamp. I've updated it, and hopefully it's clear now (and still reasonably succinct)?

@IainCRobertson
Copy link
Collaborator Author

IainCRobertson commented Aug 1, 2025 via email

@bcstrongx
Copy link
Collaborator

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants