Full Adder modified to make Full Subtractor

  • Thread starter Thread starter mm391
  • Start date Start date
  • Tags Tags
    Adder
AI Thread Summary
To modify an 8-bit full adder into a full subtractor, an inverter should be placed at the carry-in input of the first full adder and on one input of each adder, specifically inverting bits A3, A2, A1, and A0 while leaving B3, B2, B1, and B0 unchanged. The carry input functions as a borrow, with the output carry indicating a potential negative flag. The operation for subtraction can be expressed as B - A = not A xor B + 2*(not A and B) + (1-C), where C is the carry input. XOR gates can be utilized to complement the B input bits based on the operation mode (add or subtract). This configuration allows the same adder circuit to perform both addition and subtraction efficiently.
mm391
Messages
65
Reaction score
0
If I was to make a modification to an 8 bit full adder to make it a an eight bit full subtractor would I put an inverter at the carry in input for the first full adder and then an inverter on one of each of the two inputs going into each adder. eg an inverter on A3, A2, A1, A0 and leave B3, B2, B1, B0 alone? (Where 0=add, 1=subtract).

Thanks for your help.

Matt
 
Engineering news on Phys.org
Let's see, if A and B are bit vectors A+B = A xor B + 2* A and B.
With a carry input you add it in: A+B w/C = A xor B + 2*A and B + Cin. Overflow in the 2nd addition is the carry output.

-A = not A +1, (two's complement)[edited]
B-A = Not A + B + 1 = not A xor B + 2* not A and B + 1
Invert A yes.

I'm not clear on the role of carry input for subtraction. It is a borrow, right? So it represents a -1 from the lower word and the output carry will represent a -2^4 to be borrowed from the higher bits or in the end a negative flag.

So yes I think you have it right: B - A w/C = not A xor B + 2*(not A and B) + (1-C)
1-C = not C since this is a 1-bit term.

(I'm working this out using bitwise boolean operations.)

It's been a while since I played with machine level arithmetic. What I suggest is that you work through, bit by bit a few examples and see if the result is as you expect.
 
jambaugh said:
Let's see, if A and B are bit vectors A+B = A xor B + 2* A and B.
With a carry input you add it in: A+B w/C = A xor B + 2*A and B + Cin. Overflow in the 2nd addition is the carry output.

-A = not A +1, (two's complement)[edited]
B-A = Not A + B + 1 = not A xor B + 2* not A and B + 1
Invert A yes.

I'm not clear on the role of carry input for subtraction. It is a borrow, right?

no, it's still a carry or "borrow-not".

it's simple. say you have a full adder, where the carry-out bit of one added bit goes into the carry-in bit if the added bit that is adjacent and more significant. for the LSB, the carry in is set to 0 for simple adding, and you set it to 1 for simple subtraction.

you can make the same adder work for adding and subtracting by putting XOR gates in front of the B input bits and the same line (called the "M" input in the diagram cited) that goes into the other input of the XOR gate (that when set to 1, it complements all of the bits going into the B input) that same line goes into the carry-in of the least significant bit to be that added "1" when doing the two's complement. so it's 0 for add and 1 for subtract.

there's a simple diagram at:

http://implement-logic.blogspot.com/2011/11/binary-parallel-addersubtractor.html

and to fill in the FA block, use:

http://en.wikipedia.org/wiki/File:Full_Adder.svg
 
Hi all I have some confusion about piezoelectrical sensors combination. If i have three acoustic piezoelectrical sensors (with same receive sensitivity in dB ref V/1uPa) placed at specific distance, these sensors receive acoustic signal from a sound source placed at far field distance (Plane Wave) and from broadside. I receive output of these sensors through individual preamplifiers, add them through hardware like summer circuit adder or in software after digitization and in this way got an...
I have recently moved into a new (rather ancient) house and had a few trips of my Residual Current breaker. I dug out my old Socket tester which tell me the three pins are correct. But then the Red warning light tells me my socket(s) fail the loop test. I never had this before but my last house had an overhead supply with no Earth from the company. The tester said "get this checked" and the man said the (high but not ridiculous) earth resistance was acceptable. I stuck a new copper earth...
Thread 'Electromagnet magnetic field issue'
Hi Guys We are a bunch a mechanical engineers trying to build a simple electromagnet. Our design is based on a very similar magnet. However, our version is about 10 times less magnetic and we are wondering why. Our coil has exactly same length, same number of layers and turns. What is possibly wrong? PIN and bracket are made of iron and are in electrical contact, exactly like the reference design. Any help will be appreciated. Thanks. edit: even same wire diameter and coil was wounded by a...

Similar threads

Back
Top