Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/keyvank/pygates

Simulating a CPU made of logic gates
https://github.com/keyvank/pygates

Last synced: about 2 months ago
JSON representation

Simulating a CPU made of logic gates

Awesome Lists containing this project

README

        

# PyGates

Trying to understand how computers work at the transistor level in a Python simulation.

A Von-Neumann Brainfuck CPU:

```
FWD
P = P + 1
PC = PC + 1
MEM[P] = MEM[P]

BWD
P = P - 1
PC = PC + 1
MEM[P] = MEM[P]

INC
P = P
PC = PC + 1
MEM[P] = MEM[P] + 1

DEC
P = P
PC = PC + 1
MEM[P] = MEM[P] - 1

JZ
P = P
PC = X
MEM[P] = MEM[P]
```

```
P =
p+1 if 0b000
p-1 if 0b001
else p

PC =
X if 0b100 &&
else PC + 1

MEM[P] =
MEM[P] + 1 if 0b010
MEM[P] - 1 if 0b011
else MEM[P]
```