D Flip Flop with Synchronous Reset
Problem Description
Design a D Flip Flop with an active-high synchronous reset. The module takes a 1-bit data input d, a clock clk, and a reset signal rst. On every rising edge of clk, if rst is high, output q is forced to 0. If rst is low, q captures the value of d. The reset only takes effect at the clock edge — not immediately when asserted.
Interface Table:
Port | Direction | Width | Description |
|---|---|---|---|
clk | input | 1 | Clock signal |
rst | input | 1 | Active-high sync reset |
d | input | 1 | Data input |
q | output | 1 | Flip flop output |
Truth Table:
rst | d | q (next) |
|---|---|---|
1 | X | 0 |
0 | 0 | 0 |
0 | 1 | 1 |
Common Mistakes:
Using
always @(posedge clk or posedge rst)— that makes it asynchronous, not synchronousUsing blocking assignment
=instead of<=inside always blockForgetting that synchronous means reset only takes effect at clock edge
Verilog
Code Editor Access
Log in to write, run and submit your solution to this interview question. It's free.
