Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Digital Logic Sim

​A minimalistic digital logic simulator · By Sebastian Lague

How do you make a system that counts up?

A topic by Rando2048 created May 08, 2025 Views: 340 Replies: 9
Viewing posts 1 to 2

I've been trying to work on a setup that counts up, but I always run into issues. Does anyone have anything?

(1 edit)

I built mine following Ben Eater's tutorials:
https://www.youtube.com/playlist?list=PLowKtXNTBypGqImE405J2565dvjafglHU

Start at video #24, the JK Flip Flop.

My JK Flip Flop isn't working because it rapidly flips between the two outputs, which I assume to be caused by it taking multiple steps to perform a NOR operation, but only one to transmit the signal.

Can you explain your problem to me? Is it an endless loop caused by updating the input to the output's change and changing the output by doing so? Because in this case you Just need a D Latch at the end, that updates, when the clock signal is high and a D Latch at the beginning, that feeds the new state into the curcuit, whenever the clock signal is low. Then you can output the signal of the last D Latch and it should work. Did I understand your problem right? The image shows a simplified working T Flip Flop.

Does it work now?

The only thing that I can get anything to do consistently is flip extremely fast from on to off. The problem, guaranteed, is purely in the two NOR gates at the end.

(1 edit)

Figure-1: J-K FLIP FLOP

Figure-2: D FLIP FLOP 

(1 edit)

You have to restrict the updates, that happen, so it doesn‘t do an endless loop of updating. It’s like a door, where only one is going to be open at a time. It‘s like these doors from the zoo so the tigers don’t escape. Build some working D Latches and use them as caches, so the inputs don‘t immediatly update when the output changes. And when the input changes to the output don‘t update the output until the input doesn‘t change anymore. This way you react to an edge only once. Try building it this way. If you need help with the D Latches tell me. By chaining these together you should be able to count up.

How do you restrict the updates?

(1 edit)

By only having one D Latch open at a time.