← ProblemsCircuits / Combinational Logic / Arithmetic Circuits

4-digit BCD adder

15%arithmeticvectors

In binary-coded decimal (BCD), each decimal digit is stored in its own 4-bit nibble, so the 16-bit value 16'h1234 represents the decimal number 1234.

You are given a single-digit BCD full adder, bcd_fadd, that adds two BCD digits plus a carry-in and produces a digit sum and a carry-out (binary add; if the result exceeds 9 it adds 6 and carries). The module is already defined in your starter code — do not modify it.

Instantiate four copies of bcd_fadd to build a 4-digit BCD ripple-carry adder that computes a + b + cin, producing a 4-digit sum and a final cout. The carry ripples from the least-significant digit (a[3:0]) to the most-significant one (a[15:12]).

Grading note: the test stimulus drives arbitrary 16-bit patterns, including nibbles above 9 that are not valid BCD digits. The expected behavior is defined as exactly a chain of four bcd_fadd instances — whatever the provided module does with non-BCD inputs is, by definition, correct.