Level 26: Dice Roll
Open the level →Where it fits in the machine →
Task
Goal: The LFSR is already on the canvas — connect its output to the data bus via the second BusOR (BusOR#1 output → BusMUX).
LFSR (Linear Feedback Shift Register) — pseudo-random number generator. Accessible via port 250 (0xFA).
The main idea: randomness in a machine is not random: an LFSR is a register with a shift and feedback, its sequence is deterministic and repeats after a huge period. The second BusOR adds a third source to the bus, following the rule of level 22.
Related Materials
- LFSR: random number generator
- AddrDecoder: address decoder
Solution for self-check
Try building the circuit yourself first. The solution below is a way to check yourself if you're stuck or have already solved it.
What you should get: the LFSR drives a new number onto the bus at port address 250 — LDA 0; ADD 250 reads it.
Each tick, LFSR outputs a new 8-bit "random" number on the data bus, if: - IO_SEL = 1 (address in I/O range: 224–255) - DevAddr = 0x1A (26 = LFSR port, 250 & 0x1F)
Tasks: 1. BusConstant = 2 → PC.Inc. 2. ROM#1 → RAM.Addr. 3. Connect LFSR.Data to the data bus via the SECOND BusOR: - First BusOR already joins RAM (via BusAND) and Gamepad. - Second BusOR (pre:BusOR#1) needs connection: first BusOR output → BusOR#1.A, LFSR.Data → BusOR#1.B. - BusOR#1 output goes to BusMUX (then to ALU8.B).
Now all three sources (RAM, Gamepad, LFSR) are correctly multiplexed onto the data bus via AddrDecoder.
Check yourself
Why are LFSR numbers called pseudo-random?
The sequence is deterministic and repeats after a huge period (255 ticks for a non-zero seed) — it just looks random.