Multi-Digit Addition

  1. What Is BCD?

BCD stands for:

BINARY-CODED DECIMAL

BCD represents each DECIMAL DIGIT separately using 4 binary bits.

For example:

Decimal 0

↓

0000

Decimal 1

↓

0001

Decimal 2

↓

0010

...

Decimal 9

↓

1001

The important idea is:

BCD does NOT simply convert an entire decimal number into ordinary binary.

Instead:

Each decimal digit

↓

receives its own 4-bit binary code

  1. Example: Decimal 59 in BCD

The decimal number:

59

contains two decimal digits:

5

and

9

BCD represents each separately.

5

↓

0101

9

↓

1001

Therefore:

59 in BCD

=

0101 1001

This is different from ordinary binary representation of decimal 59.

  1. BCD vs Ordinary Binary

Consider decimal:

12

ORDINARY BINARY:

1100

But BCD represents the decimal digits separately:

1

↓

0001

2

↓

0010

Therefore:

12 in BCD

=

0001 0010

So:

ordinary binary 12

=

1100

BCD 12

=

0001 0010

  1. Valid BCD Digit Codes

A decimal digit can only have the values:

0 through 9.

Therefore, the valid 4-bit BCD codes are:

0000 → 0

0001 → 1

0010 → 2

0011 → 3

0100 → 4

0101 → 5

0110 → 6

0111 → 7

1000 → 8

1001 → 9

These are the 10 valid BCD digit representations.

  1. Invalid BCD Digit Codes

Four binary bits can represent:

16 different combinations

from:

0000

through:

1111

But a decimal digit only needs:

10 values.

Therefore:

1010

1011

1100

1101

1110

1111

do NOT represent valid individual decimal digits in standard BCD.

Conceptually:

0000 through 1001

↓

VALID BCD

1010 through 1111

↓

INVALID BCD DIGIT CODES

  1. Why BCD Addition Needs Special Treatment

Suppose we add two valid BCD digits.

Example:

7 + 5

The decimal result is:

12

Ordinary binary addition gives:

0111

+

0101

=

1100

But:

1100

is not a valid single BCD digit.

Therefore, simply performing ordinary 4-bit binary addition is not always enough.

The result may need BCD CORRECTION.

  1. Preliminary Binary Sum

The first step in BCD addition is to calculate the ordinary binary sum:

a + b + cin

where:

a = first BCD digit

b = second BCD digit

cin = decimal carry from the previous digit

Conceptually:

BCD digit A

+

BCD digit B

+

carry-in

↓

PRELIMINARY BINARY SUM

  1. Why the Preliminary Sum Needs More Than 4 Bits

The largest valid BCD digit is:

9

Therefore, the largest single-digit addition with carry-in is:

9 + 9 + 1

=

19

Binary 19 is:

10011

which requires:

5 bits

Therefore, the preliminary result must be wide enough to represent values from:

0 through 19.

  1. Maximum Single-Digit BCD Addition

For valid BCD inputs:

maximum a = 9

maximum b = 9

maximum cin = 1

Therefore:

maximum preliminary sum

=

9 + 9 + 1

=

19

This tells us something important:

The temporary binary result must be capable of representing:

19

  1. When Is BCD Correction Required?

A single BCD digit can only represent decimal:

0 through 9.

Therefore:

If preliminary sum ≤ 9

↓

No BCD correction is required.

If preliminary sum > 9

↓

BCD correction IS required.

Conceptually:

0 through 9

↓

valid single BCD digit

10 through 19

↓

requires decimal carry + corrected BCD digit

  1. Example Without Correction

Suppose:

3 + 4

Binary:

0011

+

0100

=

0111

Decimal result:

7

Since:

7 ≤ 9

the result is already a valid BCD digit.

Therefore:

BCD result = 0111

carry-out = 0

  1. Example Requiring Correction

Suppose:

7 + 5

Preliminary binary result:

0111

+

0101

=

1100

1100 represents decimal:

12

But:

1100

is not a valid single BCD digit.

Therefore:

BCD correction is required.

  1. The BCD Add-6 Rule

When the preliminary result is greater than 9:

add:

0110

which is decimal:

6

Therefore:

BCD correction

↓

