Signed Arithmetic and Sign Extension
Verilog evaluates an expression as unsigned if any operand in it is unsigned. One unsigned wire is enough to stop sign extension and break a signed product.
The module computes the product of two 8-bit two's complement signed integers. The result is a 16-bit two's complement signed integer. Both inputs arrive as standard logic vectors and must be correctly interpreted as signed values before multiplication to ensure the sign bit is preserved and extended into the upper byte of the result.
This circuit is purely combinational. There is no clock and no reset. The output must reflect the valid signed product of the inputs at all times.
| Signal | Direction | Width | Description |
|---|---|---|---|
a |
input | 8 | Multiplicand; represents a signed two's complement integer |
b |
input | 8 | Multiplier; represents a signed two's complement integer |
p |
output | 16 | Product; represents a signed two's complement integer |
Constraints
- The circuit must be purely combinational.
- Inputs
aandbare provided as standard unannotated vectors but must be treated as signed two's complement values. - Output
pmust be a valid 16-bit signed two's complement representation of the product. - Do not use any clock or reset signals.
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's 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.
Part of Combinational RTL
Problem 11 of 15 in the Combinational RTL track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks