CodiodeCodiode
Home
Problem Solving
Skill Tracks
My Assignments
Contests
Leaderboard
Community
Settings
Codiode/Problems/Combinational Logic

Signed Arithmetic and Sign Extension

HardVerilog / SystemVerilogBuild

Digital signal processing datapaths frequently require signed arithmetic. Verilog's default evaluation rules aggressively coerce mixed or unannotated vectors into unsigned types. A single unsigned wire in an expression can silently destroy the arithmetic integrity of the entire pipeline by preventing automatic sign extension.

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 a and b are provided as standard unannotated vectors but must be treated as signed two's complement values.
  • Output p must be a valid 16-bit signed two's complement representation of the product.
  • Do not use any clock or reset signals.

Topics

CombinationalArithmeticSigned Math

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.

Sign in to solveSee what Pro unlocks

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.

Related problems

  • Single Continuous AssignmentEasy
  • Basic Vector ConcatenationEasy
  • Ternary Operator MuxEasy
  • Underscores for ReadabilityEasy
  • Left Hand Side ConcatenationEasy
  • Inout Port MechanicsEasy
  • Explicit Binary LiteralsEasy
  • Vector Port EndiannessEasy

Browse all problems · Learning tracks