How to Build an ALU in Logisim-evolution
An ALU (Arithmetic Logic Unit) is the part of a CPU that does math and logic. Logisim-evolution has no single “ALU” component — you build one from an adder, a subtractor, logic gates, and a multiplexer that picks the result. That is exactly how real ALUs are organized, so building one teaches the real concept.
What our ALU does
Our ALU works on 4-bit numbers and supports four operations, chosen by a 2-bit opcode:
00— ADD01— SUBTRACT10— AND11— OR
Step 1: Add the arithmetic blocks
From the Arithmetic library, place an Adder and a Subtractor. Select each and set its data bit width to 4 in the attribute panel. Add two input pins (Wiring → Pin, Type = Input, Data Bits = 4) named A and B, and wire A and B into both blocks.
Step 2: Add the logic gates
From the Gates library, place an AND gate and an OR gate, each set to work on 4-bit values in the attribute panel. Wire A and B into both gates. You now have four 4-bit results: sum, difference, AND, and OR.
Step 3: Select the result with a multiplexer
From the Plexers library, place a Multiplexer. Set Select Bit Width to 2 (four choices) and Data Bit Width to 4. Wire the four results into the multiplexer’s data inputs in opcode order: ADD → input 0, SUBTRACT → input 1, AND → input 2, OR → input 3.
Step 4: Wire up the opcode
Add two 1-bit input pins for the opcode bits and connect them to the multiplexer’s select inputs. Connect the multiplexer’s output to a 4-bit output pin — or to a Hex Digit Display from the I/O library to read the result directly.
Step 5: Test every operation
Select the Poke tool and set A = 6 (0110), B = 3 (0011). Step the opcode through 00, 01, 10, 11 and check the output: 9, 3, 2, 7. If a result looks wrong, the opcode-to-input order on the multiplexer is the first thing to check.
Going further
- Carry flag: the Adder has a carry output — wire it to an LED to make overflow visible.
- Zero flag: combine the four result bits with an OR and invert the output with a NOT gate. The flag reads 1 only when the ALU output is zero.
- More operations: widen the opcode to 3 bits and add XOR, shifts, or comparisons with the Comparator from the Arithmetic library.
Keep learning
- Multiplexer (MUX) Tutorial — the selection trick in detail.
- Combinational Analysis — generate control logic from a table.
- Counter Tutorial — add sequential state to your designs.
