Monday 2 December 2019

digital logic - Subtraction using adder circuit


I need some really basic help here. Can I use a 4bit adder chip as a subtracter by using the 2's complement for the number to be subtracted?



Answer



In 2's complement, negation can be achieved by inverting a number and adding one (ie -A = ~A + 1). To subtract a number B from A, invert B, add 1 to it, then proceed to add that sum to A.


A - B = A + ~B + 1

In order to transform a normal adder IC into a subtractor, you need to invert the second operand (B) and add 1 (by setting Cin = 1 ). An Adder subtractor can be achieved by using the following circuitry.


enter image description here



Note that when the control signal SUB is low,


A = A
B = B
Cin = 0

Therefore, the computed sum will be A + B + SUB = A + B.


But if SUB = 1


A = A
B = ~B
Cin = 1


Meaning the computed sum will now be A + ~B + SUB = A + ~B + 1 = A - B, hence achieving subtraction.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...