The fix is, replace the level trigger latches with edge trigger flip flops.
- The issue occurs because the circuit uses a D latch, which is a level-triggered device.
- The push button is connected to the Enable input of the D latch.
- When the button is held down, the latch remains transparent.
- During this time, the up-counter continues counting with every clock pulse.
- Hence, the latch continuously stores the changing counter values instead of a single value.
- The final stored number is the value present when the button is released, not when it was first pressed.
- Modify only the D latch section of the circuit.
- Replace the D latch with a positive edge-triggered D flip-flop. Flip Flops have ">" input instead of "IE".
- The flip-flop captures the counter value only at the rising edge of the button signal.
- Therefore, only one number is stored per button press, irrespective of how long the button is held.
- Result: The game now correctly records a single random hex number for every button press.