Hardware interview practice
Implement a constant multiply without truncation
For an unsigned 10-bit input, implement y = 9*x + 3 without using the multiplication operator and choose an expression width that preserves the maximum result.
Starting point
Question code
input logic [9:0] x;
output logic [13:0] y;Reviewed example
Work through one case
Input
x = 10'd1023Expected output
y = 14'd9210The maximum input produces 9*1023 + 3 = 9210, which is below 2^14 and therefore fits losslessly in 14 bits.
What to cover
Requirements
- Implement 9*x as (x << 3) + x.
- Extend x before shifting so every intermediate is 14 bits wide.
- Add the constant 3 without truncation.
- State and verify the maximum possible result.
