Challenge - 5 Problems
Verilog Simulation vs Synthesis Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateSimulation output of non-blocking assignments
What is the output of the following Verilog simulation code snippet?
Verilog
module test;
reg a, b;
initial begin
a = 0;
b = 0;
a <= 1;
b <= a;
#1;
$display("a=%b b=%b", a, b);
end
endmoduleAttempts:
2 left
💡 Hint
Remember that non-blocking assignments update at the end of the time step.
✗ Incorrect
In simulation, non-blocking assignments (<=) schedule updates to happen after all right-hand sides are evaluated. So 'b <= a;' uses the old value of 'a' (which is 0), so b becomes 0, while a becomes 1.
❓ Predict Output
intermediateSynthesis behavior of blocking assignments
What is the synthesized hardware behavior of this Verilog always block?
Verilog
always @(posedge clk) begin a = b; c = a; end
Attempts:
2 left
💡 Hint
Consider how blocking assignments execute sequentially inside always blocks.
✗ Incorrect
Blocking assignments (=) execute in order. So 'a = b;' updates 'a' immediately, then 'c = a;' uses the new 'a' value. Synthesized hardware will have registers for 'a' and 'c', with 'c' getting the updated 'a' value.
🧠 Conceptual
advancedDifference between simulation and synthesis for delays
Which statement correctly describes how delays (#) are treated in simulation vs synthesis?
Attempts:
2 left
💡 Hint
Think about what delays mean in real hardware vs simulation.
✗ Incorrect
Delays (#) are simulation-only constructs to model timing. Synthesis tools ignore them because real hardware timing depends on physical properties, not code delays.
❓ Predict Output
advancedSimulation output with mixed blocking and non-blocking assignments
What is the output of this Verilog simulation code?
Verilog
module test;
reg x, y;
initial begin
x = 0; y = 0;
x = 1;
y <= x;
#1;
$display("x=%b y=%b", x, y);
end
endmoduleAttempts:
2 left
💡 Hint
Blocking assignments update immediately, non-blocking update later.
✗ Incorrect
The blocking assignment 'x = 1;' updates x immediately to 1. The non-blocking 'y <= x;' schedules y to update after the time step using the current x (which is now 1). So y becomes 1 at display time.
🧠 Conceptual
expertWhy some Verilog constructs simulate but do not synthesize
Which reason best explains why some Verilog code runs in simulation but cannot be synthesized?
Attempts:
2 left
💡 Hint
Think about the difference between describing behavior and describing hardware.
✗ Incorrect
Simulation can run code that models behavior with constructs like delays, file I/O, or infinite loops, which do not correspond to physical hardware and thus cannot be synthesized.
