TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

NandGame – Build a Computer from Scratch

627 pointsby dalemyersover 4 years ago

43 comments

carlsover 4 years ago
I&#x27;ve done the Coursera course, Nand2Tetris, that inspired this website [1] and found it deeply intellectually satisfying and engaging.<p>If anyone is interested in learning about the logical primitives that build up to a computer, and how they&#x27;re implemented using logic gates, I would deeply recommend the course!<p>-----------<p>[1] <a href="https:&#x2F;&#x2F;www.nand2tetris.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.nand2tetris.org&#x2F;</a>
评论 #25285161 未加载
评论 #25283260 未加载
评论 #25285782 未加载
评论 #25284658 未加载
评论 #25283481 未加载
Sniffnoyover 4 years ago
Building circuits is neat, but I think this has some problems as a game:<p>1. It seems to only let you save one solution for each level, even though there are two optimization goals. It should let you save one for fewest components and one for fewest NAND gates.<p>2. It&#x27;s not really clear how NAND gate counts work in later levels where you&#x27;re using potentially non-optimal components you&#x27;ve built? Like does it count each one as the number of gates that you used, or the number of gates that is optimal, or what? Someone else told me it was the latter, but it seems like XOR counts as 6 even though there&#x27;s apparently a way to do it with fewer?<p>3. Why do some levels give me the message &quot;This is optimal!&quot; while others say &quot;This is the simplest solution!&quot;? What&#x27;s going on here? What do these messages mean specifically? It&#x27;s not clear.<p>All this adds up making attempts at optimization a bit frustrating and as such I just don&#x27;t really want to play it very far. If you&#x27;re not worried about optimization it seems fine, but if you are the interface really kind of works against you.
评论 #25287049 未加载
评论 #25287806 未加载
评论 #25284319 未加载
kaysonover 4 years ago
Not that this will ever matter for someone who isn&#x27;t a circuit designer, but the &quot;optimal&quot; solution for the latch is actually really bad.<p>If you use a &quot;select&quot; block (which should really be called &quot;mux&quot;) and tie the output to the input, you create a race condition. If the data input is 1, and you change set from 1 to 0, the output can actually glitch to 0 for a very short period of time, which is a big no-no. (If you draw the equivalent circuit out with just nand gates and assume they all have some delay between input and output, you&#x27;ll see why).<p>A safer solution would be to cross couple two nand gates into an SR latch [0], use another two nand gates to control the Set and Reset signals, and an inverter to create NOT(data).<p>Of course in reality, a latch is usually custom built out of transistors rather than logic gates, but there are some cases where I&#x27;ve used logic-gate-latches to make things easier.<p>&lt;&#x2F;pedanticism&gt;<p>[0] <a href="http:&#x2F;&#x2F;electronics-course.com&#x2F;sr-nand-latch" rel="nofollow">http:&#x2F;&#x2F;electronics-course.com&#x2F;sr-nand-latch</a>
评论 #25293010 未加载
评论 #25285785 未加载
IIAOPSWover 4 years ago
There was this ancient Flash game called &quot;Engineer of the People&quot; that was all about designing IC circuits (NPN and PNP junctions) in the Soviet Union for some secretive reason. I never beat the game and got to the reveal. IIRC it was by Zachtronics, the same guy that did Shenzhen I&#x2F;O and infiniminer (the inspiration for Minecraft).
评论 #25286701 未加载
评论 #25284099 未加载
评论 #25283803 未加载
评论 #25282981 未加载
评论 #25283319 未加载
userbinatorover 4 years ago
I know digital logic, yet was perplexed by the odd definition of D flip-flop this game uses with both &quot;store&quot; and &quot;clock&quot; inputs, which matches none of the standard variants of DFFs: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Flip-flop_(electronics)#D_flip-flop" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Flip-flop_(electronics)#D_flip...</a><p>Edit: this continues on with the counter level, where you can use the register but it does not behave like the typical set of edge-triggered flip-flops (or transparent latches) that one would normally use. My best attempt at coming up with an explanation is that it&#x27;s like two-phase edge-triggered logic.
评论 #25293167 未加载
ElHackerover 4 years ago
I got excited when I saw the title, then checked the URL and it is a software simulation &#x2F; game of building a computer. I&#x27;m not denying this can be interesting, but I&#x27;ve been thinking for a while to get my hands dirty with hardware as a side project. (I&#x27;m a software eng by profession). I haven&#x27;t really done a lot of research on this yet, but does anyone have any recommended guides&#x2F;books&#x2F;tutorials on how to get started designing and building my own computer? (extra points it it&#x27;s a mobile&#x2F;embedded computer)
评论 #25283568 未加载
评论 #25283536 未加载
评论 #25284570 未加载
评论 #25284228 未加载
评论 #25283826 未加载
评论 #25283574 未加载
评论 #25283838 未加载
评论 #25283875 未加载
评论 #25284150 未加载
rkagererover 4 years ago
Neat! My only complaint is I feel like it would be more intuitive to be able to drag connections from output to input. I understand why it&#x27;s the other way around (each input can only have one source, while outputs can go to multiple chips) but it still feels backwards - like reading right to left.
iKlsRover 4 years ago
If you like this or want to get into it a bit more, this recent video is lovely <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=QZwneRb-zqA" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=QZwneRb-zqA</a>
bstrongover 4 years ago
Very cool! Reminds me of all the fun I had with Rocky&#x27;s Boots on Apple II:<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Rocky%27s_Boots" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Rocky%27s_Boots</a>
评论 #25283397 未加载
linkddover 4 years ago
This looks a bit like MHRD [1] but with a GUI :)<p>----<p>[1] <a href="https:&#x2F;&#x2F;store.steampowered.com&#x2F;app&#x2F;576030&#x2F;MHRD&#x2F;" rel="nofollow">https:&#x2F;&#x2F;store.steampowered.com&#x2F;app&#x2F;576030&#x2F;MHRD&#x2F;</a>
评论 #25283887 未加载
评论 #25287753 未加载
evangowover 4 years ago
Awesome! I&#x27;ve always thought it would be interesting to port Nand2Tetris to the web to make it more easily accessible. Glad someone finally ported the virtual computer building part!
herghostover 4 years ago
I was able to get as far as building the half-adder, but then didn&#x27;t have the means of figuring out the full adder as that seemed massively more complex.
mkl95over 4 years ago
I have fond memories from reading this book and doing the exercises. I never got past building RAM memory though :-)<p>It&#x27;s worth mentioning that the book is getting a extensively revised (sic) 2nd edition in July 2021.<p>* <a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;Elements-Computing-Systems-second-Principles&#x2F;dp&#x2F;0262539802" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;Elements-Computing-Systems-second-Pri...</a>
Koshkinover 4 years ago
I find using an FPGA for this an ideal middle point. Building a functional computer from discrete components is fun but the result may not be worth the effort, to be honest. At the other extreme, modeling it in software may leave a weird feeling of not having achieved anything. With an FPGA, on the other hand, you can create something of a usable computer, even one you could run Linux on.
noncomlover 4 years ago
There are 10 kind of people. Those who like to drag from the input back to the output and those who prefer to drag from the output to the input.
评论 #25287355 未加载
radicalriddlerover 4 years ago
I did logic gates as part one of my first uni courses in I.T. The assignment was actually so fun, I hated when I finished it.
yellowappleover 4 years ago
So I&#x27;m a bit confused with how this is measuring the number of NANDs; for example, with the first adder problem, I solved it with exactly two gates, neither of which were NAND, and yet while it&#x27;s recognized as the lowest number of gates, it insists that it can be done with fewer NANDs (than zero, apparently). Is it counting the NANDs that may or may not be used to implement those two gates? And if so, is that based on how I solved the previous problems? Or is it based on the lowest possible number of NANDs that would be required to solve those problems &#x2F; produce those gates?<p>If it is indeed counting the NANDs used to make the gates I actually used, it&#x27;d be useful to have a clear indication of exactly how many NANDs each gate uses so I can chase after a game of NAND Golf.<p>In any case, this is fun :)
评论 #25286367 未加载
ducktectiveover 4 years ago
For anyone interested, also check out this computer designed in Powder Toy game! <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=h4eHgnLFk9k" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=h4eHgnLFk9k</a>
AQXtover 4 years ago
That&#x27;s the coolest thing I have seen today. Thanks! :)<p>Suggestion: replace the blue button text (&quot;I have completed the level&quot;) with something simpler, like &quot;Run&quot;, &quot;Check&quot;, &quot;Test&quot; or &quot;Go&quot;.
simonbarker87over 4 years ago
Some of my favourite courses of undergrad were Digital Electronics 1 and 2. How you can build everything up from nand gates is so satisfying, I’ve forgotten much of it now but this is bookmarked to come back to for posterity
h_anna_hover 4 years ago
The test in the opcodes level is incomplete as for X-Y it accepts ~(X&amp;Y)
ColinWrightover 4 years ago
It probably sounds petty, but I found it disturbing that inputs are at the bottom ... I was constantly having to readjust my thinking, and have become sufficiently frustrated to give up.
dustedover 4 years ago
This is fun! But, the first few told me &quot;this is the optimal solution&quot;, then I hit the xor gate, and I can get either &quot;this uses the fewest nand gates but it can be done with fewer components&quot; or &quot;this uses the fewest components, but it can be done with fewer nand gates&quot;.. Does this imply that there is no optimal solution, or just that I&#x27;ve not yet found it?
评论 #25296751 未加载
评论 #25301664 未加载
gdcohenover 4 years ago
This is really cool. You&#x27;ve done a tremendous job in making this very usable (I love your yellow sticky note instructions).
vishnuharidasover 4 years ago
Reminds me of Ben Eater&#x27;s Youtube videos where he builds everything using basic gates on a breadboard. He made a video-card using ICs on a breadboard that fascinated me: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=l7rce6IQDWs" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=l7rce6IQDWs</a>
jzer0coolover 4 years ago
What might be some logical next steps to do, learn, or make (preferred) after learning some basic circuit logic?
评论 #25286537 未加载
Hittonover 4 years ago
I love this game. And was the UI improved since the last time it was posted on HN or am I misremembering it?
评论 #25288019 未加载
pteraspidomorphover 4 years ago
This isn&#x27;t working very well for me on firefox. The components don&#x27;t seem to want to be dragged.
rzachover 4 years ago
Love this - I actually started implementing these circuits in C [0] a while back but never got past combined memory.<p>[0]: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23672470" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23672470</a>
BitwiseFoolover 4 years ago
This was so much fun! It brings me back to my first class in digial logic.
mathattackover 4 years ago
I used this with several elementary school kids who enjoyed it very much.
wolfgkeover 4 years ago
A quite similar game in Steam:<p>MHRD<p><a href="https:&#x2F;&#x2F;store.steampowered.com&#x2F;app&#x2F;576030&#x2F;MHRD&#x2F;" rel="nofollow">https:&#x2F;&#x2F;store.steampowered.com&#x2F;app&#x2F;576030&#x2F;MHRD&#x2F;</a>
newman8rover 4 years ago
this is fun. When I got to the multi-bit-adder I think the half adder was removed from the toolbox though and replaced with the full adder - would be nice to keep it there.
zug_zugover 4 years ago
There&#x27;s a very similar game(text-based) called MHRD
tunesmithover 4 years ago
Nicely done! If the author is reading, care to share any details on what stack or libraries were used?
评论 #25286906 未加载
mikewarotover 4 years ago
That was a fun diversion, thanks!
signaruover 4 years ago
it would be cool (ambitious) if at some point there is also a programming language&#x2F;compiler down the line. perhaps it can would also be able to run tetris or even another nandgame.
berkserbetover 4 years ago
Really cool, curious to see how hard it gets. Reminds me of college.
评论 #25285473 未加载
评论 #25282994 未加载
hnickover 4 years ago
Thank you for showing me how much I have forgotten in 15 years :)
DNiedover 4 years ago
I wish Pure Data had a GUI like that. Hats off to the author.
mtoner23over 4 years ago
I&#x27;m a simple man. i see NandGame i upvote
blackrockover 4 years ago
I wonder when we can start 3D printing our own resistors and transistors.
评论 #25282765 未加载
评论 #25282703 未加载
评论 #25287954 未加载
评论 #25283565 未加载
评论 #25284057 未加载
LeonBover 4 years ago
Should start from physics building up and up until you have subatomic particles, rising through many layers of abstraction until you are doping P and N type semiconductors .... starting with such a high level concept as “nand gates” is far too easy. &#x2F;sarcasm.parody
评论 #25283664 未加载
评论 #25289054 未加载
评论 #25285563 未加载
评论 #25289024 未加载
评论 #25296512 未加载
评论 #25289021 未加载