add 6

Example:

7 + 5

=

12

Binary preliminary result:

01100

Add:

00110

Result:

10010

Interpret this as:

carry = 1

BCD digit = 0010

Therefore:

12

↓

BCD representation

↓

0001 0010

  1. Why Do We Add 6?

This rule should not simply be memorized.

Four binary bits provide:

2^4 = 16

possible combinations.

But one BCD digit uses only:

10

of those combinations.

The difference is:

16 - 10 = 6

Therefore:

BCD correction uses:

+6

to compensate for the six unused 4-bit patterns between:

decimal 10

and

binary rollover at 16

  1. Another Way to Understand the Add-6 Correction

Consider preliminary result:

10

Binary:

01010

If we add:

00110

we get:

10000

Now interpret:

1 0000

as:

decimal carry = 1

BCD digit = 0000

Therefore:

10

↓

BCD

↓

0001 0000

The correction transforms the invalid single-digit binary representation into:

correct decimal carry

+

correct BCD low digit

  1. Example: 9 + 9

Calculate:

9 + 9

=

18

Preliminary binary result:

10010

Since:

18 > 9

correction is required.

Add:

00110

to the low-digit correction process:

10010

+

00110

=

11000

Interpret:

carry = 1

BCD digit = 1000

1000 represents:

8

Therefore:

18

↓

BCD

↓

0001 1000

  1. Example: 9 + 9 + 1

Maximum single-digit case:

9 + 9 + 1

=

19

Preliminary binary:

10011

Correction:

10011

+

00110

=

11001

Interpret:

carry = 1

BCD digit = 1001

1001 represents:

9

Therefore:

19

↓

BCD

↓

0001 1001

  1. What Does the BCD Carry Mean?

The carry-out of a BCD digit represents:

one carry into the NEXT DECIMAL DIGIT.

For example:

7 + 5 = 12

The corrected result gives:

carry-out = 1

digit result = 2

Conceptually:

12

↓

1 ten

+

2 ones

Therefore:

BCD carry

↓

moves to the next decimal position

  1. Binary Carry vs Decimal-Digit Carry

In BCD arithmetic, we are ultimately interested in:

DECIMAL-DIGIT CARRY.

This means:

when one decimal digit position produces a result of 10 or greater

↓

carry 1 into the next decimal digit position.

The BCD correction logic converts the preliminary binary addition into this proper decimal-digit representation.

  1. Single-Digit BCD Adder

A single-digit BCD adder conceptually performs:

BCD digit A

+

BCD digit B

+

decimal carry-in

↓

preliminary binary sum

↓

Is result greater than 9?

↓

NO → keep result

YES → apply BCD correction

↓

produce:

4-bit BCD digit

+

decimal carry-out

  1. Two Outputs of a BCD Digit Stage

A BCD digit-adder stage produces:

1. A 4-bit corrected BCD digit

2. A carry-out for the next decimal position

Conceptually:

A digit

B digit

carry-in

↓

BCD ADDER

↓

result digit

+

carry-out

  1. Why the Result Digit Remains 4 Bits

After correction:

the resulting decimal digit must be:

0 through 9

Therefore, its BCD representation always fits in:

4 bits.

Any value representing the next decimal place is separated into:

carry-out

  1. Multi-Digit BCD Addition

Now suppose we want to add decimal numbers containing multiple digits.

Each decimal position can use one BCD-adder stage.

Conceptually:

ONES digit

↓ carry

TENS digit

↓ carry

HUNDREDS digit

↓ carry

THOUSANDS digit

↓

...

The carry propagates between DECIMAL DIGIT POSITIONS.

  1. Example: Two-Digit BCD Addition

Suppose we add:

27

+

35

ONES:

7 + 5

=

12

Result digit:

2

Carry:

1

TENS:

2 + 3 + 1

=

6

Result digit:

6

Carry:

0

Therefore:

27 + 35

=

62

  1. BCD Representation of the Previous Example

27 in BCD:

0010 0111

35 in BCD:

0011 0101

Result:

62

BCD:

0110 0010

Notice that each group of four bits still corresponds to one decimal digit.

  1. Carry Propagation in Multi-Digit BCD

The carry-out from one BCD digit stage becomes:

