Level 22: Bus Conflict

Open the level →

Task

Fix the data bus conflict: RAM and Gamepad both drive the bus. Add AddrDecoder and BusAND to gate the RAM output.

When two devices (RAM and Gamepad) share the data bus, a CONFLICT occurs: both try to output data simultaneously.

Related Materials

Solution

The data bus is a bundle of copper wires where only one device may "shout" at a time. If RAM and the gamepad drive the bus simultaneously, that is a short circuit: the signals physically fight on the wires. BusAND fixes it electrically: it "mutes" the inactive device by ANDing its data with a zero mask — silence reaches the bus.

AddrDecoder solves this: - Addresses 0–223 (0x00–0xDF) → RAM (RAM_SEL=1) - Addresses 224–255 (0xE0–0xFF) → I/O devices (IO_SEL=1)

AddrDecoder outputs two signals: - RAM_SEL8 (bus8) — mask for RAM data (0xFF when RAM, 0x00 when I/O) - IO_SEL (bit) — I/O port access flag

Tasks: 1. BusConstant = 2 → PC.Inc. 2. ROM#1 → RAM.Addr. 3. ROM#1 → AddrDecoder.Addr (so the decoder knows which address is being accessed). 4. Connect data bus to ALU8.B: RAM.DataOut → BusAND.A, AddrDecoder.RAM_SEL8 → BusAND.B, then BusAND.Q → BusOR, then to ALU8.B.

This cascade (RAM → BusAND → BusOR) masks RAM data when the address belongs to an I/O device — resolving the bus conflict.

Assembler help →

Solution circuit for level 22 — Bus Conflict
The authored solution for level 22 in the simulator (dark theme)