Live data from Hacker News

NandGame – Build a Computer from Scratch

nandgame.com

121–130 of 141 posts

Re: NandGame – Build a Computer from Scratch

#121
post #93
post #88

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.

Author here: The reason you drag from the input rather than output is that a pin can have only one input.

Please ignore. It was completely tongue-in-cheek. Great idea and implementation.

Re: NandGame – Build a Computer from Scratch

#122

I know digital logic, yet was perplexed by the odd definition of D flip-flop this game uses with both "store" and "clock" inputs, which matches none of the standard variants of DFFs: https://en.wikipedia.org/wiki/Flip-flop_(electronics)#D_flip... 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 latch…

Yeah. The flip flop, and its corresponding register version would be a DFF with enable pin. That is not actually too abnormal. The traditional implementation is taking a normal DFF and adding the enable feature either by gating the clock or by adding a mux in the input path, that uses the enable signal to select between the input or the existing output.

Re: NandGame – Build a Computer from Scratch

#123
post #63

Not that this will ever matter for someone who isn't a circuit designer, but the "optimal" solution for the latch is actually really bad. If you use a "select" block (which should really be called "mux") 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…

Since the latch is only used as a component of the flip-flip and edge sensitive logic does not care about glitches except on the clock line or any asynchronous set/resets (which are not used in this design) I find that rather unimportant. Especially because the d-flipflops found in standard cell libraries are frequently implemented as what amounts to two muxes and some inverters. For a design that uses latches as sta…

In practical designs, flip flop outputs are regularly used as clock inputs and asynchronous set/reset inputs. If you used this latch as the output latch in a flip flop, it would glitch on the falling edge of the flip flop clock.

I didn't go through the entire game, so its entirely possible that it would not affect this particular "design". But as its far more educational than practical, I think its still worth mentioning.

> Especially because the d-flipflops found in standard cell libraries are frequently implemented as what amounts to two muxes and some inverters.

I'm curious where you've seen that implementation because I've never seen anything like that. Most of what I've seen uses two tri-state inverter latches.

Re: NandGame – Build a Computer from Scratch

#124
post #91

Nicely done! If the author is reading, care to share any details on what stack or libraries were used?

Author here - It uses TypeScript and the Angular framework. Not because I prefer Angular in particular but because I had to learn it anyway for a work-related project. I think TypeScript is great.

It looks like it is more canvas than svg, yes? Was there a particular canvas library that you used? I ask because I'm working on a side project that feels like it mostly pulls me in an svg direction, so I'm been prototyping with dagrejs and cytoscape.js, but it also has elements of creating (or dragging, like yours) new elements into a graph and connecting them, so I'm regularly torn when deciding on the basic architecture of it.

Re: NandGame – Build a Computer from Scratch

#125
post #123

Earlier quoted context omitted.

Since the latch is only used as a component of the flip-flip and edge sensitive logic does not care about glitches except on the clock line or any asynchronous set/resets (which are not used in this design) I find that rather unimportant. Especially because the d-flipflops found in standard cell libraries are frequently implemented as what amounts to two muxes and some inverters. For a design that uses latches as sta…

In practical designs, flip flop outputs are regularly used as clock inputs and asynchronous set/reset inputs. If you used this latch as the output latch in a flip flop, it would glitch on the falling edge of the flip flop clock. I didn't go through the entire game, so its entirely possible that it would not affect this particular "design". But as its far more educational than practical, I think its still worth mentio…

Not the one you're replying to, but look up "transmission gate latch". As for an actual processor that uses them, see the RCA CDP1802, for which a die photo and reverse engineered gate-level schematic are available.

Re: NandGame – Build a Computer from Scratch

#126
post #123

Earlier quoted context omitted.

In practical designs, flip flop outputs are regularly used as clock inputs and asynchronous set/reset inputs. If you used this latch as the output latch in a flip flop, it would glitch on the falling edge of the flip flop clock. I didn't go through the entire game, so its entirely possible that it would not affect this particular "design". But as its far more educational than practical, I think its still worth mentio…

Not the one you're replying to, but look up "transmission gate latch". As for an actual processor that uses them, see the RCA CDP1802, for which a die photo and reverse engineered gate-level schematic are available.

Ah. Duh. I was thinking static cmos logic/nand gate mux in my head, probably because that's how you build it in the game.

Definitely have seen tgate flip flops. They seem to be less in fashion now though I'm not exactly sure why.

Re: NandGame – Build a Computer from Scratch

#129
post #92

Building circuits is neat, but I think this has some problems as a game: 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. 2. It's not really clear how NAND gate counts work in later levels where you're using potentially non-optimal components you've built? Like does it count each…

Author here - thank you for the feedback! The nand-count is based on how you built the components involved. So optimizing a component will have have cascading effects. "This is the simplest solution!" means the solution with fewest individual components on the canvas. I realize the text could be clearer.

Love the game. One suggestion I had is that it would be helpful to indicate the number of nand gates in each component. When I'm trying to optimize I'm also trying to remember which is a "cheaper" component - having a number of nand gates associated with each component would help.

Re: NandGame – Build a Computer from Scratch

#130
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'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.
Post reply on HN