1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Comparator design using a 4-bit adder

  1. May 16, 2015 #1
    1. The problem statement, all variables and given/known data
    Hi, it's me again.
    Now I am going to design a 4-bit magnitude comparator using just ONE 4-bit adder and infinitely large number of gates (AND, OR, NOT, NAND, NOR, XOR, XNOR) for signed numbers (negative binary).

    a 4-bit magnitude comparator using 4-bit adder for signed values.png

    2. Relevant equations
    A > B => A3barB3 + A2barB2x3 + A1barB1x3x2 + A0barB0x3x2x1

    similar for A < B and A = B.
    3. The attempt at a solution
    a 4-bit magnitude comparator using 4-bit adder for signed values_attempts.png

    This is my attempt. Frankly, this is my first time encountering problems related to comparator design because this is never said to be in the syllabus of the course (introductory course). I find this in a past paper... seemingly indicating that the instructor wants us to divide and conquer it within the 3 hours of exam.

    I do this all by resources on the internet. So there may be a lot of mistakes.
  2. jcsd
  3. May 17, 2015 #2


    User Avatar
    Science Advisor

    I think you are on the right track, but I have some comments:
    • Where is the Cin coming from? You are only comparing two 4-bit numbers!
    • Are the numbers supposed to be in two's complement?
    And - there are only 16 combinations possible. I suggest making a truth table before continuing.
  4. May 17, 2015 #3
    I think it should be using 2's complement.
  5. May 17, 2015 #4


    User Avatar
    Science Advisor

    Then get busy on your truth table.
  6. May 17, 2015 #5
    A truth table looks like this? because I have never drawn a truth table for such a design...so I searched on google...

    Attached Files:

  7. May 17, 2015 #6
    I have a question about the XOR gates. Are those XOR gates for doing 2's complement (i am thinking in this way)?
    But I know that 2's complement is not just inverting 1 and 0, but also needs to add 1 after that. It seems that the above design cannot do that?
  8. May 17, 2015 #7
    And you mentioned that there should not be Cin? Does this mean there are no cascading inputs?
  9. May 17, 2015 #8


    User Avatar
    Science Advisor

    No. I meant the truth table for what you are trying to design. Since you are trying to compare two 4-bit 2's complement numbers, create a table with the A-numbers horizontally (-8 to +7) and the B-numbers vertically (-8 to +7). Now fill in the interior of the table with the result of the comparison you want (e. g. A>B). After you have done that, start thinking about how to implement it.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted