World Cup Final

Problem Description

India is defending a low total in the World Cup Final. The stadium uses a Distributed Sensor Network (Ball-tracking, Ultra-edge, and Speed-gun). As the lead architect, you must design a Central Processing Hub (CPH) that aggregates asynchronous data from these sensors and updates the scoreboard in real-time.

The Architectural Challenge

You are designing a Data Pipeline that bridges two separate clock domains: the Sensor Clock (s_clk) and the System/Display Clock (m_clk).

1. The Input Interface (Sensor Domain - s_clk)

The system receives a 16-bit packet from the sensor bus:

  • [15:13]: Packet Header (Must be 3'b101 to be valid).

  • [12:10]: Event Type (0: Dot, 1-6: Runs, 7: Wicket).

  • [9]: Extra Flag (1: Wide/No-ball).

  • [8]: Review Flag (1: Event is "Under Review").

  • [7:0]: Checksum (Reduction XOR of bits [15:8]).

2. Architecture Requirements

  • Asynchronous FIFO: Move data from the 50MHz s_clk domain to the 25MHz m_clk domain using Gray-coded pointers to prevent metastability.

  • Review Logic (Shadow Register): If the Review Flag is high, the score and balls count must be stored in a Shadow Register.

    • If review_clear is asserted, add the shadow score to the total_score.

    • If review_overturn is asserted, discard the shadow event.

  • Over-Limit & Strike Logic:

    • Strike Rotation: Toggle current_striker if an odd number of runs (1, 3, 5) are scored.

    • Over Change: At the end of 6 legal deliveries (excluding extras), toggle current_striker and reset balls_in_over.

3. Module Port List

Port Name

Direction

Width

Description

s_clk

Input

1

Sensor Clock (50MHz)

s_rst_n

Input

1

Active-low Reset (Sensor Domain)

s_packet

Input

16

16-bit Sensor Data Packet

s_packet_vld

Input

1

High when s_packet is valid

m_clk

Input

1

Display/System Clock (25MHz)

m_rst_n

Input

1

Active-low Reset (Display Domain)

review_clear

Input

1

Pulse high to confirm a DRS review

review_overturn

Input

1

Pulse high to cancel a DRS review

total_score

Output

10

Cumulative runs scored

current_striker

Output

1

0 or 1, representing the active batsman

pending_review

Output

1

High when data is in the Shadow Register

balls_in_over

Output

3

Legal balls bowled (0 to 5)

error_flag

Output

1

High for 1 cycle if Checksum fails

Verilog

Code Editor Access

Log in to write, run and submit your solution to this interview question. It's free.

Output

Output goes here...