Traffic Light with Emergency Preemption
City intersections and transit corridors rely on priority interrupts to clear traffic for emergency vehicles. The combinational logic of a traffic controller determines the next state and active lights based on the current state, a timer, and an emergency override signal.
The system uses a 2-bit state encoding: Green (00), Yellow (01), and Red (10). State 11 is invalid and must default to Red. Under normal operation, the system advances to the next state when T (timer done) is 1. When E (emergency) is 1, the system must safely transition to Red. If the current state is Green, it must transition to Yellow first. If the current state is Yellow or Red, it transitions to or stays in Red, overriding the timer.
| S1 | S0 | T | E | N1 | N0 | R | Y | G | |------|------|-----|-----|------|------|-----|-----|-----| | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 0 |
Constraints
- Implement combinational logic only.
- Do not use sequential elements or flip-flops.
- Force the next state to Red (
10) for the invalid state11regardless of input conditions.
Topics
Solve this problem
Place the gates, wire them up and watch the signals settle. Every submission runs on the same simulation engine that grades it.
This problem is part of Codiode Pro. The statement above is free to read.
The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.