Table of contents
1.
Introduction
2.
Arithmetic Operations
3.
Decimal Arithmetic Unit 
3.1.
BCD Code
3.1.1.
BCD Addition
3.2.
BCD Adder
4.
FAQs
5.
Key Takeaways 
Last Updated: Mar 27, 2024

Decimal Arithmetic Unit and Operations

Author Alisha chhabra
2 upvotes
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

The user of a computer provides data with decimal numbers and receives results in a decimal form, but we know that the computer doesn’t understand the decimal language. It only understands the binary or machine or object code (0s and 1s). So, whatever the input a user provides to the computer is always converted into the computer understandable language, i.e., the machine language, and all the arithmetic operations like addition, subtraction, multiplication, and division are performed on the binary code. Moreover, to provide the result of the performed operations will be converted into the user-friendly language i.e, the decimal language. Not only the arithmetic operations, all the operations that a computer performs work on the machine language as it is the only understandable language for the computer systems. 

You can also read about - Shift Registers in Digital Electronics

In this article, we’ll be focusing on one of the arithmetic operations,i.e, Addition, and the Decimal Arithmetic Unit. 

Recommended Topic, Microinstruction in Computer Architecture

Arithmetic Operations

You must have heard of Arithmetic operations from your childhood. So, the four basic arithmetic operations are addition, subtraction, multiplication, and division. We can use these four operations to derive other operations also. The need for these arithmetic operations is to manipulate the data. Data is manipulated to produce the results required to solve computation problems. Computers, calculators, or other specialised digital systems that perform arithmetic operations directly in the decimal number system represent decimal numbers in the binary-coded form. 

There are basically two cases in the computer systems: When the I/O is small and the arithmetic calculations are relatively larger and vice versa. 

As we discussed, it is necessary to convert input decimal numbers to binary, perform all calculations with binary numbers, and convert results back to decimal to perform arithmetic operations on decimal data. This can be a good method for applications that require a lot of calculations but only a small amount of input and output data. 

When an application requires a large amount of input-output and a small number of arithmetic calculations, doing internal arithmetic directly with decimal numbers becomes appropriate. Decimal data must be stored in binary-coded form (BCD) on computers that can do decimal arithmetic. The decimal numbers are then fed into a decimal arithmetic unit, which can perform micro-operations in decimal numbers.

For example, Electronic calculators invariably employ internal decimal arithmetic units since inputs and outputs are frequent. There does not seem to be a reason for converting the keyboard input numbers to binary and again converting the displayed results to decimal, since this process requires special circuits and also it takes a longer time for the execution.

 

At the very least, we now know what the decimal arithmetic unit is and when it is used. It's now time to deep dive into it and how it operates: 

Also see, Instruction Format in Computer Architecture

Decimal Arithmetic Unit 

A decimal arithmetic unit is a digital function that performs decimal microoperations. It mainly performs two operations: Addition and Subtraction. 

The addition operation is performed with BCD Adder whereas Subtraction is performed with BCD Subtractor. Here, BCD stands for binary-coded decimal. Let’s briefly look at what BCD is. 

BCD Code

  • In this code, each decimal digit (0-9) is represented by a 4-bit binary number. For example, 374 is a decimal number whereas, 3, 7, and 4 are the decimal digits. Henceforth, by using BCD we can represent decimal digits by a 4-bit binary number. 
  • Positional weights are 8-4-2-1. And sometimes BCD is known as 8-4-2-1 code. 

Time for an example:

Decimal Digits 

  8  

4

2

1

Explanation

0

0

0

0

0

All 0’s 

1

0

0

0

1

LSB is 1

2

0

0

1

0

Self explanatory

3

0

0

1

1

2+1 = 3

4

0

1

0

0

Self explanatory

5

0

1

0

1

4+1 = 5

6

0

1

1

0

4+2 = 6

7

0

1

1

1

4+2+1 = 7

8

1

0

0

0

