Aimld23 Dlca Ex

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

Date of Performance : 08 September 2021

Roll No : AIMLD23_kumawat Rahul Devendra

Aim : Study of logic gates.

Software : Roll app

Screen Shots in PDF format :

Result (in terms of truth table) :

AND gate truth table OR gate truth table NOT gate truth table
A B Q A B Q A Q
0 0 0 0 0 0 0 1
0 1 0 0 1 1 1 0
1 0 0 1 0 1 Boolean Expression Q = NOT
A or A
1 1 1 1 1 1
Read as inversion of A gives Q
Boolean Expression Q = A.B Boolean Expression Q = A+B
Read as A AND B gives Q Read as A OR B gives Q
Conclusion :

This is how we can verify the truth table and the Boolean
Date of Performance : 15 September 2021,

Roll No : AIMLD23_kumawat Rahul Devendra

Aim : Verification of NAND gate as Universal gate and Design a NAND Logic

Circuit that is equivalent to the AOI circuit shown below.

Software : Roll app

Screen Shots in PDF format :

Result (in terms of truth table) :

Conclusion :

This is how we can verify the NND gate as a Universal gate


Date of Performance : 15 September 2021,

Roll No : AIMLD23_kumawat Rahul Devendra

Aim : Verification of NOR gate as Universal gate and Design a NOR Logic Circuit

that is equivalent to the AOI circuit shown below..

Software : Roll app

Screen Shots in PDF format :

Result (in terms of truth table) :

Conclusion :

This is how we can verify the NOR gate as a Universal gate


Date of Performance : 26 November 2021

Roll No : AIMLD23_kumawat Rahul Devendra

Aim : Study of Binary to Gray code converter and Gray to Binary.Software : Roll app

Screen Shots in PDF format :

Result (in terms of truth table) :

Binary to gray code

Binary Code Gray Code Binary Code Gray Code

0 0000 0000 8 1000 1100

1 0001 0001 9 1001 1101

2 0010 0011 10 1010 1111

3 0011 0010 11 1011 1110

4 0100 0110 12 1100 1010

5 0101 0111 13 1101 1011

6 0110 0101 14 1110 1001

7 0111 0100 15 1111 1000


Gray code to binary

Decimal Number Gray Code Binary Code

0 0000 0000

1 0001 0001

2 0010 0010

3 0011 0011

4 0110 0100

5 0111 0101

6 0101 0110

7 0100 0111

8 1100 1000

9 1101 1001

10 1111 1010

11 1110 1011

12 1010 1100

13 1011 1101

14 1001 1110

15 1000 1111

Conclusion:

That’s how we con convert gray code to binary and binary to gray code
Date of Performance : 12 October 2021

Roll No : AIMLD23_kumawat Rahul Devendra

Aim : Study of Half and Full adder.

Software : Roll app

Screen Shots in PDF format :

Half adder by Nand gate

Full Adder
Result (in terms of truth table) :
Half Adder Truth Table

A B A+B Decimal Output Binary Output Sum (A ⊕ B) Carry (A ⋅ B)

0 0 0+0 0 0 0 0

0 1 0+1 1 1 1 0

1 0 1+0 1 1 1 0

1 1 1+1 2 10 0 1

Full adder Truth Table

Conclusion:

That’s how we can draw the half adder and full adder.
Date of Performance : 15 November 2021

Roll No : AIMLD23_kumawat Rahul Devendra

Aim : Study of Half and Full subtractor.

Software : Roll app

Screen Shots in PDF format :

Result (in terms of truth table) :

Half subtractor
Full Subtractor

Conclusion:

That’s how we can draw the half subtractor and full subtractor.
Date of Performance : 22 November 2021

Roll No : AIMLD23_kumawat Rahul Devendra

Aim : Implementation of Booth Algorithm for Binary multiplication..

Software : Roll app

Screen Shots in PDF format :

#include <stdio.h>

#include <math.h>

#define BIT 4

void d_b(int dec_s, int bin[BIT]) //function to convert decimal(int type) to binary(array type)

int carry, dec, i;

carry = 0;

dec = dec_s > 0 ? dec_s : -dec_s; //checking if decimal is +ve or -ve

for (i = 0; i < BIT; i++)

bin[i] = (dec % 2); //store the remainder

dec /= 2; //reduce the number by a factor of 2

if (dec_s >= 0)

return;

else

for (int j = 0; j < BIT; j++)


{

bin[j] = bin[j] == 0 ? 1 : 0; //complementing the bits if decimal is found to be less than zero

if (bin[0] + 1 <= 1)

bin[0] += 1;

return;

else

carry = 1; //if bit additon exceeds 1 then carry is generated

for (int i=0;i<BIT;i++)

if (bin[i] + carry <= 1)

bin[i] += carry;

carry = 0;

return;

else

bin[i] = (bin[i] + carry) % 2;

}
}

