A 4-bit accumulator-based CPU designed to do the bare minimum and nothing more.
This started out sounding like a good/fun idea, but I kind of failed on execution...I should have really just made a simplified 8-bit CPU.
- 4-bit, accumulator-based, harvard architecture
- 16-bit instruction; 12-bit addressing; 65536 byte ROM (16x4096)
- 4-bit word size; 12-bit addressing; 16384 byte RAM (4x4096)
- One general purpose 8-bit register, the accumulator
Opcode | Mnemonic | Description | Example |
---|---|---|---|
0000 (0) | LDA |
Load accumulator low nibble with memory | example |
0001 (1) | LDI |
Load immediate into accumulator | example |
0010 (2) | STA |
Store accumulator low nibble to memory | example |
0011 (3) | INP |
Load input into accumulator | example |
0100 (4) | OUT |
Load accumulator into output | example |
0101 (5) | BRC |
Branch on carry flag set | example |
0110 (6) | BRZ |
Branch on zero flag set | example |
0111 (7) | JMP |
Unconditional jump to address | example |
1000 (8) | ADI |
Add immediate to accumulator | example |
1001 (9) | ADD |
Add memory to accumulator | example |
1010 (A) | SUB |
Subtract memory to accumulator | example |
1011 (B) | AND |
Logical AND accumulator with memory | example |
1100 (C) | ORR |
Logical OR accumulator with memory | example |
1101 (D) | XOR |
Logical XOR accumulator with memory | example |
1110 (E) | LSL |
Logical shift left accumulator | example |
1111 (F) | LSR |
Logical shift right accumulator | example |
Register | Size | Description |
---|---|---|
PC | 12-bit | program counter |
AC | 8-bit | accumulator |
FL | 2-bit | flags register |
Mask | Flag | Description |
---|---|---|
01 | Z |
Zero |
10 | C |
Carry |
Signal | Name |
---|---|
CTRL_ALU |
Enable ALU output |
CTRL_MW |
Memory write |
CTRL_MR |
Memory read |
CTRL_JMP |
jump |
CTRL_INP |
Enable input |
CTRL_OUT |
Enable output |
example: make target MOD=alu
CPU with test ROM: make target MOD=cpu
This makefile compiles the target module with iverilog
,
simulates it with vvp
, and opens the waveform in gtkwave
.
TODO: I hope to make a really simple assembler for this at some point in the future.