Concept Flow - D flip-flop with synchronous reset
Clock Rising Edge
Check Reset
Set Q=0
Output Q
On each rising clock edge, the flip-flop checks the reset signal. If reset is high, output Q is set to 0; otherwise, Q takes the value of input D.
always @(posedge clk) begin if (reset) q <= 0; else q <= d; end
| Step | clk | reset | d | Condition (reset?) | Action | q (new value) |
|---|---|---|---|---|---|---|
| 1 | rising edge | 0 | 1 | No | q <= d | 1 |
| 2 | rising edge | 1 | 0 | Yes | q <= 0 | 0 |
| 3 | rising edge | 0 | 1 | No | q <= d | 1 |
| 4 | rising edge | 0 | 0 | No | q <= d | 0 |
| 5 | rising edge | 1 | 1 | Yes | q <= 0 | 0 |
| 6 | no edge | 0 | 1 | N/A | No change | 0 |
| Variable | Start | After 1 | After 2 | After 3 | After 4 | After 5 | After 6 |
|---|---|---|---|---|---|---|---|
| q | X (unknown) | 1 | 0 | 1 | 0 | 0 | 0 |
| reset | 0 | 0 | 1 | 0 | 0 | 1 | 0 |
| d | X | 1 | 0 | 1 | 0 | 1 | 1 |
D flip-flop with synchronous reset: - On clock rising edge, check reset. - If reset=1, set q=0. - Else, set q=d. - q changes only on clock edges. - Reset has priority over d input.