FPGA DEVICES · ENGINEERING · SOURCING Source-linked information. Clear project requirements.

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.

Frequency counter and signal-source instruments. Tick period and counter width are separate assumptions in a timestamp record.
Frequency counter and signal-source instruments. Tick period and counter width are separate assumptions in a timestamp record. Photo: Glrx. Original · CC BY-SA 4.0.

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.

8-bit timestamp space8-bit timestamp space064128192250 → 5Forward modular gap: 11An extra full wrapcannot be detected here.
Illustrative model and values; assumptions are stated in the adjacent text.

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.

Three questions, three different recordsThree questions, three different records1Elapsed ticksKnown direction; interval below one wrap2Ordering unknown eventsRequire a valid half-range assumption3Long or interrupted logsRetain an epoch and reset boundary
Illustrative model and values; assumptions are stated in the adjacent text.

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 sequenceForward ticks across 8-bit wrap: 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

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

Related evidence and next tasks

Continue the task with the relevant source scope. These reading paths do not establish interchangeability or current supply.

Source addresses and citation trail

Full source addresses are retained below. Read each citation with its document revision, page, table and applicability conditions above.

  1. https://commons.wikimedia.org/wiki/File:Electronic_instruments_digital_multimeter,_frequency_counter,_frequency_standard_receiver,_and_signal_generator.jpg
  2. https://creativecommons.org/licenses/by-sa/4.0
  3. https://www.rfc-editor.org/rfc/rfc1982.txt
  4. https://projectf.io/posts/fixed-point-numbers-in-verilog/