int b_d(int a[BIT], int q[BIT]) //binary to decimal conversion

int i = 0;

int ans = 0;

for (; i < BIT; i++)

ans += q[i] * pow(2, i);

for (int k = 0; k < BIT; k++, i++)

ans += a[k] * pow(2, i);

return ans;

void twos(int m[BIT], int m2[BIT]) //calculating 2's complement

for (int i = 0; i < BIT; i++)

m2[i] = m[i] == 0 ? 1 : 0; //calculating 1's complement

int carry = 1; //adding 1 to the above result

for (int i = 0; i < BIT; i++)

if (m2[i] + carry <= 1)

m2[i] += carry;
carry = 0;

return;

else

m2[i] = (m2[i] + carry) % 2; //if result exceeds 1 then take the remainder

int add(int a[BIT], int m[BIT])

int carry = 0;

for (int i = 0; i < BIT; i++)

carry += m[i];

if (a[i] + carry <= 1)

a[i] += carry;

carry = 0;

else

a[i] = (a[i] + carry) % 2;

carry = 1;

return carry;
}

int ashr(int a[BIT], int q[BIT], int q_1) //performing ASR b/w A Q and Q-1

q_1 = q[0];

for (int i = 1; i < BIT; i++)

q[i - 1] = q[i];

q[BIT - 1] = a[0];

for (int i = 1; i < BIT; i++)

a[i - 1] = a[i];

return q_1;

int main() // main function to set the flow of the program

int multiplicand, multiplier, q_1, count;

printf(" Enter the multiplicand: ");

scanf("%d", &multiplicand);

printf(" Enter the multiplier: ");

scanf("%d", &multiplier);

q_1 = 0;

int a[BIT] = {0};

int m[BIT] = {0};

int m2[BIT] = {0};

int q[BIT] = {0};


count = BIT;

d_b(multiplicand, m); //converting user input into the binary equivalent

d_b(multiplier,q);

twos(m, m2);

printf("\n Entered Multiplicand: ");

for (int k = BIT - 1; k >= 0; k--)

printf(" %d", m[k]);

printf("\n Entered Multiplier: ");

for (int k = BIT - 1; k >= 0; k--)

printf(" %d", q[k]);

printf("\n\n\t\tA\t Q\t\tQ-1\tOPERATION");

int a1 = 1;

for (int i = count; i != 0; i--)

printf("\n LOOP NO:%d ", a1);

a1++;

for (int k = BIT - 1; k >= 0; k--)

printf(" %d", a[k]);

printf("\t");

for (int k = BIT - 1; k >= 0; k--)

{
printf(" %d", q[k]);

printf("\t %d", q_1);

if (q[0] == 1 && q_1 == 0)

add(a, m2);

printf("\n ");

for (int k = BIT - 1; k >= 0; k--)

printf(" %d", a[k]);

printf("\t");

for (int k = BIT - 1; k >= 0; k--)

printf(" %d", q[k]);

printf("\t %d\t ADD M", q_1);

else if (q[0] == 0 && q_1 == 1)

add(a, m);

printf("\n ");

for (int k = BIT - 1; k >= 0; k--)

printf(" %d", a[k]);

printf("\t");
for (int k = BIT - 1; k >= 0; k--)

printf(" %d", q[k]);

printf("\t %d\t SUB M", q_1);

q_1 = ashr(a, q, q_1);

printf("\n ");

for (int k = BIT - 1; k >= 0; k--)

printf(" %d", a[k]);

printf("\t");

for (int k = BIT - 1; k >= 0; k--)

printf(" %d", q[k]);

printf("\t %d\t ASHR", q_1);

printf("\n\nFINAL RESULT: \n");

printf("\n The answer in binary form is:");

for (int k = BIT - 1; k >= 0; k--)

printf(" %d", a[k]);

for (int k = BIT - 1; k >= 0; k--)

{
printf(" %d", q[k]);

int sign = a[BIT - 1];

if (sign)

for (int k = BIT - 1; k >= 0; k--)

a[k] = a[k] == 1 ? 0 : 1;

q[k] = q[k] == 1 ? 0 : 1;

int one[BIT] = {0};

one[0] = 1;

int carry = 0;

carry = add(q, one);

if (carry)

carry = add(a, one);

int ans = b_d(a, q);

printf("\n The answer in decimal form is: ");

if (sign)

printf("-");

printf("%d \n", ans);

Result (in terms of truth table) :


Conclusion:

That’s how we can implement the concept of booth algorithm in computer

You might also like