Sequential Multiplier with Early Exit
High-performance arithmetic units rely on data-dependent latency to optimize system throughput. A standard sequential shift-and-add multiplier takes N cycles for an N-bit operation, regardless of the operands. By detecting when the remaining multiplier bits are all zero, the control logic can terminate the operation early, bypassing unnecessary clock cycles and saving significant power.
This module is a sequential multiplier that computes the 32-bit product of two 16-bit unsigned integers, a (multiplicand) and b (multiplier). When start is asserted, the module loads the operands and begins computation. For each subsequent clock cycle, it performs a standard shift-and-add step.
The critical feature is the early exit: at the end of any cycle where the remaining unshifted bits of the multiplier evaluate to zero, the module must immediately stop computing, transition to its completion state, and assert done for exactly one clock cycle. The product p must hold the correct result while done is high and remain stable until a new operation begins.
| Signal | Direction | Width | Description | |---|---|---|---| | clk | input | 1 | Positive-edge triggered clock | | rst_n | input | 1 | Asynchronous active-low reset; done and p reset to 0 | | start | input | 1 | High for one cycle to begin multiplication | | a | input | 16 | Multiplicand | | b | input | 16 | Multiplier | | done | output | 1 | Asserted for exactly one cycle when multiplication completes | | p | output | 32 | Product of a and b; valid when done is 1 |
Constraints
- The module must use an asynchronous active-low reset.
- The
donesignal must assert for exactly one clock cycle per operation. - The product
pmust be 0 on reset and hold its final value afterdoneis asserted until a new operation overwrites it. - The operation must complete in exactly
N + 2clock cycles measured from thestartassertion, whereNis the index of the highest set bit inb(e.g., ifbis 4,N=2, total cycles=4). - If
bis 0, the operation must complete in exactly 1 clock cycle afterstart. - If
startis asserted while the module is already computing a product, the newstartpulse must be ignored until the current operation completes.
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against a real testbench — you get the waveform back, not a stored answer.
This problem is part of Codiode Pro. The statement above is free to read.
The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.