RTL Design #35 · 2026-10-28 · Remainder FSMs · Easy · about 10 min
A remainder tracker that drops the first bit
mod3 receives a number one bit at a time, most significant bit first, and reports its remainder when divided by 3.
- On a rising edge with
valid = 1,dinis the next bit. Withstart = 1as well, it is the first bit of a new number, and whatever came before is forgotten. - After each accepted bit,
remis the remainder of all the bits of the current number so far (0, 1 or 2).remholds whilevalid = 0, andstartis ignored withoutvalid. rst_n = 0(synchronous) clearsremto 0.- Numbers can follow each other with no idle cycle in between, and a number can be a single bit.
Run sends four numbers and some of the remainders come out wrong. Fix mod3.sv. Grading uses three hidden checks.
Write and run your answer in the browser. The hidden tests check it, and it’s free.