|
I have written a virtual CPU from very simple building blocks and highly recommend doing it. I started with class Wire (which just wraps a bool) and class Transistor (which accepts two input Wire& and has an output Wire). It has an Update() function which sets the output state. From those I built up gates, then flipflops, registers, mux/demuxes, counters, an ALU, and memory banks. Then I wrote a machine language, connected the cpu together, wrote a loader to load machine language files into ROM, then an assembler to allow me to write assembly code. I then added VRAM, async buses, and wrote a working implementation of Game of Life. It has 32bit instructions and runs about 10kHz with 8KB of RAM. |