Skip to content

Commit

Permalink
Start on architecture spec
Browse files Browse the repository at this point in the history
  • Loading branch information
commonkestrel committed Nov 14, 2023
1 parent 8e12145 commit dac8c56
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Arch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Architecture

## Control Word

The control word toggles operations inside the CPU,
and enables CPU control based on instructions.

This control word changes every clock cycle,
and is determined in 3 ROM chips inside the control circuit
based on the current instruction, the instruction immediate bit,
and the clock cycle.

### ALU opcode

The first three bits of the control word (`AOL`, `AOM`, and `AOH`) represent the ALU opcode.
ALU operations based on these opcodes are shown below:

| `AOL` | `AOM` | `AOH` | Operation |
|-------|-------|-------|-----------|
| `0` | `0` | `0` | `ADD` |
| `0` | `0` | `1` | `SUB` |
| `0` | `1` | `0` | `ADC` |
| `0` | `1` | `0` | `SBC` |
| `1` | `0` | `0` | `NAND` |
| `1` | `0` | `1` | `OR` |
| `1` | `1` | `0` | `CMP` |
| `1` | `1` | `1` | `CZ` |

While most of these are pretty self explanitory,
a few need a bit more explanation.

`CMP` compares the numbers in the primary and secondary registers,
and sets the `L`, `E`, and `G` flags in the Flags Register accordingly.

`CZ` stands for Check Zero.
This operation checks if the number in the primary register is zero,
and sets the `Z` flag in the Flags Register accordingly.

0 comments on commit dac8c56

Please sign in to comment.