Menu

Theme

Component reference · Component · CHECKED ON 5.0.0

Arithmetic in Logisim: comparator, adder, subtractor, multiplier and shifter

The Arithmetic library adds, subtracts, multiplies, negates, compares and shifts binary numbers. The Comparator has three outputs (greater, equal, less) and treats numbers as two's complement, signed, unless you set Numeric Type to Unsigned. The Adder has a carry in and a carry out, and the Subtractor a borrow in and a borrow out. Every table on this page was printed by Logisim-evolution 5.0.0.
FOR
Students building an ALU or a datapath · Logisim-evolution 5.0.0
CHECKED
9 Nov 2026
Checked against Logisim-evolution 5.0.0 on 1 machines
On this page

Signed or unsigned: read this first

The same eight bits mean different numbers in the two readings. In two’s complement the top bit counts as negative.

Eight-bit patterns as unsigned and as two's complement
01111111127127
10000000128-128
10000001129-127
11111110254-2
11111111255-1
0000000111

The Comparator has a Numeric Type setting, signed by default. The project’s notes list the same kind of setting on the Multiplier and the Divider. The Adder and Subtractor give the same bits either way; only your reading of them changes.

Comparator

Inputs A and B, three one-bit outputs: Greater, Equal, Less. By default it compares as signed numbers (F42). On 4 bits, 128 of the 256 input pairs get a different answer when you switch Numeric Type to Unsigned. Here are the first rows where the two settings disagree (outputs are Greater, Equal, Less):

4-bit Comparator: default signed type against Unsigned
000010001 0 00 0 1
000010011 0 00 0 1
000010101 0 00 0 1
000010111 0 00 0 1
000011001 0 00 0 1
000011011 0 00 0 1
000011101 0 00 0 1
000011111 0 00 0 1

Downloads, each checked against its full table: signed, unsigned. To build a comparator from gates, see the full adder project and the ALU project.

Adder

Inputs A and B, a carry in, a sum output and a carry out. The tables below come from the 4-bit Adder with carry in as a pin (F44 lists the ports):

4-bit Adder, selected rows
00010010000110
00010010101000
01110001010000
11110001000001
11111111111111

A carry out of 1 with a sum of 0000 means the sum did not fit in 4 bits. The Adder has no overflow output. For signed numbers, overflow occurs when both inputs have the same sign and the sum has the opposite sign; this is the standard rule and we did not build it. We did not test what an unconnected carry-in does, so wire it to a constant 0.

Download the 4-bit adder: all 512 input combinations match its table.

A 16-bit adder from two 8-bit adders

Split each 16-bit number into two bytes, add the low bytes, send the carry out of the low Adder to the carry in of the high Adder, and join the two sums with a splitter. See Splitters.

circ-arith-adder-16-from-8 · mainscroll to see all
16161616bA16bBaloahiblobhiAdderAdderalobloahibhi0ccsloshishislo16bSCout
Two 8-bit Adders chained by carry. Twenty sums, including 0x00FF + 0x0001 and 0xFFFF + 0x0001, matched in 5.0.0. CC BY 4.0 · SHA-256 fe01bde35a1f
Describe this circuit

Components: Input pin A; Input pin B; Splitter 1; Splitter 2; Adder 1; Adder 2; Constant 1; Splitter 3; Output pin S; Output pin Cout.

  • Input pin A connects to Splitter 1 (net A), 16 bits wide.
  • Input pin B connects to Splitter 2 (net B), 16 bits wide.
  • Splitter 1 connects to Adder 1 (net alo), 8 bits wide.
  • Splitter 1 connects to Adder 2 (net ahi), 8 bits wide.
  • Splitter 2 connects to Adder 1 (net blo), 8 bits wide.
  • Splitter 2 connects to Adder 2 (net bhi), 8 bits wide.
  • Adder 1 connects to Splitter 3 (net slo), 8 bits wide.
  • Adder 1 connects to Constant 1.
  • Adder 1 connects to Adder 2 (net c).
  • Adder 2 connects to Splitter 3 (net shi), 8 bits wide.
  • Adder 2 connects to Output pin Cout (net Cout).
  • Splitter 3 connects to Output pin S (net S), 16 bits wide.

Download the circuit.

Subtractor

Minuend M, subtrahend S, a borrow in, a difference and a borrow out. The borrow out is 1 when the difference is negative.

4-bit Subtractor, selected rows
01010011000100
01010011100010
00000001011111
00110101011101

Download the 4-bit subtractor. A common alternative is an adder with XOR gates on one input and the carry in set to 1; see the adder projects.

Multiplier

