A cross-platform simulator for the GreenArrays GA144 multi-computer chip.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move fetch logic into fetch state

+13 -13
+13 -13
src/f18.zig
··· 98 98 99 99 /// An F18A computer 100 100 pub const Computer = struct { 101 + const State = enum { 102 + fetch, 103 + execution, 104 + unext, 105 + next, 106 + }; 101 107 /// control and status for communication ports and I/O logic. 102 108 io: Word, 103 109 /// serves as a "program computer" ··· 114 120 return_stack: stack.ReturnStack, 115 121 data_stack: stack.DataStack, 116 122 117 - state: enum { 118 - fetch, 119 - execution, 120 - unext, 121 - next, 122 - }, 123 + state: State = .fetch, 123 124 124 125 slot: u2, 125 126 126 127 pub fn step(self: *Computer) void { 127 - self.state = .fetch; 128 - self.i = self.mem[self.p.address.local]; 129 - const instruction: Instruction = @bitCast(self.i); 130 - 131 - self.p.increment(); 128 + var instruction: Instruction = undefined; 132 129 133 - current_state: switch (self.state) { 130 + current_state: switch (State.fetch) { 134 131 .fetch => { 132 + self.i = self.mem[self.p.address.local]; 133 + instruction = @bitCast(self.i); 134 + 135 + self.p.increment(); 135 136 continue :current_state .execution; 136 137 }, 137 138 .execution => { ··· 149 150 break :current_state; 150 151 }, 151 152 } 152 - return; 153 153 }, 154 154 .unext => { 155 155 if (self.return_stack.t == 0) {