Self explanatory 

9

1

0

0

1

8+1 = 9

 

The above codes are valid BCD codes. Now we’ll look at the invalid BCD codes:

Since we are using 4-bits to represent the decimal digits, the total possibilities will be 2 = 16 and we are only representing (0-9), i.e10 out of 16 possibilities. So, what about the other ones? 

10 - 15 are considered invalid since they are not decimal digits rather decimal numbers. The don’t care terms(X) are used to represent invalid cases. 

Now, to convert the decimal numbers into BCD, we need to break out the decimal number. 

For example, to represent 10 in BCD, the BCD code for 1 and 0 will be concatenated. 

Thus, 

(10)10  = 00010000

Now, you must be wondering, are the BCD and binary the same? The answer is NO. 

Let’s understand with an example: 

Let’s convert a decimal number 15 in binary as well as in BCD. 

(15)10  = (1111)2 in binary

(15)10  = (00010101) in BCD

So far we’ve understood the BCD or 8-4-2-1 code, let us now look at the BCD addition: 

BCD Addition

BCD addition is a replica of the binary addition. In BCD addition, we’ve to deal with three cases which are:

Sum <= 9, final carry = 0, the obtained result is correct. 

Sum <= 9, final carry = 1, the obtained result is incorrect. To correct the answer, we just need to add 6(or 0110) to the obtained result

Sum >9, final carry = 0, again the result obtained is incorrect. To correct the answer the same will be followed, i.e, the addition of 6( or 0110) to the result.

Let’s see some examples: 

  • (2)+ (6)2  #BCD Addition 
  • (3)10 + (7)10

As discussed above by adding 6 we can obtain the correct result. Now the question may arise why 6 only? 

We know that we use the 4-bit binary number to represent the decimal digits which are from (0-9). Also, we know that with 4-bit there can be 16 (0-15) possibilities. But the valid cases are only from (0-9), by this, we can calculate the invalid cases, i.e, 15 - 9 = 6 

To correct the above answer, let’s add 6  to the sum.

(10)10 = 0001 0000

Now lets us discuss the BCD adder by which we can perform the addition operation on decimal numbers: 

BCD Adder

The digital system handles the decimal number in the form of binary-coded decimal numbers (BCD). A BCD Adder Circuit adds two BCD digits and returns a BCD sum digit. BCD numbers use digits, ranging from 0 to 9, which are represented in binary as 0000 to 1001, i.e. each BCD digit is a 4-bit binary number.

The maximum value of output will be 19 (i.e. 9(1001)+9(1001)+1(carry =1) = 19).

Here, we will only be obtaining the binary addition of the two numbers. To convert them into the BCD form by using the BCD adder. 

As a result, in order to build a BCD Adder Circuit, we'll need:

  • 4-bit binary adder for initial addition
  • Logic circuit to detect sum greater than 9 and
  • One more 4-bit adder to add 0110(6) in the sum if the sum is greater than 9 or carry is 1.

The only correction is needed in the second half of the table. 

Let’s understand why? 

The minimum sum we can obtain from the 4-bit adder is zero(0000 with k(final carry) = 0) and the maximum sum is 19 (0011 with k = 1).

  • The table shows that when the 'Binary Sum' has an output carry K=1, a correction is required.

First condition = K(output carry) =1, which covers the numbers from 16 to 19.   

  • The remaining six combinations numbered 10 to 15, require correction, with the bit on the Z8 position set to 1. If we closely look at table two unrequired cases ( 8 and 9 ) will also be covered. To overcome this, we can check for the other bits. Herewith Z8, Z4 values are also 1’s. 

Second condition = Z8Z= 1, which covers the numbers from 12 to 15. 

  • The leftover will be covered by considering the Zand Z2 bits. 

Third condition = Z8Z2 = 1, which covers the numbers 10 and 11. 

To conclude:

C=K+Z8.Z4+Z8.Z2 will be the boolean expression for the adder circuit. 

