A circuit description language and simulator, intended for making a CPU from nand gates.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
parse.py Initial release Sep 27, 2018
program.py Initial release Sep 27, 2018
program.txt
readme.md Initial release Sep 27, 2018
requirements.txt
sim.py
test.py

readme.md

A circuit description language and simulator intended for making a CPU from nand gates.

This post describes the motivation and some internals.

Running (the default CPU with the sample preloaded into ROM)

pip install -r requirements.txt
python parse.py

Running your own CPU

from parse import make_gates, rom, cpu_cycle
program = "# Your CPU description here"
gates = make_gates(program)
rom[:] = [0b00, 0b10, ...] # Format this for your CPU
while True:
    cpu_cycle(gates['CPU'])

Tests for gates used in the default CPU

python test.py

The default CPU is based on Nand game which itself is based on Nand to Tetris.