Multipliers
Multiplication is repeated addition with shifts, exactly like the
long-multiplication you learned in school, but in base 2, where each
"digit product" is just an AND. The design computes a * b two ways:
- Combinationally, with
assign product = a * b;. On any modern FPGA this maps to a hardened DSP block (DSP48 on AMD, DSP on Intel/Lattice), a real multiplier circuit that's faster and cheaper than anything built from LUTs. As with adders: write*and let the tools place it. - Sequentially, with a shift-and-add state machine that processes one
bit of
bper clock: if the current low bit ofbis 1, add the (shifted)ainto the accumulator. It needs N clocks but only one adder, the classic area-vs-time trade, still relevant when you need many low-rate multiplies and can't afford DSPs for each.
Watch the sequential unit in the waveform: after start, busy rises,
the accumulator builds up over 4 clocks, then done pulses with the same
answer the combinational multiplier produced instantly.
The width rule: multiplying N-bit by M-bit needs N+M bits,
4x4 -> 8. Truncating a product without thinking is the classic DSP-path
bug; decide explicitly which bits you keep (see the
fixed-point converter for how Q-formats track this).
Experiment: make the sequential multiplier 8x8, or change it to skip
runs of zero bits in b and count how many cycles typical inputs save.