- UID
- 856476
|
先把D触发器的test bench附上
`timescale 10ns/10ns
module d_ff_flow;
reg sys_clk;
reg rst;
reg D;
wire Q;
wire Q_n;
d_ff u1(
.sys_clk(sys_clk),
.rst(rst),
.D(D),
.Q(Q),
.Q_n(Q_n)
);
initial
begin
sys_clk=0;
while(1)
#1 sys_clk=~sys_clk;
end
initial
begin
rst=0;
while(1)
#2 rst=~rst;
end
initial
begin
D=0;
while(1)
#3 D=~D;
end
initial
begin
$display($time,"sys_clk=%d D=%d rst=%d Q=%d Q_n=%d",sys_clk,D,rst,Q,Q_n);
end
endmodule
附上源文件
module d_ff(
input sys_clk,
input rst,
input D,
output reg Q,
output Q_n
);
always@(posedge sys_clk)
if(!rst) Q<=1'b0;
else Q<=D;
assign Q_n=~Q;
endmodule |
|