The Multiplier gives the low bits of the product in its output and the upper bits on the carry-out port; the carry-in port adds an amount. For the 3-bit part (F44):

3-bit Multiplier
010011000110000
111111000001110
111111111000111
100100000000010

7 × 7 = 49 is 110001: the output holds 001 and the carry out holds 110. We did not compare the signed and unsigned types of the Multiplier. A Divider is in the library too, with dividend, divisor, quotient and remainder; we did not test it and give no result for division by zero.

Shifter

The Shifter has a Shift Type: Logical Left, Logical Right, Arithmetic Right, Rotate Left or Rotate Right. The distance input is as wide as needed to count the data bits. We tested three types on 4 bits; the table shows 1001 shifted by each distance:

4-bit Shifter applied to 1001
0100110011001
1001011001100
2010001101110
3100000111111

Downloads: logical left, rotate right, arithmetic right. We did not test Logical Right or Rotate Left.

Negator, Bit Adder and Bit Finder

The Negator gives the two’s complement negation. On 4 bits, 1000 (−8) negates to 1000, because +8 does not fit:

4-bit Negator
00000000
00011111
00101110
00111101
01001100
01011011
01101010
01111001
10001000
10010111
10100110
10110101
11000100
11010011
11100010
11110001

The Bit Adder counts the 1 bits in its input:

4-bit Bit Adder
0000000
0001001
0010001
0011010
0100001
0101010
0110010
0111011
1000001
1001010
1010010
1011011
1100010
1101011
1110011
1111100

The Bit Finder reports whether a bit is present and the index of the lowest-order 1 (its default Type):

4-bit Bit Finder, lowest-order 1
0000000
0001100
0010101
0011100
0100110
0101100
0110101
0111100
1000111
1001100
1010101
1011100
1100110
1101100
1110101
1111100

The other Bit Finder types, such as highest-order 1, were not tested.

Newer parts

Parts first listed in 4.1.0 in our component list:

Components first listed in 4.1.0
ExponentiatorRaises one integer input to the power of another.
Square RootComputes the integer square root of its input.
AbsoluteOutputs the absolute value of a signed integer.
Minimum and MaximumOutputs the smaller or larger of its inputs.
Floating Point ExponentiatorRaises a floating-point value to a power.
Floating Point LogarithmComputes a logarithm of a floating-point value.
Floating Point Square RootSquare root of a floating-point value.
Floating Point AbsoluteAbsolute value of a floating-point number.
Floating Point Minimum and MaximumSmaller or larger of floating-point inputs.
Floating Point RoundRounds a floating-point value (e.g. floor, ceiling, nearest).
Floating Point TrigonometrySine, cosine and related functions on floating-point values.
Floating Point ClassificatorReports whether a floating-point value is zero, infinite, NaN, negative and so on.
Floating Point ConverterConverts between floating-point formats (16/32/64-bit).
Dual Port RAMRAM with two independent access ports.
DMA engineMemory-to-memory copy engine on the SoC bus (added 4.1.0).

The Floating Point Arithmetic library is separate; see the component reference filtered to it.

When your lab says “build it from gates”

Use the built-in part to check your own design. Run the same 4-bit vector against both and compare the tables; see Test vectors when available, and the full adder project.

Frequently asked questions

Why does the Logisim comparator say a big number is smaller?

By default the Comparator reads its inputs as two's complement, so 1000 on 4 bits is minus 8 and is less than 0001. Set Numeric Type to Unsigned and 1000 (8) is greater (F42).

How do I add two 16-bit numbers with 8-bit adders?

Split each 16-bit number into two bytes with a splitter, add the low bytes, wire that Adder's carry out to the high Adder's carry in, and join the two sums. Our file does exactly that and matched 20 test sums.

How do I detect overflow in Logisim?

The Adder has no overflow output. For signed numbers, overflow happens when both inputs have the same sign and the sum has the opposite sign. We did not build or test that circuit, so this is the standard rule rather than our result.

How do I get the carry out of an adder?

Wire the Adder's carry-out port, on the bottom edge, to an output pin or the next stage. For 0xF + 0x1 on 4 bits the sum is 0000 and the carry out is 1.

How do I shift right and keep the sign?

Set the Shifter's Shift Type to Arithmetic Right. For 1001 shifted by 1 it gave 1100 in our test; Logical Right would give 0100.

Sources

  1. Logisim-evolution user guide: Arithmetic library, Logisim-evolution project, accessed 9 Nov 2026
  2. Tables printed by the 5.0.0 jar, logisim.dev lab data: test-data/lab2-2026-11-09-components/tables/; test-data/FINDINGS.md F42, F44

Try: , , ,