summaryrefslogtreecommitdiff
path: root/eater_cpu/readme.txt
blob: b75a00cc42892d13dd74bf3e39e887b77d8ad48c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
                       4 LSB      
                   +<--------> PC 
                   |              
                   |              
        4 LSB      |              
 MAR <-------------+<--------> A  
  |                |           |  
  | 4 LSB          |           |  
  |                |           |  
  v                |           v  
 RAM <------------>|<-------- ALU 
                   |           ^  
                   |           |  
                   |           |  
                   |           |  
     <-------------+           |  
  IR ------------->|<--------> B  
  |    4 LSB       |              
  |                |              
  |                |              
  | 4 MSB          +---------> OUT
  |                             | 
  v                             | 
  ins                           v 
  decoder                   DISPLAY

---

instruction set

NOP ____________  0b_0000_xxxx            No-op
LDA <memaddress>  0b_0001_<memaddress>    Load memory > A
ADD <memaddress>  0b_0010_<memaddress>    "Add memory": mem>B, A + B -> A
SUB <memaddress>  0b_0011_<memaddress>    "Sub memory": mem>B, A - B-> A
OUT ____________  0b_1110_xxxx            Output A -> OUT
HLT ____________  0b_1111_xxxx            Sets halt flag
---

operation

1. Load instruction @ PC into INS,
   Increment PC.
   a) PC out -> MAR
   (PC_to_bus) + (bus_to_MAR) + (clk)
   b) MEM -> INS
   (RAM_to_bus) + (bus_to_INS) + (clk)
   c) PC++
   (PC_count_en) + (clk)

   NOTE:
   Yes, I know Ben Eaters computer combines b and c.
   See eater_types for details.

2. Decode and execute instruction.

2.I LDA: Load memory into A
   a) INS_lsb -> MAR
   (INS_to_bus) + (bus_to_MAR) + (clk)
   b) MEM -> A
   (RAM_to_bus) + (bus_to_A) + (clk)

2.II ADD: Load mem in B,
   ALU "auto" adds,
   put back in A
   a) INS_lsb -> MAR
   (INS_to_bus) + (bus_to_MAR) + (clk)
   b) MEM -> B
   (RAM_to_bus) + (bus_to_B) + (clk)
   c) ALU -> A
   (ALU_to_bus) + (bus_to_A) + (clk)

2.III OUT: Put A in OUT
   a) A -> OUT
   (A_to_bus) + (bus_to_OUT) + (clk)