2 7 Segment Life
2 : 7 Segment Life
- Author: icegoat9
- Description: Simple 7-segment cellular automaton
- GitHub repository
- Most recent GDS build
- Wokwi project
- Extra docs
- Clock: 6250 Hz
- External hardware: None. Could add debounced momentary pushbuttons in parallel with dip switches 1,2,3 to make loading in new patterns and stepping through a run easier.
How it works
This implements a very simple 7-segment cellular automaton from ~200 basic logic gates. At each clock cycle, each of the seven segments is set to “alive” or “dead” based on a simple set of rules:
- If a segment was “alive” in the previous time step and has exactly one living neighbor, it survives.
- If a segment was “dead” (or “empty”) in the previous time step and has exactly two living neighbors, if becomes alive (“gives birth”)
A “neighbor” is any segment it touches, tip to tip. This means that the top and bottom segments only have two neighbors, while the side segments have three neighbors and the center segment has four neighbors.
See the Wokwi gate layout and simulation. At a high level:
- Seven flip-flops hold the cellular automaton’s internal state, which is also wired to the seven-segment display.
- Combinatorial logic generates the next state for each segment based on its neighbors.
- When either the system clock or a user-toggled clock input goes high, this new state is latched in to the flip-flips.
- There’s minor additional support logic to let the user manually shift in an initial condition and handle clock dividing.
How to test
For full details with some examples, see the github README doc link. At a high level, assuming the IC is mounted on the standard tinytapeout PCB which provides dip switches, clock, and a seven-segment display for output:
- Set all dip switches off, and the clock slide switch to the ‘manual’ clock side.
- Power on the system. An arbitrary state may appear on the 7-segment display.
- Set dip switch 4 on (‘run mode’).
- Toggle dip switch 1 on and off to advance the automaton to the next state, you should see the 7-segment display update.
If you want to watch it run automatically (which may quickly settle on an empty state or a static pattern, depending on start state):
- Set the PCB clock divider to the maximum clock division (255). With a system clock of 6.25kHz, the clock input should now be ~24.5Hz.
- Set dip switches 5 and 7 on to add an additional 16x clock divider.
- Set dip switch 4 on.
- Switch the clock slide switch to the ‘system clock’ side. The display should advance at roughly 1.5Hz (if I’ve done math correctly)
- To run faster or slower, set a combination of dip switches 5 (8x clock divider), 6 (4x divider), and 7 (2x divider)
If you want to load a custom initial state:
- Set dip switch 4 off (’load mode’).
- Toggle dip switches 2 and/or 3 on and off up to seven times total, to shift in 0 and 1 values to the automaton’s internal state (see github README for examples).
- Set dip switch 4 on and run manually or automatically as above.
Exercises / puzzles for the reader:
- How many unique initial states are there, disregarding equivalent mirrored/rotated states? (there are 2^7 = 128 possible initial states, but many are equivalent)
- What fraction of these initial states survive? (i.e. don’t eventually die out)
- What fraction settle into a static living pattern vs an infinite cycle between multiple different patterns?
- What is the longest sequence of unique states a pattern travels through (stop counting once it reaches a previously-visited state, beginning an infinite loop)?
- What is the longest cycle of unique states that repeats in a loop?