Question

First you must create a logic circuit using only basic gates such as AND, OR, NOR,...

First you must create a logic circuit using only basic gates such as AND, OR, NOR, NAND, NOT, etc. to implement an ADDER capable of adding two 4 bit binary numbers.

Second you must create a logic circuit using only basic gates such as AND, OR, NOR, NAND, NOT, etc. to implement a Subtractor that is capable of subtracting the second number from the first, by converting the second number into its 2's complement form and then adding the resulting number to the first number. You do not need to worry about accomodating the addition or subtraction of negative numbers as part of your assignment.

Finally, for the third part of the assignment you must create a limited ALU (Arithmetic logic unit) circuit using Logism that implements a Full Adder circuit capable of adding 2 – 4 bit binary numbers and subtracting 2- 4 bit binary numbers. You must also implement the ability to select a bitwise AND operation and a bitwise OR operation. For the ALU it is acceptable to use the Adder and Subtractor circuits that are listed under the "Arithmetic" folder in Logism. Please check the video lecture on Logism tips and tricks to learn how to use multi bit pins, and how to set up different gates to support more than 1 bit.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

//function for Binary Addition

int AdditionofBinary(int a,int b)

{

      int c; //carry

      while (b != 0) {

              //find carry and shift it left

              c = (a & b) << 1;

              //find the sum

              a=a^b;

              b=c;

      }

      return a;

}

//function for Binary Subtraction

int SubtrationofBinary(int a, int b)

{

      int carry;

      //get 2's compliment of b and add in a

      b = AdditionofBinary(~b, 1);

      while (b != 0) {

              //find carry and shift it left   

              carry = (a & b) << 1;

              //find the sum

              a = a ^ b;

              b = carry;

      }

      return a;

}

int main()

{

    int number1,number2, binAdd, binSub;

    printf("Input first integer value: ");

    scanf("%d",&number1);

  

    printf("Input second integer value: ");

    scanf("%d",&number2);

    binAdd=AdditionofBinary(number1,number2);

    binSub=SubtrationofBinary(number1,number2);

    printf("Binary Addition: %d\n",binAdd);

    printf("Binary Subtraction: %d\n",binSub);

    return 0;

}

Add a comment
Know the answer?
Add Answer to:
First you must create a logic circuit using only basic gates such as AND, OR, NOR,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT