1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
| module sipo_tb;
reg d,clk,clr,reset,check;
wire q1,q2,q3,q4;
reg [3:0]t;
integer i;
sipo dut1(.d(d), .q1(q1),.q2(q2), .q3(q3), .q4(q4), .clk(clk), .clr(clr), .reset(reset));
initial
begin
clk = 1'b0;
clr = 1'b0;
reset = 1'b0;
d = 0;
end
always
begin
forever
#10 clk = ~clk;
repeat(5)@(negedge clk)
begin
reset = 0;
clr = 0;
d = $random;
t[i] = d;
i=i+1;
if(i>3)
begin
check = 1;
i = 0;
end
end
$finish;
end
always@(posedge clk)
begin
if( check )
begin
if(t[0] !== q1 && t[1] !== q2 && t[2] !== q3 && t[3] !== q4)
$display(" error mismatch: %b%b%b%b",t[0],t[1],t[2],t[3]," output is %b%b%b%b",q1,q2,q3,q4);
check = 0;
end
end
endmodule |