Henceforth, we are adding “0110” (=6) only to the second half of the table.

We can also make use of the K-map to find the boolean expression: 

The conditions are:

If K = 1 (Satisfies 16-19)

If Z8.Z4 = 1 (Satisfies 12-15)

If Z8.Z2 = 1 (Satisfies 10 and 11)

Let’s now build the circuit for the same: 

In the above diagram, 

  • We'll use a 4-bit Binary-Adder as an example, which accepts addend and augend bits as input and has a 'Carry in' input carry.
  • The Binary-Adder generates five outputs: Z8, Z4, Z2, Z1, and a carry K output.
  • The logical circuit is designed to identify the Cout using the output carry K and Z8, Z4, Z2, Z1 outputs.
  • The binary adder's Z8, Z4, Z2, and Z1 outputs are fed into the 2nd 4-bit binary adder as an Augend.
  • The addend bit of the 2nd 4-bit binary adder is designed in such a way that the 1st and the 4th bit of the addend number are 0 and the 2nd and the 3rd bit are the same as Cout. When the value of Cout is 0, the addend number will be 0000, which generates the same result as the 1st 4-bit binary number. But when the value of the Cout is 1, the addend bit will be 0110(6) which adds with the augend to get the valid BCD number.

Time for an example,

1001 + 1001 

Step 1: Add both the numbers using a 4-bit binary adder and the input carry Cin = 0. 

Step 2: The binary adder produces the result 0010 and the output carry as 1(k=1). 

Step 3: Then, using the expression Cout=K+Z8.Z4+Z8.Z2, find the Cout value to determine whether the produced BCD is invalid or valid.

K = 1

Z8 = 0

Z4 = 0

Z2 = 1

Cout = 1+0*0+0*1

Cout = 1+0+0

Cout = 1

Step 4: The value of Cout is 1, which expresses that the produced BCD code is invalid. Then, add the output of the 1st 4-bit binary adder with 0110(6).

= 0010+0110

= 1000

The BCD is represented by the carry output as:

BCD=Cout Z8 Z4 Z2 Z1=1 1 0 0 0 (19). 

Must read decimal to binary c++ 
Check this out: Device Manager in Computer

FAQs

  1. What are don’t care terms?
    In a multi-valued logic system, "don't care" can refer to an unknown value, which is referred to as an X value or "don't know."
     
  2. What is 8-4-2-1 code in computer science?
    A weighted 8421 BCD code is a standard binary-coded decimal code in which the weights of the different bits are represented by 8, 4, 2, and 1, starting with the most significant bit (MSB) and progressing to the least significant bit (LSB).
     
  3. What is the use of K-map in digital electronics?
    A Karnaugh map (K-map) is a pictorial method for minimizing Boolean expressions that do not require the use of Boolean algebra theorems or equation manipulations. 
     
  4. Why does a computer use a binary number system rather than a decimal number system?
    Voltages are used by computers, and because voltages change frequently, no specific voltage is set for each decimal number. As a result, binary is measured as a two-state system, meaning it is either on or off. Computers also use the binary number system to simplify calculations and convert to binary online.
     
  5. In terms of efficiency, which is the efficient one BCD or binary? 
    It's worth noting that the BCD is nothing more than a binary representation of each decimal digit. The fact that the BCD representation of the given decimal number uses extra bits, makes it heavy-weighted.

Key Takeaways 

In this article, we’ve explored the Decimal Arithmetic Unit along with the BCD Addition. We’ve also looked at some fancy terms which might be tricky to understand in one go, thus, it is recommended to revise the article and the respected concepts. 

To learn more about Micro Operations, refer to Arithmetic Micro Operations.

We hope that this blog has helped you enhance your knowledge regarding the Decimal Arithmetic unit and if you would like to learn more, check out our more wonderful articles. Do upvote our blog to help other ninjas grow. 

Happy Learning Ninja!

Live masterclass