Verification #8 · 2026-10-01 · Randomization · Easy · about 10 min
The checksum that's one packet behind
packet carries len payload bytes, data[0] to data[len-1], and a checksum chk. chk isn't random: it must equal the XOR of the bytes in use, and it must be right after every successful randomize() call. That includes calls on a packet that has been randomized before, and calls with inline constraints (randomize() with {...}).
Run randomizes one packet five times and prints chk next to the value it should have. Fix packet.sv.
Write and run your answer in the browser. The hidden tests check it, and it’s free.