How do you subtract a constant using only an adder?

Discussion in 'Homework Help' started by katevable, Oct 23, 2015.

  1. katevable

    Thread Starter New Member

    Oct 23, 2015
    7
    0
    I need to build a Logisim circuit in which I only have two inputs (two 8-bit immediates), an adder, and as many constants, inverters, and spitters as I need. I have 2 MUXs available to me and an Opcode that specifies the output. When the opcode is 00 or 10, I need A-1 and A-B as an output, respectively.

    How do I do this with only an adder? That is, how do I subtract 1 from A and how do I subtract B from A with only an adder?
     
  2. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,678
    2,737
    Can you think of a way to redefine C=A-B as an addition problem?
     
  3. katevable

    Thread Starter New Member

    Oct 23, 2015
    7
    0
    Do I just negate the thing being subtracted? I think I got it then
     
  4. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,678
    2,737
    Close. Negation, though, is not exactly the same as inversion. Look up "2's complement".
     
  5. katevable

    Thread Starter New Member

    Oct 23, 2015
    7
    0
    Ah right, two's complement. So I have to invert with the NOT gate and add 1 as the second input into the adder. But how do I add one in my circuit if I only am allowed one adder?
     
  6. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,678
    2,737
    Can you think of a way to input an extra 1 into the LSB of the adder? Hmmm.
     
  7. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Does your adder have a "carry in"?
     
  8. katevable

    Thread Starter New Member

    Oct 23, 2015
    7
    0
    The adder has a carry-in, but how can I have a carry-in of 1 exclusively for subtraction (opcode 00 and 10)? I have splitters available to me but no additional MUXs
     
  9. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    What is the rule for creating a Two's complement?
     
  10. katevable

    Thread Starter New Member

    Oct 23, 2015
    7
    0
    I know I need to have a carry-in only when I'm subtracting, which is when the select line in my second MUX is 0. But my MUX-ing, if you will, happens before my adding, so I don't understand how I could possibly selectively have a carry-in. Is there something obvious that I'm missing? Screen Shot 2015-10-23 at 11.53.51 AM.png
     
  11. katevable

    Thread Starter New Member

    Oct 23, 2015
    7
    0
    Wait, I'm trying to add an inverter to the output from the splitter of the first bit and wire that into my carry-in. I'm hoping this will work
     
  12. katevable

    Thread Starter New Member

    Oct 23, 2015
    7
    0
    I think this works!
     
  13. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    In a word, Yes!
     
  14. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,678
    2,737
    Yes. Addition has an amazing property that it is commutative.
     
  15. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    Now THIS is how Homework Help is supposed to work. Great job, everyone!

    What is the purpose of the left-most MUX? What does it mean to have an eight-bit input on one side of the MUX and a two-bit input on the other? I'm assuming you want an eight-bit constant that is equal to 1 (i.e., "00000001"). Can you show it that way on the diagram? If so, it will be less confusing. You should also annotate your diagram with a small table showing the defined OP codes and what operation is performed. Try to make the diagram self-sufficient and self-explanatory.
     
  16. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,678
    2,737
    Does this mean I get promoted to TA?
     
  17. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    Is there a "shudder-at-the-thought" emoticon? :D
     
    joeyd999 likes this.
Loading...