Codiode

Q4.4 and Q2.6 Addition

MediumVerilog / SystemVerilogBuild1 solved

Fixed-point numbers only add correctly once their binary points line up. An adder just adds bit 0 to bit 0; it has no idea what each bit is worth.

This module takes two unsigned fixed-point values with different formats and computes their sum. The first input uses a Q4.4 format (4 integer bits, 4 fractional bits) and the second uses a Q2.6 format (2 integer bits, 6 fractional bits). The module aligns their radix points and produces a Q5.6 result (5 integer bits, 6 fractional bits) to guarantee no precision loss or overflow.

Signal Direction Width Description
a input 8 Unsigned Q4.4 value
b input 8 Unsigned Q2.6 value
c output 11 Unsigned Q5.6 sum of a and b

Constraints

  • The circuit must be purely combinational.
  • Both inputs and the output must be treated as unsigned values.
  • The radix points must be perfectly aligned before addition by padding the fractional bits of the Q4.4 input with zeros.
  • The integer bits must be padded with zeros to match the 11-bit target width before addition to prevent overflow.

Topics

Combinational LogicDatapathFixed Point

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 Datapath Design

Problem 16 of 27 in the Datapath Design track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

Solve this on a laptopSend yourself the link and continue there.