Challenge - 5 Problems
Async Reset Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of D flip-flop with asynchronous reset
What is the output Q after the following Verilog code runs for one clock cycle if reset is asserted asynchronously?
Verilog
module dff_async_reset(input clk, input reset, input d, output reg q); always @(posedge clk or posedge reset) begin if (reset) q <= 1'b0; else q <= d; end endmodule // Initial state: q = 0 // Inputs at posedge clk: reset = 1, d = 1
Attempts:
2 left
💡 Hint
Remember asynchronous reset overrides the clocked data input.
✗ Incorrect
When reset is asserted (high) asynchronously, the output Q is immediately set to 0 regardless of the clock or data input.
🧠 Conceptual
intermediate1:30remaining
Understanding sensitivity list in D flip-flop with async reset
Which signals must be included in the sensitivity list of a D flip-flop with asynchronous reset in Verilog?
Attempts:
2 left
💡 Hint
Think about what triggers the flip-flop to update output.
✗ Incorrect
The flip-flop output updates on the rising edge of the clock or the rising edge of the asynchronous reset, so both must be in the sensitivity list.
🔧 Debug
advanced2:00remaining
Identify the error in this D flip-flop with async reset code
What error will occur when compiling this Verilog code for a D flip-flop with asynchronous reset?
module dff(input clk, input reset, input d, output reg q);
always @(posedge clk or reset) begin
if (reset)
q <= 1'b0;
else
q <= d;
end
endmodule
Attempts:
2 left
💡 Hint
Check how edges are specified in sensitivity lists.
✗ Incorrect
The sensitivity list must specify edges for asynchronous signals. 'reset' alone is invalid; it should be 'posedge reset' or 'negedge reset'.
📝 Syntax
advanced2:00remaining
Correct asynchronous reset implementation
Which of the following Verilog code snippets correctly implements a positive-edge triggered D flip-flop with an active-high asynchronous reset?
Attempts:
2 left
💡 Hint
Asynchronous reset must be in sensitivity list with edge specified.
✗ Incorrect
Option B correctly uses 'posedge reset' in sensitivity list and checks reset active high inside the block.
🚀 Application
expert2:30remaining
Number of clock cycles to clear output with async reset
Given a D flip-flop with asynchronous reset implemented as below, if reset is asserted high for 3 clock cycles and then deasserted, how many clock cycles after reset deassertion will it take for Q to reflect the input D?
module dff(input clk, input reset, input d, output reg q);
always @(posedge clk or posedge reset) begin
if (reset)
q <= 1'b0;
else
q <= d;
end
endmodule
Attempts:
2 left
💡 Hint
Think about when Q updates relative to clock edges and reset signal.
✗ Incorrect
Q is cleared immediately when reset is high. After reset goes low, Q updates on the next rising clock edge, so 1 clock cycle delay.