Challenge - 5 Problems
Initial Block Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateWhat is the output of this initial block?
Consider the following Verilog code snippet. What will be the value of
signal after the initial block finishes?Verilog
module test;
reg signal;
initial begin
signal = 0;
#5 signal = 1;
#10 signal = 0;
end
endmoduleAttempts:
2 left
💡 Hint
Think about the delays and the last assignment in the initial block.
✗ Incorrect
The initial block sets signal to 0, then after 5 time units sets it to 1, then after 10 more time units sets it back to 0. The final value after the initial block completes is 0.
❓ Predict Output
intermediateWhat is the value of
count after this initial block?Analyze this Verilog code. What value does
count hold at the end of the initial block execution?Verilog
module test; reg [3:0] count; initial begin count = 4'b0000; #2 count = count + 1; #3 count = count + 2; end endmodule
Attempts:
2 left
💡 Hint
Add the increments step by step considering the delays.
✗ Incorrect
Initially count is 0. After 2 time units, count becomes 1. After 3 more time units, count becomes 3 (1 + 2).
🔧 Debug
advancedWhat error does this initial block cause?
Examine this Verilog code. What error will occur when simulating this initial block?
Verilog
module test;
reg clk;
initial begin
clk = 0;
#5 clk = 1;
end
endmoduleAttempts:
2 left
💡 Hint
Check the line endings carefully.
✗ Incorrect
The first assignment line is missing a semicolon, causing a syntax error.
🧠 Conceptual
advancedWhich statement about initial blocks is true?
Select the correct statement about the behavior of initial blocks in Verilog.
Attempts:
2 left
💡 Hint
Think about when initial blocks execute in simulation.
✗ Incorrect
Initial blocks run once at simulation start to provide stimulus or initialization. They do not loop or depend on clock edges and are generally not synthesizable.
❓ Predict Output
expertWhat is the final value of
data after this initial block?Consider this Verilog code with multiple delays and assignments. What is the final value of
data after the initial block completes?Verilog
module test; reg [7:0] data; initial begin data = 8'hFF; #3 data = data >> 1; #2 data = data & 8'h0F; #1 data = data + 8'h01; end endmodule
Attempts:
2 left
💡 Hint
Calculate each step carefully considering bitwise operations and delays.
✗ Incorrect
Initially, data = 8'hFF. After 3 time units, data = 8'hFF >> 1 = 8'h7F. After 2 more time units, data = 8'h7F & 8'h0F = 8'h0F. After 1 more time unit, data = 8'h0F + 8'h01 = 8'h10.
