Challenge - 5 Problems
Clock Signal Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateWhat is the output waveform behavior of this clock generator?
Consider this Verilog testbench snippet that generates a clock signal. What is the frequency of the clock signal produced?
reg clk = 0; always #5 clk = ~clk;
Verilog
reg clk = 0; always #5 clk = ~clk;
Attempts:
2 left
💡 Hint
The clock toggles every 5 time units, so a full cycle is twice that.
✗ Incorrect
The clock toggles every 5 time units, so one full period is 10 time units. Frequency is 1/period = 1/10 = 0.1 units^-1. This matches option A.
❓ Predict Output
intermediateWhat is the initial value of clk after this testbench code runs?
Given this Verilog testbench code:
What is the value of clk at time 0?
reg clk; initial begin clk = 1'b1; #10 clk = 1'b0; end
What is the value of clk at time 0?
Verilog
reg clk; initial begin clk = 1'b1; #10 clk = 1'b0; end
Attempts:
2 left
💡 Hint
Initial block runs at time 0 and sets clk first.
✗ Incorrect
The initial block sets clk to 1 at time 0, then after 10 time units sets clk to 0.
🔧 Debug
advancedWhy does this clock generator not toggle as expected?
Look at this Verilog code snippet intended to generate a clock signal:
What is the problem?
reg clk = 0; always (clk) #5 clk = ~clk;
What is the problem?
Verilog
reg clk = 0; always (clk) #5 clk = ~clk;
Attempts:
2 left
💡 Hint
Check the syntax of the always block sensitivity list.
✗ Incorrect
The always block sensitivity list must be empty, or use @ (posedge clk) or similar. '(clk)' is invalid syntax.
🚀 Application
advancedHow to generate a 50 MHz clock from a 100 MHz input clock in testbench?
You have a 100 MHz clock signal in your testbench. Which code snippet correctly generates a 50 MHz clock by dividing the input clock by 2?
Attempts:
2 left
💡 Hint
Toggle output clock on every rising edge of input clock.
✗ Incorrect
Toggling clk_out on every positive edge of clk_in divides frequency by 2, producing 50 MHz from 100 MHz.
🧠 Conceptual
expertWhat is the effect of using non-blocking assignment in clock generation always block?
In a testbench, you write:
What is the effect of using non-blocking assignment (<=) instead of blocking (=) here?
reg clk = 0; always #5 clk <= ~clk;
What is the effect of using non-blocking assignment (<=) instead of blocking (=) here?
Verilog
reg clk = 0; always #5 clk <= ~clk;
Attempts:
2 left
💡 Hint
Non-blocking and blocking assignments behave similarly in simple clock toggling.
✗ Incorrect
For simple clock toggling in testbench, blocking or non-blocking assignments produce the same waveform.
