This repository contains the Logisim implementation of a basic computer with a full datapath and control unit. The final circuit executes a real assembly program that computes a loop involving XOR, division, and accumulation.
This project was developed for CSIS402: Computer Organization and Systems Programming at the German University in Cairo (GUC), Spring 2026.
basic-computer/
│
├── circuit/
│ └── basic_computer.circ # Logisim circuit file
│
├── memory/
│ └── memory_contents.txt # Machine code loaded into RAM
│
├── screenshots/
│ ├── full_circuit.png
│ ├── alu.png
│ └── control_unit.png
│
├── docs/
│ └── rtls_and_control_logic.pdf
│
└── README.md
- 256 × 16-bit RAM — 256 addressable locations, each 16 bits wide
- The Address Register (AR) drives the memory address lines
- Memory input and output are connected to the common bus
- Read/write controlled by the control unit each clock cycle
Four 16-bit and two 8-bit registers, each with load, increment and clear flags:
| Register | Description |
|---|---|
| AR | Address Register |
| PC | Program Counter |
| DR | Data Register |
| AC | Accumulator |
| IR | Instruction Register |
| TR | Temporary Register |
A D flip-flop was added to all CLR signals to enforce synchronous clearing, since Logisim's counter clear is asynchronous by default.
7-input multiplexed bus with 3 select lines (S2S1S0):
| S2 S1 S0 | Source |
|---|---|
| 0 0 1 | Memory |
| 0 1 0 | AR |
| 0 1 1 | PC |
| 1 0 0 | DR |
| 1 0 1 | AC |
| 1 1 0 | IR |
| 1 1 1 | TR |
Each instruction is 16 bits, decoded from the IR as follows:
+----------+----------+------------------+----------+
| I bit | opcode | address | unused |
| [15] | [14:12] | [11:4] | [3:0] |
+----------+----------+------------------+----------+
- Bit 15 (I): Always 0 — All memory instructions are direct (no indirect addressing)
- Bits 14–12: Opcode — decoded by a 3-to-8 decoder to produce D0–D6
- Bits 11–4: Address field — used as the memory operand address
- Bits 3–0: Unused, ignored
- All instructions begin execution at T3 (T0–T2 are the common fetch cycle)
Takes two inputs — AC (A) and DR (B) — and outputs the result selected by C2C1C0:
| C2 C1 C0 | Operation |
|---|---|
| 0 0 1 | Transfer A (from DR) |
| 0 1 0 | Add A + B |
| 0 1 1 | Subtract A − B |
| 1 0 0 | Multiply A × B |
| 1 0 1 | Divide A / B |
| 1 1 0 | Complement A |
| 1 1 1 | A XOR B |
The ALU output is routed through a MUX selected by C2C1C0 back into the AC via the control unit.
DIVreuses the BSA opcode andXORreuses the AND opcode, since neither BSA nor AND are implemented in this project.
-
RTL Design — Wrote register transfer language (RTL) statements for each instruction cycle by cycle, starting from T3. T0–T2 are shared across all instructions as the standard fetch cycle.
-
Logical Expressions — Derived boolean expressions for every control signal (LD, INC, CLR for each register; bus select lines S2S1S0; ALU select lines C2C1C0; memory READ/WRITE/EN) from the RTL timing diagrams. Unneeded controls in the required programs were ignored.
-
Sequence Counter (SC) — Built using a counter and a 3-to-8 decoder to produce timing signals T0–T6. A CLR SC signal was derived as a boolean OR of the last timing step of each instruction, resetting the SC automatically at the end of each instruction.
-
Opcode Decoder — A 3-to-8 decoder reads IR[14:12] and produces D0–D6, one active signal per instruction.
-
Per-component logic — For each register and component (AR, PC, DR, AC, IR, TR, MEM, BUS, ALU), the logical expressions were implemented as gate networks combining the timing signals (Tx) and decoded opcode signals (Dx).
-
Priority Encoders — Used for BUS select (S2S1S0) and ALU select (C2C1C0) outputs.
LDA · STA · ADD · ISZ · BUN · DIV · XOR
All unused control signals are tied to 0 to ensure stable execution.
ORG 0
LOP, LDA A
XOR B
ADD A
STA A
LDA A
DIV B
ADD C
STA C
ISZ i
BUN LOP
HLT
A, DEC 15
B, DEC 5
C, DEC 0
i, DEC -3Equivalent C code:
int A = 15, B = 5, C = 0;
for (int i = 0; i < 3; i++) {
A += A ^ B;
C += A / B;
}Expected result after 3 iterations: A = 101, C = 35
- Ahmed Zainhom
- Ebrahim Omar Elshafei
- Martin Joseph Adly Elabd
- Omar Waleed El-sayed
- Youssef Sameh Emil Shafik
- Zayd Ahmed