carry-in of the next BCD digit stage.

Conceptually:

Digit 0

↓ C1

Digit 1

↓ C2

Digit 2

↓ C3

Digit 3

↓

...

This resembles a ripple structure, but the stages operate on:

DECIMAL DIGITS encoded in BCD.

  1. Least-Significant BCD Digit

The first stage handles the:

least-significant decimal digit.

For example, in:

5837

the first BCD stage handles:

7

The next handles:

3

Then:

8

Then:

5

Carry therefore moves from:

less-significant decimal positions

toward:

more-significant decimal positions

  1. Four Bits Per Decimal Digit

Each BCD digit requires:

4 bits.

Therefore:

1 decimal digit

↓

4 bits

2 decimal digits

↓

8 bits

10 decimal digits

↓

40 bits

100 decimal digits

↓

400 bits

General relationship:

N BCD digits

↓

4N bits

  1. Why 100 BCD Digits Require 400 Bits

Each digit requires:

4 bits.

Therefore:

100 digits × 4 bits per digit

=

400 bits

A 100-digit BCD number can therefore be stored in a packed vector such as:

[399:0]

  1. Viewing a 400-Bit Vector as 100 BCD Digits

Conceptually:

bits [3:0]

↓

BCD digit 0

bits [7:4]

↓

BCD digit 1

bits [11:8]

↓

BCD digit 2

...

bits [399:396]

↓

BCD digit 99

Therefore:

one large packed vector

can represent:

many individual BCD digits

  1. Selecting Each BCD Digit

Using indexed part-select knowledge learned previously, a digit can be accessed conceptually using:

a[4*i +: 4]

For:

i = 0

↓

a[3:0]

i = 1

↓

a[7:4]

i = 2

↓

a[11:8]

and so on.

The indexed part-select itself is NOT a new concept here.

We are applying it to:

BCD digit organization.

  1. Reusing a Single-Digit BCD Adder

Once we have a module that correctly adds:

one BCD digit

we can reuse that module for every decimal position.

Conceptually:

BCD adder stage

×

number of decimal digits

For 100 digits:

100 BCD-adder stages

  1. Structural Scaling

Instead of manually writing:

BCD adder 0

BCD adder 1

BCD adder 2

...

BCD adder 99

the already-learned generate mechanism can structurally replicate the digit-adder stage.

The new concept here is NOT generate syntax.

The important architectural idea is:

ONE CORRECT DIGIT STAGE

↓

REPLICATE ACROSS ALL DECIMAL POSITIONS

  1. Carry Chain for 100 BCD Digits

For 100 BCD digit stages, we need to represent:

initial carry-in

plus:

carry between every neighboring stage

plus:

final carry-out.

A convenient carry vector therefore contains:

101 carry positions.

Conceptually:

C[0]

↓

stage 0

↓

C[1]

↓

stage 1

↓

C[2]

↓

...

stage 99

↓

C[100]

  1. Why 100 Stages Give 101 Carry Positions

Think about the boundaries.

For one stage:

carry before stage

+

carry after stage

Therefore:

2 carry positions.

For two stages:

C0

↓ stage 0

C1

↓ stage 1

C2

Therefore:

3 carry positions.

In general:

N stages

↓

N + 1 carry positions

So:

100 BCD stages

↓

101 carry positions

  1. 100-Digit BCD Adder Architecture

Conceptually:

A[3:0] + B[3:0] + C[0]

↓

BCD Stage 0

↓

SUM[3:0] + C[1]

A[7:4] + B[7:4] + C[1]

↓

BCD Stage 1

↓

SUM[7:4] + C[2]

...

A[399:396] + B[399:396] + C[99]

↓

BCD Stage 99

↓

SUM[399:396] + C[100]

This produces:

400-bit BCD result

+

final decimal carry-out

  1. Final Carry-Out of a Multi-Digit BCD Adder

Suppose every available decimal position has been used and the most-significant BCD stage produces another carry.

That final carry represents:

an additional most-significant decimal digit of 1.

For example:

99

+

1

=

100

If the circuit only contains two BCD result digits:

00

plus:

final carry = 1

Together they represent:

100

  1. Why BCD Arithmetic Is Not Ordinary Binary Arithmetic

