D flip-flop is the most important flip-flop in digitial circuit. In this tutorial, we'll descrive D flip-fop in Verilog HDL without reset, with synchronous and asynchronous reset.
D flip-flop is also known as delay type flip-flop because output of d flip-flop is 1 clock pulse delay of the input appled to the d flip-flop . The truth table of positive edge triggered D flip-flop is given below. When there is negative edge trigger clock, it stores the previous input applied to the flip-flop. In positive edge trigger of clock, input of the d flip-flop is stored.
Clock Edge |
D |
Q |
Description |
$$\downarrow$$ |
X |
Q |
No Change (Store previous input) |
$$\uparrow$$ |
1 |
1 |
Set Q to 1 |
$$\uparrow$$ |
0 |
0 |
Reset Q to 0 |
module dff(clk,d,q);
input clk,d;
output reg q;
always @ (posedge clk)begin
q <= d;
end
endmodule
module dff(clk,reset,d,q);
input clk,reset,d;
output reg q;
always @ (posedge clk)begin
if(reset)
q <= 0;
else
q <= d;
end
endmodule
module dff(clk,reset,d,q);
input clk,reset,d;
output reg q;
always @ (posedge clk or negedge reset)begin
if(~reset)
q <= 0;
else
q <= d;
end
endmodule
Click like if you found this useful
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Comments (1)
very informative!