-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTop_tb.v
83 lines (65 loc) · 1.07 KB
/
Top_tb.v
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
`timescale 1ns / 1ns
module Top_tb;
reg clk, rst;
reg [7:0] T;
wire [2:0] valid, NR, done;
wire [7:0] R, G, B;
integer wrf, wgf, wbf;
Top uut (
.clk(clk),
.rst(rst),
.T(T),
.valid(valid),
.NR(NR),
.done(done),
.R(R),
.G(G),
.B(B)
);
initial begin
clk = 0;
rst = 0;
T = 0;
#2 rst = 1; #7 rst = 0;
end
initial forever #10 clk = ~clk;
initial begin
#100;
wrf = $fopen("test/decoded/R.txt", "w");
while (~done[0]) begin
#20;
if (valid[0])
$fwrite(wrf, "%0d,", R);
if (NR[0])
$fwrite(wrf, "\n");
end
$fclose(wrf);
wrf = 0;
end
initial begin
#100;
wgf = $fopen("test/decoded/G.txt", "w");
while (~done[1]) begin
#20;
if (valid[1])
$fwrite(wgf, "%0d,", G);
if (NR[1])
$fwrite(wgf, "\n");
end
$fclose(wgf);
wgf = 0;
end
initial begin
#100;
wbf = $fopen("test/decoded/B.txt", "w");
while (~done[2]) begin
#20;
if (valid[2])
$fwrite(wbf, "%0d,", B);
if (NR[2])
$fwrite(wbf, "\n");
end
$fclose(wbf);
wbf = 0;
end
endmodule