Nandgame - build a cpu in your browser

Build a CPU in your browser, starting with a NAND gate. Each step builds a component, then newly built component that to the available components to build the next one.

http://nandgame.com/

This is a nice intro to computer logic in the context of building a really simple CPU. It would make a nice intro to digital logic, possibly as a precursor to a limited focus FPGA/programmable logic class.

In the later stages, toward the end, things won’t make as much sense unless you have the book, as the author mentions in the ‘About’ page.

The Nand Game is inspired by the amazing course From NAND to Tetris - Building a Modern Computer From First Principles which is highly recommended.

This game only covers a small part of the material in the above course, and is mostly intended as a fun exercise.

If you are interested in the fundamentals of computing, the book Code by Charles Petzold is also highly recommended.

For any feedback, complaints or questions contact [email protected].

Hope you have fun with the game!

  • Olav Junker Kjær

For a trip to the Karnaugh map wayback machine, go to the ‘Condition’ step. This is where the ALU condition decoding is done. First order decode was done by making and 8:1 mux out of 2-input ANDs and ORs. It was very big and messy. At the end of each working step, a message is given stating whether the solution used the minimal amount of resources. Of course this one didn’t.

After a bit of Karnaugh map manipulation, the following optimized (and minimal) solution was realized. Don’t forget - as I did - that adjacent terms on the Kmap axis are grey-code, only 1 bit at a time can change. Otherwise things won’t work…

Karnaugh map from which optimized solution was extracted.
image

Happy Nanding!

5 Likes

It is somewhat surprising they do not use the recognized shapes of the various logic gates.

2 Likes

It would certainly benefit someone learning logic using this tool, as any future logic gate diagrams they would encounter would be understandable.

1 Like