Tutorials
FPGA Timestamp Rollover: Measure Elapsed Time Without Misordering Events
Published · Updated
A timestamp needs a range as well as a tick
A 32-bit counter ticking at 100 MHz wraps every 42.94967296 seconds. Its ten-nanosecond resolution says nothing about whether two records separated by several minutes can be ordered without extra information. Record width, tick period, reset behavior and the longest possible observation gap.

If the earlier event is known and the real elapsed interval is less than one wrap, unsigned modular subtraction recovers the elapsed tick count. For an 8-bit example, start 250 and end 5 give (5−250) mod 256 = 11 ticks. The same pair could also hide an additional full wrap; the values alone cannot rule that out.
Transfer event pulses without assuming every pulse is seen.
Record the clock source and board bring-up conditions.
Do not confuse elapsed time with event ordering
Ordering two otherwise unknown sequence values requires a stronger distance assumption. Within a half-range comparison convention, a forward modular difference below half the space identifies one direction; above half identifies the other. Exactly half is ambiguous. RFC 1982 describes this finite-sequence-space issue for serial numbers, not an FPGA timestamp peripheral.
The worksheet therefore presents two results separately: a modular forward distance, and an ordering interpretation only when you explicitly confirm the half-range assumption. Equal values can mean the same tick or different wraps. Do not silently turn an unknown interval into a zero-duration event.
Define clock-domain boundaries.
Carry an epoch when the log can outlive the counter
Extend the record with an epoch or a wider coherently captured timestamp when the required interval exceeds the safe range. Capture the complete value as one logical transaction. Reading a changing low word and then a high word without a coherency protocol can create a timestamp that never existed.
Use integer arithmetic for wide counters. JavaScript Number cannot exactly represent every 64-bit integer, so the page uses BigInt for tick arithmetic and limits decimal conversion to display estimates. Reset boundaries remain explicit; modular arithmetic cannot distinguish a reset from ordinary rollover without additional evidence.
Retain a repeatable startup test.
Forward ticks across 8-bit wrap: short sequence

Start residue 250: elapsed 0: 0 elapsed ticks → Residue 255: elapsed 5: 5 elapsed ticks → Residue 0: elapsed 6: 6 elapsed ticks → End residue 5: elapsed 11: 11 elapsed ticks
Export your result with its assumptions. For an unresolved board or implementation issue, prepare an engineering review with the exact part, revision and relevant record. This link opens the review page; it does not send your worksheet.
Sources and scope
Sources checked 18 November 2026. Numerical examples are calculated cases. Hardware measurements and device timing closure are outside the results shown here.
Back to Tutorials