RTL Design #59 · 2026-11-21 · Multipliers · Medium · about 30 min
A shift-and-add multiplier
Build a sequential shift-and-add multiplier, shift_mul, in mul.sv. It multiplies two unsigned N-bit numbers (N is 8 by default) using one adder, one step per clock, and takes exactly N clocks per product.
Requirements:
startis honoured on a rising edge wherebusyis 0. That edge capturesaandb; later changes toaandbhave no effect on the running multiplication. Astartwhilebusyis 1 is ignored.busyis 1 from the edge that acceptsstartuntil the edge that finishes the multiplication, which is theNth edge after it. Sobusyreads 1 for exactlyNcycles.- The edge that finishes the multiplication sets
busyto 0, drivesdoneto 1 for exactly one cycle, and loadsproductwith the full2N-bit result. productkeeps that value until the next multiplication finishes. It does not change while a new one is running.rst_nis a synchronous, active-low reset. It clearsbusy,doneandproduct, and abandons any multiplication in progress (nodone). Reset wins overstarton the same edge.
Example, N = 8, a = 13, b = 11, with start high only on edge 0:
| after edge | busy |
done |
product |
|---|---|---|---|
| 0 | 1 | 0 | 0 |
| 1 … 7 | 1 | 0 | 0 |
| 8 | 0 | 1 | 143 |
| 9 | 0 | 0 | 143 |
Write and run your answer in the browser. The hidden tests check it, and it’s free.