I have two numbers both with four bits (a3 to a0 and b3 to b0 reading from left to right) and I would like to find out if a is bigger than b. I have drawn a solution of mine and a short mathematical explanation of it, it would be amazing if somebody can tell me if this is correct. So my idea is to to use full adders (which are named VA), where I have a, b and the carry from before as inputs. The carry from the current adder and q_{i} are outputs of it. I negate all of my bits of b,setting C0 to one to add one so I have a two's complement and than I add both numbers. One of my sources say's, that a>b when sign=0 and z=0. Z is 1 when all q_{i} are zero. And sign means (concerning my sources), that q3 is zero. So in the end I came up combining it like the way I did on the photo.
\$\begingroup\$
\$\endgroup\$
7
-
\$\begingroup\$ Negating all of your bits is not two complement. \$\endgroup\$– DonFusiliCommented Sep 5, 2018 at 8:02
-
2\$\begingroup\$ @DonFusil note C0 = 1. He is achieving twos complement by inverting and adding one although this is not explained. \$\endgroup\$– RoyCCommented Sep 5, 2018 at 9:07
-
\$\begingroup\$ @RoyC Ah, that'll teach me to assume the text and diagram explain and show the same, my bad. \$\endgroup\$– DonFusiliCommented Sep 5, 2018 at 9:16
-
\$\begingroup\$ @RoyC Thanks for saying this, sorry I forgot to talk about this. Is that the correct twos complement then? \$\endgroup\$– HemmeligCommented Sep 5, 2018 at 9:23
-
\$\begingroup\$ Yes that is good. \$\endgroup\$– RoyCCommented Sep 5, 2018 at 9:24
|
Show 2 more comments
2 Answers
\$\begingroup\$
\$\endgroup\$
2
The fundamental error with this and why you are not using c3 is that you need to represent the twos complement input and output with the range 15 to -15 as a five bit quantity. This means that c3 is q4 of the output and the sign bit.
-
\$\begingroup\$ So do you mean the function would be correct, if I would put q3 to OR as well and move the current q3 to the carry with c3? \$\endgroup\$– HemmeligCommented Sep 5, 2018 at 9:24
-
2
-
\$\begingroup\$ @RoyC I agree with you, I am so sorry. I will add the links where I got those circuits. Take it as an example, unfortunatelly the bad one. \$\endgroup\$ Commented Sep 5, 2018 at 15:43
-
\$\begingroup\$ @RoyC I did change the exaple with better one. \$\endgroup\$ Commented Sep 5, 2018 at 15:47