A D flip-flop is a memory device that captures the value of the input (D) at a specific clock edge and holds it until the next clock edge.
Click to reveal answer
beginner
Which clock edge does a positive-edge triggered D flip-flop respond to?
It responds to the rising edge of the clock signal, which is when the clock changes from 0 to 1.
Click to reveal answer
intermediate
Explain the role of the clock signal in a D flip-flop.
The clock signal controls when the D flip-flop captures the input value. The flip-flop updates its output only at the specified clock edge, ensuring synchronized data storage.
Click to reveal answer
beginner
What happens to the output Q of a D flip-flop if the clock does not have an edge?
The output Q remains unchanged and holds the last captured value until the next clock edge occurs.
Click to reveal answer
intermediate
Write a simple Verilog code snippet for a positive-edge triggered D flip-flop.
module d_flip_flop(input wire clk, input wire d, output reg q);
always @(posedge clk) begin
q <= d;
end
endmodule
Click to reveal answer
What does the 'posedge' keyword in Verilog indicate?
ANo clock edge
BNegative (falling) edge of the clock
CAny change in the clock
DPositive (rising) edge of the clock
✗ Incorrect
The 'posedge' keyword triggers the block on the rising edge of the clock signal.
In a D flip-flop, when is the input 'D' value transferred to output 'Q'?
AWhen reset is active
BContinuously
CAt the clock edge
DWhen enable is low
✗ Incorrect
The D flip-flop captures the input only at the clock edge, not continuously.
What will happen if you use 'negedge clk' instead of 'posedge clk' in a D flip-flop?
AFlip-flop triggers on falling edge of clock
BFlip-flop triggers on rising edge of clock
CFlip-flop triggers on both edges
DFlip-flop does not trigger
✗ Incorrect
'negedge' means the flip-flop triggers on the falling (negative) edge of the clock.
Which statement best describes the output behavior of a D flip-flop between clock edges?
AOutput holds the last value
BOutput changes randomly
COutput follows input continuously
DOutput resets to zero
✗ Incorrect
Between clock edges, the output remains stable and holds the last captured value.
What is the purpose of using a D flip-flop in digital circuits?
ATo amplify signals
BTo store and synchronize data
CTo generate clock signals
DTo perform arithmetic operations
✗ Incorrect
D flip-flops are used to store data and synchronize it with the clock signal.
Describe how a D flip-flop works with a clock edge to store data.
Think about when the flip-flop reads input and when it keeps the output stable.
You got /4 concepts.
Write a simple Verilog code example of a positive-edge triggered D flip-flop and explain each part.
Focus on how the always block uses the clock edge to update output.
You got /5 concepts.
Practice
(1/5)
1.
What does a D flip-flop do in a digital circuit?
easy
A. Stores the input value on the rising edge of the clock
B. Generates a clock signal
C. Performs arithmetic operations
D. Resets the circuit asynchronously
Solution
Step 1: Understand the role of a D flip-flop
A D flip-flop captures and stores the input value (D) at a specific clock event.
Step 2: Identify the clock event
It stores the value on the rising edge (positive edge) of the clock signal.
Final Answer:
Stores the input value on the rising edge of the clock -> Option A
Quick Check:
D flip-flop stores input on clock rising edge [OK]
Hint: Remember: D flip-flop stores data at clock's rising edge [OK]
Common Mistakes:
Confusing D flip-flop with clock generator
Thinking it performs calculations
Assuming it resets asynchronously
2.
Which of the following is the correct Verilog syntax to trigger a D flip-flop on the rising edge of the clock clk?
easy
A. always @(negedge clk)
B. always @(posedge clk)
C. always @(clk)
D. always @(clk posedge)
Solution
Step 1: Recall the correct event control syntax
Verilog uses posedge to detect the rising edge of a signal.
Step 2: Match syntax with clock signal
The correct syntax to trigger on rising edge of clk is always @(posedge clk).
Final Answer:
always @(posedge clk) -> Option B
Quick Check:
Rising edge trigger = posedge [OK]
Hint: Use 'posedge' for rising edge in always block [OK]
Common Mistakes:
Using negedge instead of posedge
Omitting posedge keyword
Incorrect event control syntax
3.
What will be the output q after the following Verilog code runs for one clock cycle if d = 1 and initial q = 0?
module dff(input clk, input d, output reg q);
always @(posedge clk) begin
q <= d;
end
endmodule
medium
A. q remains 0
B. q toggles between 0 and 1
C. q becomes undefined
D. q becomes 1
Solution
Step 1: Understand the behavior on posedge clk
On the rising edge of clk, the flip-flop assigns d to q.
Step 2: Apply given inputs
Since d = 1 and initial q = 0, after the clock edge, q updates to 1.
Final Answer:
q becomes 1 -> Option D
Quick Check:
D input 1 stored at clock edge = q 1 [OK]
Hint: On clock rising edge, q copies d value [OK]
Common Mistakes:
Assuming q changes immediately without clock edge
Thinking q toggles automatically
Ignoring initial value of q
4.
Identify the error in this D flip-flop Verilog code snippet:
module dff(input clk, input d, output reg q);
always @(clk) begin
q <= d;
end
endmodule
medium
A. Missing sensitivity to clock edge, should use posedge
B. Output q should not be reg
C. Input d should be reg type
D. No error, code is correct
Solution
Step 1: Check sensitivity list
The code uses always @(clk), which triggers on any change of clk, not just edges.
Step 2: Correct edge sensitivity
For a D flip-flop, it must trigger only on the rising edge: always @(posedge clk).
Final Answer:
Missing sensitivity to clock edge, should use posedge -> Option A
Quick Check:
Flip-flop triggers on posedge clk only [OK]
Hint: Use posedge in always block for flip-flop [OK]
Common Mistakes:
Using level sensitivity instead of edge sensitivity
Confusing reg and wire for outputs
Assuming inputs must be reg
5.
You want to design a D flip-flop that resets q to 0 asynchronously when rst is high. Which Verilog code snippet correctly implements this behavior?
module dff(input clk, input rst, input d, output reg q);
always @(posedge clk or posedge rst) begin
if (rst)
q <= 0;
else
q <= d;
end
endmodule
hard
A. The sensitivity list is missing negedge rst
B. Reset should be checked only on clock edge, not asynchronously
C. This code correctly implements asynchronous reset
D. q should be assigned with blocking assignment (=) inside always
Solution
Step 1: Analyze sensitivity list
The always block triggers on rising edge of clock or rising edge of reset, enabling asynchronous reset.
Step 2: Check reset logic
If reset is high, q is set to 0 immediately, else q follows d on clock edge.
Final Answer:
This code correctly implements asynchronous reset -> Option C
Quick Check:
Asynchronous reset uses posedge rst in sensitivity list [OK]
Hint: Add posedge rst in sensitivity list for async reset [OK]
Common Mistakes:
Checking reset only on clock edge (synchronous reset)
Using blocking assignment for sequential logic
Missing reset in sensitivity list
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.