Challenge - 5 Problems
Testbench Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of a simple testbench module
What is the output of this Verilog testbench when simulated?
Verilog
module tb(); reg clk = 0; initial begin $display("Start simulation"); #5 clk = 1; #5 clk = 0; $display("End simulation"); $finish; end endmodule
Attempts:
2 left
💡 Hint
Look at the $display statements and the delays.
✗ Incorrect
The testbench prints 'Start simulation' immediately, then after 10 time units prints 'End simulation' before finishing.
🧠 Conceptual
intermediatePurpose of initial and always blocks in testbench
In a Verilog testbench, what is the main difference between an initial block and an always block?
Attempts:
2 left
💡 Hint
Think about how simulation time flows and how these blocks behave.
✗ Incorrect
Initial blocks execute once at simulation start. Always blocks loop forever, reacting to events or delays.
🔧 Debug
advancedIdentify the error in this testbench module
What error will this Verilog testbench code cause when simulated?
Verilog
module tb();
reg clk;
initial begin
clk = 0;
forever #5 clk = ~clk;
end
initial begin
#20 $finish;
end
endmoduleAttempts:
2 left
💡 Hint
Check how 'forever' and multiple initial blocks behave.
✗ Incorrect
Multiple initial blocks are allowed. 'forever' loops inside initial block. The second initial block ends simulation after 20 units.
📝 Syntax
advancedWhich testbench code snippet has a syntax error?
Identify the code snippet that will cause a syntax error in Verilog testbench.
Attempts:
2 left
💡 Hint
Look carefully for missing semicolons or keywords.
✗ Incorrect
Option B misses a semicolon after 'clk = 0' causing syntax error.
🚀 Application
expertNumber of clock cycles generated by this testbench
How many complete clock cycles does this testbench generate before finishing?
Verilog
module tb(); reg clk = 0; initial begin forever #3 clk = ~clk; end initial begin #30 $finish; end endmodule
Attempts:
2 left
💡 Hint
Calculate clock period and total simulation time.
✗ Incorrect
Clock toggles every 3 time units, so period is 6 units. Simulation ends at 30 units. 30/6 = 5 cycles.
