How do you subtract a constant using only an adder?

Thread Starter

katevable

Joined Oct 23, 2015
7
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?
 

Thread Starter

katevable

Joined Oct 23, 2015
7
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?
 

Thread Starter

katevable

Joined Oct 23, 2015
7
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
 

Thread Starter

katevable

Joined Oct 23, 2015
7
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
 

Thread Starter

katevable

Joined Oct 23, 2015
7
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
 

WBahn

Joined Mar 31, 2012
29,979
I think this works!
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.
 
Top