BCD uses binary bits to encode decimal digits.

Therefore, the physical circuitry is binary digital logic.

But the representation rules are decimal-digit rules.

This is why:

ordinary binary addition

↓

may produce an invalid BCD digit

and:

BCD correction

↓

is required

  1. BCD Representation Has Unused Codes

A 4-bit field has:

16 possible bit patterns.

BCD uses only:

10.

Therefore:

6 patterns are unused for ordinary decimal digits.

Those unused patterns are:

1010

1011

1100

1101

1110

1111

This mismatch between:

16 binary combinations

and:

10 decimal digit values

is fundamental to understanding BCD correction.

  1. Correction Condition vs Correction Action

Keep these two ideas separate.

CORRECTION CONDITION:

Is the preliminary digit result greater than 9?

If YES:

correction is necessary.

CORRECTION ACTION:

Add:

6

to form the proper BCD digit and decimal carry representation.

  1. Preliminary Sum vs Final BCD Result

Do not confuse:

PRELIMINARY BINARY SUM

with:

FINAL BCD RESULT.

Example:

7 + 5

Preliminary binary sum:

01100

Decimal:

12

After BCD correction:

10010

Interpret as:

carry = 1

digit = 0010

The preliminary sum is an intermediate arithmetic value.

The corrected result follows BCD representation rules.

  1. Valid Inputs vs Intermediate Values

The input BCD digits should individually be valid:

0000 through 1001.

But their preliminary binary sum can naturally be:

10 through 19.

Therefore, seeing a temporary value corresponding to:

1010 through 10011

does not mean the addition itself failed.

It means:

correction may be required before producing the final BCD digit.

  1. Common Mistake: Treating the Entire Number as Ordinary Binary

Suppose the BCD number is:

0101 1001

This means:

decimal 59

NOT:

the ordinary binary value represented by the complete 8-bit pattern.

BCD must be interpreted:

4 bits at a time

because each nibble represents one decimal digit.

  1. Common Mistake: Assuming Every 4-Bit Pattern Is a Valid BCD Digit

Four bits can encode:

0 through 15

in ordinary binary.

But standard BCD only allows:

0 through 9

Therefore:

1010 through 1111

are invalid BCD digit codes.

  1. Common Mistake: Forgetting the Carry-In

For a multi-digit BCD adder, each stage generally adds:

digit A

+

digit B

+

carry from previous decimal digit

Ignoring the carry-in can produce incorrect results whenever the previous digit sum exceeds 9.

  1. Common Mistake: Adding 6 to Every BCD Sum

BCD correction is NOT applied unconditionally.

If the preliminary result is:

0 through 9

it is already a valid BCD digit.

Correction is required only when the preliminary result exceeds:

9

  1. Common Mistake: Thinking +6 Is an Arbitrary Rule

The correction value is connected to:

16 possible 4-bit binary combinations

versus:

10 valid decimal digit values.

The difference is:

6

Therefore, the correction is tied directly to the mismatch between binary radix-16 rollover and decimal radix-10 digit behavior.

  1. Common Mistake: Confusing BCD Carry With the Result Digit

For:

7 + 5 = 12

the BCD stage should produce:

digit = 2

carry = 1

The output digit itself should NOT contain:

12

because one BCD digit can represent only:

0 through 9

  1. Common Mistake: Forgetting Four Bits Per Decimal Digit

A decimal number containing:

N digits

requires:

4N bits

when stored as standard BCD.

Therefore:

100 decimal digits

require:

400 BCD bits.

  1. Common Mistake: Relearning Old Verilog Concepts

A large BCD adder may use:

generate loops

carry vectors

module instantiation

indexed part-selects

These mechanisms have already been learned.

Their presence in the BCD problem does NOT make them new concepts.

The new learning objective is:

BCD ARITHMETIC

+

MULTI-DIGIT BCD ARCHITECTURE

  1. Single-Digit vs Multi-Digit BCD Adder

SINGLE-DIGIT BCD ADDER

Inputs:

one BCD digit A

one BCD digit B

carry-in

Outputs:

one corrected BCD digit

carry-out

MULTI-DIGIT BCD ADDER

Uses:

