Show HN: Online challenge: Build a CPU from scratch
nandgame.com
nandgame.com
Hopefully it is both fun and challenging, while at the same time educational about some of the fundamental principles of how a CPU works.
It still lack some explanatory texts, but is should be playable as it is.
It is inspired by the first chapters of the brilliant Nand2tetris course (and I have gotten permission to use the same general CPU design). My hope is this is more accessible since it is web-based and does not require any text-based coding or CS background.
This reminded me of "Code" by Charles Petzold, which I saw you reference in the About page. As a software engineer with an interest (but no professional training) in hardware design, I think it's useful and interesting to have at least a basic understanding of how a CPU handles logic.
Can I ask what library (if any) you used for the canvas interactions? I'm looking for something similar for a project of my own.
I think I've finally found what I'm looking for in Raphael.js + Raphael.FreeTransform though.
Would be awesome if you compare your answer to the "best" solution, i.e. which uses the minimum number of components (or even the minimum number of nand gates!)
It would also be cool to show the overall cost in nand-gates or even transistors. And to be able to show the solutions decomposed into only transistors and wires.
Didn't know Euclid the Game, but it seems very cool and close to what I wanted to achieve.
Perhaps a toggle for the info boxes on components?
Overall, I love this though.
I'm really enjoying the whole thing though, great work!
I wanted to send a bit into two separate components and I was looking for some sort of "hub" object. It wasn't clear (to me) that you could connect many lines to a single node.
Removing lines takes a lot of clicking.
Is my design the best possible? Rather than just being told my design fits the requirements, I'd like to be told that I could have done it with one less component and offer to try again.
Otherwise, it's fun, although the node connections are fiddly! Maybe allow dragging from either end? Or snapping together.
Edit to add: and on the next level, the m flag doesn't exist. So, will stop there, but fun!
The m issue is a bug in the spec, thanks for discovering it.
Thank you for the feedback, it is much appreciated.
To further build on this; If there is an intermediate state, show its pins in the diagram like output and input. If the table becomes wide, perhaps show it on the bottom. Perhaps let users add a "debug probe" from the toolbox that becomes a column in that table.
While I'm at it, here's another bug: the last test of the program engine feeds a 5 into j, which breaks things because the counter doesn't expect it at all. Also the final level doesn't have any tests but I'm sure you know that.
I want to add that besides some issues that have already been pointed out, it's a really nicely made tutorial. I went through all of it pretty fast because I already have a good background, but I would definitely point a beginner to it as a learning resource.
Yes I think I shot myself in the foot by designing the connectors so the labels could only be one or two letters. There is no technical reason they couldn't have descriptive labels like "clock" rather than "c". But it would probably require to turn the design "on the side", so the connectors are left-right rather than top-bottom.
I know I miss tests for a few of the levels.
Thanks for the nice words, it is encouraging!
I was saddened by the fact that I lost progress when I left the page. It would be nice if progress could be save via cookies or something.
One other thing that would be nice is the ability to offer hints. These could even be just an external link to relevant material on wikipedia or equivalent.
Reset for clearing all components off the canvas, or for resetting the input signals and state? Or both?
The explanatory text for the level does not really define neither "byte" or "word", so beside fixing the error it also need more details. (But I want to avoid going down the rabbit hole of explaining that bytes can have different sizes than 8 and so on)
By the way I suppose the subtraction component should be available in this task. This would make is simpler. I had trouble deciding if increment should be before or after subtraction.