Level 22: Bus Conflict

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.

Solution

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 →