D Flip Flop
module d_myff(d,clk,q);
input d,clk;
output q;
reg q;
always@(posedge clk)
begin
q <=d;
end
endmodule
Test Bench
`timescale 1ns/1ns
module tb();
reg d1,clk1,d2,clk2;
wire q1,q2;
d_myff U1(
.d(d1),
.clk(clk1),
.q(q1));
d_myff U2(
.d(d2),
.clk(clk2),
.q(q2));
initial
begin
d1=1;
clk1=1;
#10;
d1=1;
clk1=0;
#20;
d1=0;
clk1=1;
#100;
end
initial
begin
d2=1;
clk2=1;
#10;
d2=1;
clk2=0;
#20;
d2=0;
clk2=1;
#100;
end
endmodule