-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter_tb.sv
83 lines (72 loc) · 2.02 KB
/
router_tb.sv
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
83
`timescale 1ns/1ps
import SystemVerilogCSP::*;
module router_tb;
parameter FL = 2, BL = 1;
parameter WIDTH_packet = 57;
Channel #(.hsProtocol(P4PhaseBD), .WIDTH(WIDTH_packet)) in[4:0]();
Channel #(.hsProtocol(P4PhaseBD), .WIDTH(WIDTH_packet)) out[4:0]();
router DUT(
in[0], out[0], //up
in[1], out[1], //down
in[2], out[2], //right
in[3], out[3], //left
in[4], out[4] //PE
);
data_bucket #(.NODE(0)) north_bucket(out[0]);
data_bucket #(.NODE(1)) south_bucket(out[1]);
data_bucket #(.NODE(2)) east_bucket(out[2]);
data_bucket #(.NODE(3)) west_bucket(out[3]);
data_bucket #(.NODE(4)) PE_bucket(out[4]);
logic [WIDTH_packet-1:0] in_data;
integer i = 0;
initial begin
//west to east
in_data = 0;
in_data[47] = 1;
in_data[46:44] = 1; // xhop
in_data[39:0] = 1;
#FL;
in[3].Send(in_data);
$display("send: %b",in_data);
#BL;
//west to north
in_data[46:44] = 0;
in_data[43] = 1;
in_data[42:40] = 1;
in_data[39:0] = 2;
#FL;
in[3].Send(in_data);
$display("send: %b",in_data);
#BL;
//west to south
in_data[46:44] = 0;
in_data[43] = 0;
in_data[42:40] = 1;
in_data[39:0] = 3;
#FL;
in[3].Send(in_data);
$display("send: %b",in_data);
#BL;
// west to pe
in_data = 0;
in_data[39:0] = 4;
#FL;
in[3].Send(in_data);
$display("send: %b",in_data);
#BL;
// pe to west, also check pe out
in_data = 0;
in_data[47] = 1'b0;
in_data[46:44] = 3'd 2;
in_data[39:0] = 5;
#FL;
in[4].Send(in_data);
$display("send: %b",in_data);
#BL;
end
initial begin
#100;
$display("*** Stopped by watchdog timer ***");
$stop;
end
endmodule