multiple single-digit BCD stages

with:

carry-out from one stage

↓

carry-in to the next stage

  1. General BCD Addition Procedure

STEP 1

Add:

A digit + B digit + carry-in

STEP 2

Obtain the preliminary binary sum.

STEP 3

Check whether the result is greater than 9.

STEP 4

If the result is 0 through 9:

no correction.

STEP 5

If the result is greater than 9:

apply the BCD +6 correction.

STEP 6

Produce:

correct 4-bit BCD digit

+

decimal carry-out.

STEP 7

For a multi-digit number:

send the carry-out into the next decimal digit stage.

  1. General Multi-Digit Architecture

For N decimal digits:

Input A width:

4N bits

Input B width:

4N bits

Result digit width:

4N bits

Number of BCD digit-adder stages:

N

Convenient number of carry positions:

N + 1

Therefore:

100 decimal digits

↓

400-bit A

400-bit B

400-bit result

100 BCD-adder stages

101 carry positions

  1. Final Mental Model

Think about BCD like this:

DECIMAL NUMBER

↓

separate decimal digits

↓

each digit encoded using 4 bits

Valid BCD digit:

0000 through 1001

↓

decimal 0 through 9

Unused BCD patterns:

1010 through 1111

For BCD addition:

A digit

+

B digit

+

carry-in

↓

preliminary binary sum

If:

sum ≤ 9

↓

already valid BCD

If:

sum > 9

↓

BCD correction required

↓

add 6

Why 6?

4 binary bits

↓

16 combinations

Decimal digit

↓

10 valid values

16 - 10

=

6

After correction:

low 4 bits

↓

correct BCD result digit

carry

↓

next decimal position

For multiple digits:

least-significant BCD stage

↓ carry

next BCD stage

↓ carry

next BCD stage

↓

...

For 100 digits:

100 × 4

=

400 bits

and:

100 digit stages

↓

101 carry positions

The most important ideas are:

BCD MEANS BINARY-CODED DECIMAL.

EACH DECIMAL DIGIT IS ENCODED SEPARATELY USING FOUR BITS.

STANDARD BCD USES 0000 THROUGH 1001 FOR DECIMAL DIGITS 0 THROUGH 9.

1010 THROUGH 1111 ARE NOT VALID STANDARD BCD DIGIT CODES.

BCD IS NOT THE SAME AS ORDINARY BINARY REPRESENTATION OF THE COMPLETE NUMBER.

A SINGLE-DIGIT BCD ADDER FIRST COMPUTES A PRELIMINARY BINARY SUM.

THE MAXIMUM SINGLE-DIGIT BCD SUM WITH CARRY-IN IS 9 + 9 + 1 = 19.

IF THE PRELIMINARY RESULT IS 0 THROUGH 9, NO CORRECTION IS NEEDED.

IF THE PRELIMINARY RESULT IS GREATER THAN 9, BCD CORRECTION IS REQUIRED.

BCD CORRECTION ADDS 6.

THE +6 RULE COMES FROM THE DIFFERENCE BETWEEN 16 POSSIBLE 4-BIT COMBINATIONS AND 10 VALID DECIMAL DIGIT VALUES.

THE CORRECTED RESULT PRODUCES A 4-BIT BCD DIGIT AND A DECIMAL CARRY.

THE CARRY-OUT FROM ONE BCD DIGIT BECOMES THE CARRY-IN OF THE NEXT DECIMAL DIGIT.

MULTI-DIGIT BCD ADDITION IS BUILT BY REUSING THE SINGLE-DIGIT BCD ADDER ACROSS DECIMAL POSITIONS.

EACH BCD DIGIT REQUIRES FOUR BITS.

N BCD DIGITS REQUIRE 4N BITS.

100 BCD DIGITS REQUIRE 400 BITS.

100 BCD ADDER STAGES CAN BE ORGANIZED WITH 101 CARRY POSITIONS.

THE GENERATE LOOPS, CARRY VECTORS, AND INDEXED PART-SELECTS USED TO BUILD A LARGE BCD ADDER ARE PREVIOUSLY LEARNED TOOLS; THE NEW CONCEPT HERE IS HOW THEY ARE APPLIED TO BCD ARITHMETIC.