D Flip Flop(Asynchronous Reset)
Truth Table
Design
module d_ff_async(d,clk,rst,q);
input d,clk,rst;
output q;
reg q;
always@(posedge clk or posedge rst)
begin
if(rst == 1'b1)
q <= 1'b0;
else
q <= d;
end
endmodule
Testbench
module d_ff_async_tb;
reg t_d,t_clk,t_rst;
wire t_q;
d_ff_async d_ff_async_tb(.d(t_d),
.clk(t_clk),
.rst(t_rst),
.q(t_q)
);
initial
begin
t_clk = 1'b0;
t_rst = 1'b0;
t_d = 1'b0;
end
always #10 t_clk = ~t_clk;
always #15 t_rst = ~t_rst;
always #20 t_d = ~t_d;
initial
begin
$monitor("%t,t_d=%b,t_q=%b,t_q=%b",$time,t_d,t_q);
end
endmodule
.jpg)
.jpg)
Comments
Post a Comment