RTL Design #33 · 2026-10-26 · Parity · Easy · about 10 min

A parity checker that blames the next frame

par_chk checks the even parity of frames that arrive one bit per cycle.

  • A bit is transferred in each cycle where valid is 1. din and last mean nothing while valid is 0.
  • The bit with last = 1 is the final bit of its frame, and is the parity bit. A frame can be a single bit long. The next frame may start in the very next cycle.
  • A frame is good if it contains an even number of 1s, parity bit included. In the cycle after a frame's last bit, err is 1 if the frame was bad, and 0 otherwise. err is 0 in all other cycles.
  • rst_n is a synchronous, active-low reset: it abandons any frame in progress.

When you press Run, the frame after the bad one is reported wrong. Fix par_chk.sv. Grading uses four hidden checks.

Write and run your answer in the browser. The hidden tests check it, and it’s free.