TEAHLAB NEW ADDITION
BUILD. SAVE. SHARE.
The world's first and only Integrated Simulator Community.

Four Bit Adder Subtractor

Interactive 4 bit adder-subtractor digital logic boolean circuit.
Click on the circuit to see its function.VHDL Program

Introduction

To be able to perform arithmetic, you must first be familiar with numbers. Therefore, although we give a few helping examples, this article is not about binary numerals.

The main interactive circuit at the top of this page is an arithmetic circuit capable of performing both addition and subtraction on any two 4-bit binary numbers. The circuit has a Mode switch that allows you to choose between adding (M=0) and subtracting (M=1). To understand why this circuit works, let’s review binary addition and binary subtraction. We use 4-bit numbers in the examples because the main interactive circuit is a 4-bit adder–subtractor.


Although our presentation focuses on a 4–bit adder–subtractor, the circuit can be extended to any arbitrary size by simply incorporating more XOR gates and full–adders.

Using the Adder–Subtractor

The following four tables show you how to use the adder-subtractor to perform different type of arithmetic operations. At the time of publication no similar breakdown exists in the literature. Hence, we advice that you pay attention to the distinctions.

Operation Note calculation
Unsigned addition Ignore the V-bit
A3A2A1A0
B3B2B1B0

CS3S2S1S0


Operation Note calculation
Signed addition
  • The addends A & B and the sum S are all 2’s complements.
  • Ignore C & V
A3A2A1A0
B3B2B1B0

S3S2S1S0


Operation Note calculation
Subtraction without overflow (V=0)
  • The minuend A, the subtrahend B, and the difference S are all 2’s complements.
  • Ignore C
A3A2A1A0
B3B2B1B0

S3S2S1S0


Operation Note calculation
Subtraction with overflow (V=1) The minuend A, the subtrahend B, and the difference S are all 2’s complements.
A3A2A1A0
B3B2B1B0

CS3S2S1S0


2’s Complement Table


Binary 2’s complement Binary 2’s complement
01111 +15 10000 -16
01110 +14 10001 -15
01101 +13 10010 -14
01100 +12 10011 -13
01011 +11 10100 -12
01010 +10 10101 -11
01001 +9 10110 -10
01000 +8 10111 -9
00111 +7 11000 -8
00110 +6 11001 -7
00101 +5 11010 -6
00100 +4 11011 -5
00011 +3 11100 -4
00010 +2 11101 -3
00001 +1 11110 -2
00000 +0 11111 -1


Teahlab on LinkedIn     Teahlab on Facebook