Experiment 10 UCS704 ESD
Experiment 10 UCS704 ESD
D-Flip Flop
D Flip-Flop
• A D flip-flop is a sequential element that follows the input pin d at the
clock's given edge. D flip-flop is a fundamental component in digital logic
circuits.
• There are two types of D Flip-Flops being implemented: Rising-Edge D Flip
Flop and Falling-Edge D Flip Flop.
• REF: https://www.javatpoint.com/verilog-d-flip-flop
D flip flop with Asynchronous
Reset
D flip-flops can have asynchronous reset, which can be independent of the clock.
Regardless of the clock, the reset can change the output Q to zero, which can cause
asynchronous output.
// Design Module
module Adff(d,rstn,clk,q);
input d,rstn,clk;
output reg q;
always@(posedge clk or negedge rstn)
if (!rstn )
q<=0;
else
q<=d;
integer i;
initial begin
Test bench clk =0; d =0; rstn =0;
#5 rstn =1;
module tv_dff;
reg d,rstn,clk; repeat(6) begin
Adff obj(d,rstn,clk,q); d =$urandom_range(0,1);
#5;
always #10 clk = ~clk; end
rstn = 0;
//#5 rstn = 1;
initial begin repeat(6) begin
$display(" T\treset \t clk \t D \t| q"); d =$urandom_range(0,1);
$monitor(" %0t \t %d \t %d \t %d | %d", #5;
$time,rstn,clk,d,q); end
end $finish;
end
D flip flop with synchronous
Reset
D flip-flop with synchronous reset means the output can reset to zero with the reset input
but only with the clock, which makes the reset input dependent on the clock pulse; without
clock pulse reset will not be able to set the output Q to zero, which will give you a
synchronous output always.
// Design Module
module Sdff(d,rstn,clk,q);
input d,rstn,clk;
output reg q;
always@(posedge clk)
if (!rstn )
q<=0;
else
q<=d;
integer i;
initial begin
Test bench clk =0; d =0; rstn =0;
#5 rstn =1;
module tv_dff;
reg d,rstn,clk; repeat(6) begin
Sdff obj(d,rstn,clk,q); d =$urandom_range(0,1);
#5;
always #10 clk = ~clk; end
rstn = 0;
//#5 rstn = 1;
initial begin repeat(6) begin
$display(" T\treset \t clk \t D \t| q"); d =$urandom_range(0,1);
$monitor(" %0t \t %d \t %d \t %d | %d", #5;
$time,rstn,clk,d,q); end
end $finish;
end