full subtractor question

Thread Starter

Nadav Reichler

Joined Apr 4, 2017
10
I'm not sure even where to start with this:

regarding the attached circuit A=a1a2a3a4 B=b1b2b3b4 represented in 2complement.
the F.S commits b-a.
what S=s1s2s3s4s5 as a function of the original numbers A,B?
 

Attachments

WBahn

Joined Mar 31, 2012
29,930
When you say A = a1a2a3a4, what value is represented if

a1 = 1
a2 = 0
a3 = 1
a4 = 0

What is your most significant bit?

What is your least significant bit?

What is going on with s0 and the signals going into the right-most FS block?

Why is b2 (presumably) hardcoded to 0.

If these blocks are full subtractors, why is there a need to invert the a[] signals and bring a 1 into the right most Bin input?

What is the functional definition of a full subtractor?
 

Thread Starter

Nadav Reichler

Joined Apr 4, 2017
10
a4 MSB a1 LSB , sorry I should have written it reversed, got confused myself.
I think the 0 and 1 in the rightmost F.S are actually the LSB of and A and B,

and about b2 I'm not sure, it's just given data I think that b2 is 0, there is nothing clearer given about this in the question.

"If these blocks are full subtractors, why is there a need to invert the a[] signals and bring a 1 into the right most Bin input?"

I think this is because A and B are in two's complement. I didn't realise this is supposed to invert the a[] but I suppose this means A is negative. If the question is why not use a full adder then, I believe it's for practicing the F.S, no real reason.
 

WBahn

Joined Mar 31, 2012
29,930
If A and B are in two complement, then sending them into a binary adder implements A+B, which sending (~A + 1) implements -A, meaning that a binary adder will result in A + (-B) = A-B.

If you use a binary subtractor instead and you want A-B, then you need to send A and B into it directly because a subtractor subtracts one input from the other (and since subtraction matters, they are not commutative, so order matters) yielding B-A naturally.

A is either negative or positive, but you don't know which and the circuit (particularly as shown) can't be predicated on it being one or the other specifically -- it must work properly regardless of the actual value represented by the current state of the signal lines that make up the value A.

I agree that the exercise is for practicing with the full-subtractor circuit, but that just underscores the need to work from the functional definition of a what a full-subtractor does and how you cascade them to achieve subtraction on multi-bit values and whether or not you can play the same (or similar) game with one of the inputs in order to get the circuit to produce B+A instead of B-A.
 

Eshawn

Joined Oct 5, 2019
31
If A and B are in two complement, then sending them into a binary adder implements A+B, which sending (~A + 1) implements -A, meaning that a binary adder will result in A + (-B) = A-B.

If you use a binary subtractor instead and you want A-B, then you need to send A and B into it directly because a subtractor subtracts one input from the other (and since subtraction matters, they are not commutative, so order matters) yielding B-A naturally.

A is either negative or positive, but you don't know which and the circuit (particularly as shown) can't be predicated on it being one or the other specifically -- it must work properly regardless of the actual value represented by the current state of the signal lines that make up the value A.

I agree that the exercise is for practicing with the full-subtractor circuit, but that just underscores the need to work from the functional definition of a what a full-subtractor does and how you cascade them to achieve subtraction on multi-bit values and whether or not you can play the same (or similar) game with one of the inputs in order to get the circuit to produce B+A instead of B-A.
Hello:
I know this is an old conversation but I am just realizing this writing which creates doubts about my understandings about binary subtraction using binary adders: the writhing includes: “If A and B are in two complement, then sending them into a binary adder implements A+B, which sending (~A + 1) implements -A, meaning that a binary adder will result in A + (-B) = A-B.” I was expecting to read B-A as we are getting the negative of A from its one’s complement. Is this a simple mistake in the writing (that the B-A should be in fact A-B) or the A-B is correct in the quoted paragraph and have I misunderstood binary subtraction?
thank you
 

Papabravo

Joined Feb 24, 2006
21,094
There are two things going on here:
  1. The abstract definition of subtraction, which is not really in doubt
  2. The implementation of subtraction in a particular CPU
As long as you understand the result and they are consistent and predictable, there is no problem.

There are some other abstract statements which are manifestly true:
  1. A binary adder will perform subtraction is you 2's complement one of the operands. You get either A-B or -A+B depending on which one you complement
  2. A binary subtractor will perform addition if you complement the subtrahend.
 

Eshawn

Joined Oct 5, 2019
31
Thank you for your comment. Could you answer the following please?

If I use two cascaded 74hc283, and set the carry-in of the first 4bits 74hc283 to logic high, to subtract 8 bits binary number B from 8 bits binary number A, should I invert the the a[] input or should I invert the b[] input for implementation of the A-B to get the §[] result in the circuit?
thanks
 

Papabravo

Joined Feb 24, 2006
21,094
The 74HC283 is an adder. To subtract B from A you take the 2's complement of B and add it to A with the Carry In set to 0. That is not the only way to do it however. Because the 2's complement of B is equal to the 1's complement of B plus 1, you can also subtract B from A by inverting the bits of B to form the 1's complement and setting the Carry In to 1. That will add three things together: A, the 1's complement of B, and the Carry In of 1, giving A-B as the result.
 

Eshawn

Joined Oct 5, 2019
31
I had already inverted the input b[] but I will try to find out why I get wrong results at output s[] of the subtractor.
Thank you again.
 

Papabravo

Joined Feb 24, 2006
21,094
I had already inverted the input b[] but I will try to find out why I get wrong results at output s[] of the subtractor.
Thank you again.
What are your test case values that lead you to conclude there is a problem. There are many possible problems in cascading two parts. How about a schematic of what you have?
Here is a "Full Adder Test Jig" I whipped up to show how you can subtract every positive value from 0 to make a down counter. Also how to make a handy DAC to test digital circuits in an analog simulator without a logic analyzer.
 

Attachments

Last edited:

Eshawn

Joined Oct 5, 2019
31
Thank you for your reponse and for the schematic you included. Also, I am sorry that I was unable to come back to this thread sooner.
The problem was that the wire that cascaded the two counters was broken in a very subtle way and was confusing. i may have other questions that I will post as new thread in the future.
 
Top