Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Check framed serial even parity

Hardware interview practice

Check framed serial even parity

MediumRTL DesignSystemVerilog

Valid cycles carry frame data bits followed by one parity bit. last is asserted only on that parity bit. Implement a serial even-parity checker with a one-cycle result pulse.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Starting point

Question code

clk, reset_n
valid, bit_in, last
parity_valid, parity_ok
active-low synchronous reset
Reviewed example

Work through one case

Input
Case 1: Data 1,0,1 then parity 0
Case 2: Data 1,0,0 then parity 1
Case 3: last=1 on the first accepted bit
Expected output
Case 1: Gives parity_valid=1 and parity_ok=1.
Case 2: Gives parity_ok=1.
Case 3: Produces parity_valid=1 and parity_ok=0.

The shown result follows by applying this rule: The last bit is compared with, not folded into, the prior-data parity. The cases also demonstrate this requirement: If valid && last is accepted before any data bit, pulse parity_valid for one cycle with parity_ok = 0, clear the accumulator, and begin the next frame cleanly; invalid cycles otherwise hold state.

What to cover

Requirements

  1. XOR only accepted data bits into an accumulator; treat the accepted last bit as parity, not data.
  2. On an accepted last bit, pulse parity_valid for one cycle and set parity_ok when bit_in equals the accumulated XOR.
  3. Clear the accumulator after every completed frame and during reset.
  4. If valid && last is accepted before any data bit, pulse parity_valid for one cycle with parity_ok = 0, clear the accumulator, and begin the next frame cleanly; invalid cycles otherwise hold state.
Continue practicing

Related questions

RTL DesignDesign and verify a round-robin arbiter→RTL DesignPredict Priority from If and Case Statements→Temporal ChecksAssert bounded eventual completion→
asic.fyi · Learn silicon end to end.info@asic.fyi