-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtb.v
55 lines (48 loc) · 1.08 KB
/
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
`include "ISA.v"
module TB();
reg clk = 0;
reg rst = 0;
reg start = 0;
reg [`LEN_DATA - 1:0] data_in;
wire done = 0;
wire one_done = 0;
wire [`LEN_DATA - 1:0] data_out;
always #(20) clk = ~clk;
Shifter UUT(
.clk(clk),
.rst(rst),
.start(start),
.data_in(data_in),
.done(done),
.one_done(one_done),
.data_out(data_out)
);
integer input_file, output_file, i, j;
initial begin
rst = 1;
#50 ;
rst = 0;
#50
start = 1;
#50
start = 0;
input_file = $fopen("samples/0.in", "r");
output_file = $fopen("samples/0.out", "w");
i = 0;
while (!$feof(input_file) && done != 1) begin
j = 0;
$fscanf(input_file, "%b\n", data_in);
while (one_done != 1 || j < `SIZE_PAGE) begin
$display("doing page %d cell %d\n", i, j);
#20 j = j + 1;
end
$fwrite(output_file, "%b\n", data_out);
$display("----\n%b\n%b\n----\n", data_in, data_out);
i = i + 1;
end
$fclose(input_file);
$fclose(input_file);
#50
$stop;
end
endmodule // TB