Challenge - 5 Problems
Clock Domain Crossing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of a simple synchronizer module
What is the output of the following Verilog code after 3 clock cycles of clk2, assuming async_signal changes from 0 to 1 at the start?
Verilog
module synchronizer( input wire clk2, input wire async_signal, output reg sync_signal ); reg sync_1; always @(posedge clk2) begin sync_1 <= async_signal; sync_signal <= sync_1; end endmodule
Attempts:
2 left
💡 Hint
Think about how the two-stage synchronizer delays the async signal by two clock cycles.
✗ Incorrect
The two flip-flops in series delay the async_signal by two clk2 cycles before sync_signal reflects the change, so sync_signal becomes 1 after 2 cycles.
🧠 Conceptual
intermediateIdentifying metastability risk
Which of the following signals is at risk of metastability in a clock domain crossing scenario?
Attempts:
2 left
💡 Hint
Metastability occurs when a signal changes close to the clock edge without proper synchronization.
✗ Incorrect
Sampling an asynchronous signal directly without synchronization flip-flops risks metastability because the flip-flop input may change near the clock edge.
🔧 Debug
advancedDebugging a CDC handshake failure
Given the following handshake signals crossing from clk1 to clk2 domain, what is the main cause of failure?
Verilog
module handshake( input wire clk1, input wire clk2, input wire req_clk1, output reg ack_clk2 ); reg req_sync1, req_sync2; always @(posedge clk2) begin req_sync1 <= req_clk1; req_sync2 <= req_sync1; ack_clk2 <= req_sync2; end endmodule
Attempts:
2 left
💡 Hint
Consider what happens to flip-flops without reset at startup.
✗ Incorrect
Without reset, the flip-flops may start in unknown states causing handshake failure even if synchronization is correct.
📝 Syntax
advancedIdentify the syntax error in CDC synchronizer code
Which option contains a syntax error in this CDC synchronizer code snippet?
Verilog
always @(posedge clk) begin sync_1 <= async_signal; sync_2 <= sync_1 end
Attempts:
2 left
💡 Hint
Check each line for proper statement termination.
✗ Incorrect
The line 'sync_2 <= sync_1' is missing a semicolon at the end, causing a syntax error.
🚀 Application
expertDesigning a safe pulse synchronizer
You need to safely transfer a single-cycle pulse from clk1 domain to clk2 domain without missing or duplicating pulses. Which design approach is correct?
Attempts:
2 left
💡 Hint
Think about how to convert a pulse into a level signal that can be safely synchronized.
✗ Incorrect
A toggle flip-flop changes state on each pulse in clk1 domain; the clk2 domain detects edges of this toggle signal after synchronization, ensuring no pulses are missed or duplicated.
