CodiodeCodiode
Home
Problem Solving
Skill Tracks
My Assignments
Contests
Leaderboard
Community
Settings
Codiode/Problems/Combinational Logic

Traffic Light with Emergency Preemption

HardLogic CircuitBuild

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 state 11 regardless of input conditions.

Topics

fsmpriority-encoderlogic-design

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.

Sign in to solveSee what Pro unlocks

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.

Related problems

  • Binary to HexEasy
  • 1-to-4 Demultiplexer from AND and NOT GatesEasy
  • 2-to-4 Line Decoder with Active-High EnableEasy
  • Hex Nibble to BinaryEasy
  • Odd Parity Bit Generator for 3-bit DataEasy
  • Full Adder from Half AddersEasy
  • Modulo ArithmeticMedium
  • Two's Complement: Encode a Negative DecimalEasy

Browse all problems · Learning tracks