LogisimRevisited

Components / Arithmetic

Subtractor Component in Logisim

Computes N-bit binary subtraction (A - B - bin), producing an N-bit Difference (Diff) and a 1-bit Borrow-Out (bout).

SUBABbinDiffbout
Default settings, facing east. Pins are the dots.
LibraryArithmetic
Type nameSubtractor
Pins and defaultsa A (-40, -10), b B (-40, 10), cin bin (-20, -20), out0 Diff (0, 0), cout bout (-20, 20), width 1..32

Try it in the app

How the Subtractor Works in Logisim

The Subtractor computes A - B - bin across 1 to 32 bits, where A is the minuend (upper-left pin), B is the subtrahend (lower-left pin), and bin is the 1-bit Borrow-In on the top edge.

Like the Adder’s cin, an unconnected Borrow-In (bin = Z) defaults to 0 so the component computes A - B directly. When the unsigned value of A is less than B + bin, the result wraps modulo 2^N (producing the two's complement difference) and the bottom Borrow-Out pin (bout) asserts 1.

Tip: In an ALU, you can either use a dedicated Subtractor component or share a single Adder by multiplexing B with ~B and setting cin = 1.

Subtractor Pins & Pinout

PinDirectionWidthLocation & Role
a (A)Input (Upper-left)1–32 bitsOffset (-40, -10). Minuend operand A.
b (B)Input (Lower-left)1–32 bitsOffset (-40, 10). Subtrahend operand B.
cin (bin)Input (Top edge)1 bitOffset (-20, -20). Borrow-In bit (defaults to 0 when unconnected/Z).
out0 (Diff)Output (Right edge)1–32 bitsOffset (0, 0). N-bit difference (A - B - bin) mod 2^N.
cout (bout)Output (Bottom edge)1 bitOffset (-20, 20). Borrow-Out bit (1 when A < B + bin).

Subtractor Truth Table & Behavior

1-Bit Subtractor truth table (bin = 0)
ABbinDiff (A - B)bout (Borrow)
00000
01011 (borrowed)
10010
11000

Related Circuits & Components