Challenge - 5 Problems
Synchronizer Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of a simple 2-flip-flop synchronizer
Consider this Verilog code for a 2-flip-flop synchronizer. What is the output value of
sync_out after 3 clock cycles if the asynchronous input async_in is held high from the start?module sync(input clk, input async_in, output reg sync_out);
reg ff1;
always @(posedge clk) begin
ff1 <= async_in;
sync_out <= ff1;
end
endmoduleVerilog
module sync(input clk, input async_in, output reg sync_out); reg ff1; always @(posedge clk) begin ff1 <= async_in; sync_out <= ff1; end endmodule
Attempts:
2 left
💡 Hint
Think about how the input propagates through two flip-flops on each clock edge.
✗ Incorrect
The first flip-flop captures the async input on the first clock edge, and the second flip-flop captures the output of the first on the next clock edge. After 2 clock cycles, sync_out will reflect the stable input value 1.
🧠 Conceptual
intermediateCause of metastability in synchronizers
What is the primary cause of metastability in a flip-flop synchronizer circuit?
Attempts:
2 left
💡 Hint
Metastability happens when timing requirements are violated at the flip-flop input.
✗ Incorrect
Metastability occurs when the input changes close to the clock edge, violating the setup or hold time, causing the flip-flop output to become unpredictable temporarily.
🔧 Debug
advancedIdentify the bug causing metastability risk
This Verilog code attempts to synchronize an asynchronous input but still risks metastability. What is the bug?
module sync_bug(input clk, input async_in, output reg sync_out);
reg ff;
always @(posedge clk) begin
ff <= async_in;
sync_out <= async_in;
end
endmoduleVerilog
module sync_bug(input clk, input async_in, output reg sync_out); reg ff; always @(posedge clk) begin ff <= async_in; sync_out <= async_in; end endmodule
Attempts:
2 left
💡 Hint
Check which signal sync_out depends on inside the clocked block.
✗ Incorrect
sync_out should be assigned from the synchronized register ff, not directly from async_in, to reduce metastability risk.
📝 Syntax
advancedSyntax error in synchronizer module
Which option contains a syntax error in this synchronizer Verilog code snippet?
module sync(input clk, input async_in, output reg sync_out);
reg ff1, ff2;
always @(posedge clk) begin
ff1 <= async_in;
ff2 <= ff1;
sync_out <= ff2;
end
endmoduleAttempts:
2 left
💡 Hint
Check for missing punctuation or keywords in module declaration.
✗ Incorrect
Option C is missing a semicolon after the module declaration line, causing a syntax error.
🚀 Application
expertCalculate Mean Time Between Failures (MTBF) for synchronizer
Given a synchronizer with a clock frequency of 100 MHz, a resolution time constant (tau) of 0.1 ns, and a setup time window (Tsetup) of 0.5 ns, what is the approximate MTBF in seconds? Use the formula:
Choose the closest value.
MTBF = exp(Tsetup / tau) / (clock_freq * Tsetup)
Choose the closest value.
Attempts:
2 left
💡 Hint
Calculate exp(0.5/0.1) = exp(5) first, then divide by (100e6 * 0.5e-9).
✗ Incorrect
exp(5) ≈ 148.41; clock_freq * Tsetup = 100e6 * 0.5e-9 = 0.05; MTBF ≈ 148.41 / 0.05 = 2968.2 seconds. Rechecking calculation: Actually, clock_freq * Tsetup = 100e6 * 0.5e-9 = 0.05, so MTBF = 148.41 / 0.05 = 2968.2 seconds. The closest option is A (1.48e+06) is incorrect, correct is about 2.97e+03 seconds. So option D is correct. Adjusting answer accordingly.
