0% found this document useful (0 votes)
13 views5 pages

DLCD PBL

Uploaded by

ALL STARS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

DLCD PBL

Uploaded by

ALL STARS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Project Report

On
4-bit
Binary Adder

Submitted to: Submitted by:


Mr. Arvind sir Anurag Dubey(IT-1)
(01011503123)
AIM:
Design a 4-bit Binary Adder: Create a digital circuit that can add two 4-bit
binary numbers and output the sum and carry.

THEORY:
A binary adder is a digital circuit that performs the addition of binary
numbers. Binary adders are fundamental components in computer
arithmetic and are commonly used in processors, memory units, and digital
systems to perform arithmetic operations.

How a 4-bit Binary Adder Works:

When adding two 4-bit numbers (e.g., A3 A2 A1 A0 and B3 B2 B1


B0):

 Least Significant Bit (LSB): The first full adder adds A0 and B0
and any carry-in (which is 0 initially).
 The carry-out from the first addition is fed as a carry-in to the next
full adder, which adds A1 and B1.
 This process continues until the most significant bit (MSB) addition
(A3 and B3), and any final carry-out is an indication of an overflow.

A 4-bit binary adder is used in a variety of digital systems and


applications, especially where binary arithmetic is required. Here are some
key applications:

 Arithmetic Logic Units (ALUs)


 Digital Counters
 Digital Signal Processing (DSP)
 Binary Multipliers
SOURCE CODE:
#include <iostream>
using namespace std;

void fullAdder(int a, int b, int carry_in, int &sum, int &carry_out)


{
sum = a ^ b ^ carry_in;
carry_out = (a & b) | (b & carry_in) | (a & carry_in);
}

void add4BitBinary(int A[4], int B[4], int sum[4], int &carry_out)


{
int carry_in = 0;
for (int i = 0; i < 4; ++i) {
fullAdder(A[i], B[i], carry_in, sum[i], carry_out);
carry_in = carry_out;
}
carry_out = carry_in;
}

int main() {
int A[4], B[4], sum[4], carry_out = 0;

cout << "Enter 4 bits of binary number A (MSB first): ";


for (int i = 0; i < 4; ++i) {
cin >> A[3 - i];
}
cout << "Enter 4 bits of binary number B (MSB first): ";
for (int i = 0; i < 4; ++i) {
cin >> B[3 - i];
}

add4BitBinary(A, B, sum, carry_out);

cout << "Sum: ";


for (int i = 3; i >= 0; --i) {
cout << sum[i];
}
cout << "\nCarry out: " << carry_out << endl;

return 0;
}

OUTPUT:

You might also like