Part of Curriculum: Verilog Fundamentals (Module 1: Fun & Games)
View Full Roadmap →
Level 2 Medium 25 pts ✓ Solved

Rock Paper Scissors Lizard Spock

Fun & Games · combinational, game-logic

Judge a round of the 5-way expanded rock-paper-scissors from The Big Bang Theory — each move beats exactly two of the other four, so the usual 3-way rule table isn't enough.

Write a synthesizable Verilog module named top_module matching the ports below exactly.
📐 Circuit Schematic Diagram
p1[2:0]p2[2:0]winner[1:0]ROCK PAPER SCISSORS DIGITAL HARDWARE BLOCK
⚡ Timing & Synthesizability Constraints

Timing Contract: Strict synchronous timing aligned to posedge clk or zero-delay combinational propagation.

RTL Constraints: Synthesizable Verilog-2001. No # delays in synthesizable RTL.

Concept: Encode each player's move as 0=Rock, 1=Paper, 2=Scissors, 3=Lizard, 4=Spock. Every move beats exactly two others (Rock beats Scissors and Lizard; Paper beats Rock and Spock; Scissors beats Paper and Lizard; Lizard beats Spock and Paper; Spock beats Scissors and Rock) — so the cleanest implementation is a direct lookup of p1's beats-list against p2, then the reverse check if that fails. A single wrong entry in that beats-list (say, listing Paper instead of Scissors as one of Rock's victims) is a real, easy-to-make copy-paste slip — it still compiles and handles most matchups correctly, but silently flips the outcome for that one specific matchup.
NameDirWidthDescription
p1input3Player 1's move (0=Rock,1=Paper,2=Scissors,3=Lizard,4=Spock)
p2input3Player 2's move, same encoding
winneroutput20=tie, 1=player 1 wins, 2=player 2 wins
Expected Waveform (Golden Timing Contract)
Verilog-2001 / SV Saved
Font: |
// Click Run Tests (or press Ctrl+Enter) to compile your RTL and simulate against hidden testbenches.
Simulation Timing Diagram (VCD Waveform)
100%
No simulation waveform yet. Run tests to simulate and generate VCD traces.
No compilation run yet. Syntax warnings and elaboration messages will appear here.
No simulation output yet. Raw stdout from vvp will appear here.

RTL Problems / Level 2 · Fun & Games

What You Will Learn

By solving Rock Paper Scissors Lizard Spock, you will acquire core industry skills:

  • Synthesizable hardware modeling in standard Verilog-2001 / SystemVerilog.
  • Correct handling of interface port contracts, edge-triggered clocks, and active-low/high resets.
  • Simulation waveform interpretation and debugging using timing diagrams (VCD traces).
  • Architectural avoidance of timing violations, glitching hazards, and synthesis warnings.

Problem Statement & Requirements

Judge a round of the 5-way expanded rock-paper-scissors from The Big Bang Theory — each move beats exactly two of the other four, so the usual 3-way rule table isn't enough.

Hardware design teams at leading semiconductor firms evaluate these exact port contracts, race-condition assertions, and corner cases during technical design reviews and ASIC engineer interviews.

Concept: Encode each player's move as 0=Rock, 1=Paper, 2=Scissors, 3=Lizard, 4=Spock. Every move beats exactly two others (Rock beats Scissors and Lizard; Paper beats Rock and Spock; Scissors beats Paper and Lizard; Lizard beats Spock and Paper; Spock beats Scissors and Rock) — so the cleanest implementation is a direct lookup of p1's beats-list against p2, then the reverse check if that fails. A single wrong entry in that beats-list (say, listing Paper instead of Scissors as one of Rock's victims) is a real, easy-to-make copy-paste slip — it still compiles and handles most matchups correctly, but silently flips the outcome for that one specific matchup.

Port List & Interface Timing

The hidden testbench instantiates top_module. Module port names and bit-widths must match the interface contract exactly:

NameDirWidthDescription
p1input3Player 1's move (0=Rock,1=Paper,2=Scissors,3=Lizard,4=Spock)
p2input3Player 2's move, same encoding
winneroutput20=tie, 1=player 1 wins, 2=player 2 wins

Timing Constraints & Synthesizable RTL Rules

⚡ Synthesizable Implementation Guidelines

Timing Contract: Strict synchronous timing aligned to posedge clk or zero-delay combinational propagation.

Synthesis Constraints: Synthesizable Verilog-2001. No # delays in synthesizable RTL.

Starter RTL Code

module top_module(
  input  [2:0] p1,
  input  [2:0] p2,
  output [1:0] winner
);

  // Your code here — 0=Rock,1=Paper,2=Scissors,3=Lizard,4=Spock.
  // Each move beats exactly two others. winner: 0=tie, 1=p1 wins, 2=p2 wins.

endmodule

Related RTL Problems in Level 2

Frequently Asked Questions

What does Rock Paper Scissors Lizard Spock require?

Judge a round of the 5-way expanded rock-paper-scissors from The Big Bang Theory — each move beats exactly two of the other four, so the usual 3-way rule table isn't enough. Implement it as Verilog module top_module matching the listed ports.

Is this design combinational or sequential?

Tags: combinational, game-logic. If a clock signal is present in the port table, implement it as sequential logic; otherwise, use continuous assignments or combinational blocks.

How is my solution graded?

A hidden SystemVerilog testbench simulates your module in the cloud judge. You pass when all directed corner cases match the golden model and the VCD timing waveform matches the contract.

How does this challenge help with semiconductor interviews?

Technical interviewers at NVIDIA, Qualcomm, Apple, and Intel routinely ask candidates to code, debug, and explain the timing waveforms of Rock Paper Scissors Lizard Spock to assess real-world synthesizability and race-condition awareness.