Q235FreeSystemVerilog
Handle wrapping 8-bit sequence numbers
Interview prompt
Question
Adapt window membership and advancement to 8-bit sequence numbers that wrap from 255 to 0.
Starting point
Question code
function bit in_window(byte unsigned seq);
function void advance_base();Reviewed example
Trace one case
Input
8-bit sequence stream near rollover: 254, 255, 0, 1Expected output
All four values are classified as consecutive; next expected sequence is 2.Modulo-256 distance treats 0 as the successor of 255 rather than as an old packet.
What to cover
Requirements
- Compute forward distance modulo 256.
- Treat seq equal to base as distance zero.
- Restrict the window to at most 128 entries so old and future values are unambiguous.
- Wrap base modulo 256 after retirement.

