How Does an Adder/Subtractor Unit Handle Negative Inputs?

  • Thread starter Thread starter ECE
  • Start date Start date
  • Tags Tags
    Adder Unit
AI Thread Summary
In an Adder/Subtractor unit, when adding two 4-bit numbers, the add/subtract signal is XORed with the second input (Y) to determine whether to add or subtract. To handle negative inputs, such as -5 and -3, the bit pattern for -5 (1011) is used, and the number to be subtracted (3) is complemented (1100) before being added. Additionally, a carry-in of 1 is included to account for the two's complement operation. The final calculation results in -8, as the carry-out falls off the edge. This method effectively allows the unit to process negative inputs correctly.
ECE
Messages
7
Reaction score
0
If two 4 bit numbers are being added in the Adder/Subtractor unit e.g. X and Y. Then according to my textbook it is written that the Add/Sub Unit is built in a way that the add/sub signal (which chooses whether to add/subtract) is XOR with Y (the position where the number that is to be complemented is entered). But what if the user wants to enters { -5-3 }.How will the add/sub unit work then? Should the X input be also XOR with another signal similar to add/sub?

-Thanks
 
Engineering news on Phys.org
ECE said:
If two 4 bit numbers are being added in the Adder/Subtractor unit e.g. X and Y. Then according to my textbook it is written that the Add/Sub Unit is built in a way that the add/sub signal (which chooses whether to add/subtract) is XOR with Y (the position where the number that is to be complemented is entered).

but you must also add 1 to the inverted bits. you do that with this adder/subtractor by coupling in the same 1 that goes to the XORs (the add/subtract signal where add=0 and subtract=1) to the carry-in of the LSB (which is tied to 0 if you're adding).

But what if the user wants to enters { -5-3 }.How will the add/sub unit work then? Should the X input be also XOR with another signal similar to add/sub?

no, just put in for A the bit pattern for -5, which is the same bit pattern for an unsigned 4-bit number that is 16-5 or 11. so -5 is 1011 and you subtact 3 (0011) which gets complimented to 1100 and goes into your full-adder, but then you got to remember to couple in the 1 into the carry-in of the LSB (which effectively adds 1).

1011 + 1100 + 0001 = [1]1000

or -8 since the 1 that carries out falls off the edge.
 
Thread 'Weird near-field phenomenon I get in my EM simulation'
I recently made a basic simulation of wire antennas and I am not sure if the near field in my simulation is modeled correctly. One of the things that worry me is the fact that sometimes I see in my simulation "movements" in the near field that seems to be faster than the speed of wave propagation I defined (the speed of light in the simulation). Specifically I see "nodes" of low amplitude in the E field that are quickly "emitted" from the antenna and then slow down as they approach the far...
Hello dear reader, a brief introduction: Some 4 years ago someone started developing health related issues, apparently due to exposure to RF & ELF related frequencies and/or fields (Magnetic). This is currently becoming known as EHS. (Electromagnetic hypersensitivity is a claimed sensitivity to electromagnetic fields, to which adverse symptoms are attributed.) She experiences a deep burning sensation throughout her entire body, leaving her in pain and exhausted after a pulse has occurred...

Similar threads

Back
Top