0
0
Verilogprogramming~20 mins

D flip-flop with asynchronous reset in Verilog - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Async Reset Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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
AQ = 0
BQ = 1
CQ retains previous value
DQ toggles
Attempts:
2 left
💡 Hint
Remember asynchronous reset overrides the clocked data input.
🧠 Conceptual
intermediate
1: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?
AClock, reset, and data signals
BOnly the clock signal
COnly the reset signal
DBoth clock and reset signals
Attempts:
2 left
💡 Hint
Think about what triggers the flip-flop to update output.
🔧 Debug
advanced
2: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
ANo error, code compiles and works correctly
BRuntime error: q never updates
CSyntax error: sensitivity list missing edge specification for reset
DSynthesis warning: asynchronous reset not supported
Attempts:
2 left
💡 Hint
Check how edges are specified in sensitivity lists.
📝 Syntax
advanced
2: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?
A
always @(posedge clk or negedge reset) begin
  if (!reset)
    q &lt;= 1'b0;
  else
    q &lt;= d;
end
B
always @(posedge clk or posedge reset) begin
  if (reset == 1'b1)
    q &lt;= 1'b0;
  else
    q &lt;= d;
end
C
always @(posedge clk or reset) begin
  if (reset)
    q &lt;= 1'b0;
  else
    q &lt;= d;
end
D
always @(posedge clk) begin
  if (reset)
    q &lt;= 1'b0;
  else
    q &lt;= d;
end
Attempts:
2 left
💡 Hint
Asynchronous reset must be in sensitivity list with edge specified.
🚀 Application
expert
2: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
A1 clock cycle after reset deassertion
B3 clock cycles after reset deassertion
CQ never updates after reset
DImmediately at reset deassertion
Attempts:
2 left
💡 Hint
Think about when Q updates relative to clock edges and reset signal.