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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
//
// Copyright 2012 Ettus Research LLC
//
`timescale 1 ps / 1 ps
module eth_dispatch_tb();
// Clocking and reset interface
reg clk;
reg reset;
reg clear;
// Setting register interface
reg set_stb;
reg [15:0] set_addr;
reg [31:0] set_data;
// Input 68bit AXI-Stream interface (from MAC)
wire [63:0] in_tdata;
wire [3:0] in_tuser;
wire in_tlast;
wire in_tvalid;
wire in_tready;
// Output AXI-Stream interface to VITA Radio Core
wire [63:0] vita_tdata;
wire [3:0] vita_tuser;
wire vita_tlast;
wire vita_tvalid;
wire vita_tready;
// Output AXI-Stream interface to ZPU
wire [63:0] zpu_tdata;
wire [3:0] zpu_tuser;
wire zpu_tlast;
wire zpu_tvalid;
wire zpu_tready;
// Output AXI-Stream interface to cross-over MAC
wire [63:0] xo_tdata;
wire [3:0] xo_tuser;
wire xo_tlast;
wire xo_tvalid;
wire xo_tready;
reg [63:0] data_in;
reg [3:0] user_in;
reg valid_in;
wire ready_in;
reg last_in;
eth_dispatch
#(.BASE(0))
eth_dispatch_i
(
// Clocking and reset interface
.clk(clk),
.reset(reset),
.clear(clear),
// Setting register interface
.set_stb(set_stb),
.set_addr(set_addr),
.set_data(set_data),
// Input 68bit AXI-Stream interface (from MAC)
.in_tdata(in_tdata),
.in_tuser(in_tuser),
.in_tlast(in_tlast),
.in_tvalid(in_tvalid),
.in_tready(in_tready),
// Output AXI-STream interface to VITA Radio Core
.vita_tdata(vita_tdata),
.vita_tuser(vita_tuser),
.vita_tlast(vita_tlast),
.vita_tvalid(vita_tvalid),
.vita_tready(vita_tready),
// Output AXI-Stream interface to ZPU
.zpu_tdata(zpu_tdata),
.zpu_tuser(zpu_tuser),
.zpu_tlast(zpu_tlast),
.zpu_tvalid(zpu_tvalid),
.zpu_tready(zpu_tready),
// Output AXI-Stream interface to cross-over MAC
.xo_tdata(xo_tdata),
.xo_tuser(xo_tuser),
.xo_tlast(xo_tlast),
.xo_tvalid(xo_tvalid),
.xo_tready(xo_tready)
);
//
// Define Clocks
//
initial begin
clk = 1'b1;
end
// 125MHz clock
always #4000 clk = ~clk;
//
// Good starting state
//
initial begin
reset <= 0;
clear <= 0;
set_stb <= 0;
set_addr <= 0;
set_data <= 0;
data_in <= 0;
user_in <= 0;
valid_in <= 0;
last_in <= 0;
end
//
// Task Libaray
//
task write_setting_bus;
input [15:0] address;
input [31:0] data;
begin
@(negedge clk);
set_stb = 1'b0;
set_addr = 16'h0;
set_data = 32'h0;
@(negedge clk);
set_stb = 1'b1;
set_addr = address;
set_data = data;
@(negedge clk);
set_stb = 1'b0;
set_addr = 16'h0;
set_data = 32'h0;
end
endtask // write_setting_bus
task enqueue_line;
input last;
input [2:0] keep;
input [63:0] data;
begin
data_in <= {keep, data};
last_in <= last;
valid_in <= 1;
while (~ready_in) begin
@(negedge clk);
end
@(negedge clk);
data_in <= 0;
last_in <= 0;
valid_in <= 0;
end
endtask // enqueue_line
task enqueue_arp_req;
input [47:0] src_mac;
input [31:0] src_ip;
input [47:0] dst_mac;
input [31:0] dst_ip;
begin
@(negedge clk);
// Line 0
enqueue_line( 0, 3'b0, {48'h0,16'hffff});
// Line 1 - Eth
enqueue_line( 0, 3'b0, {32'hffffffff,src_mac[47:16]});
// Line 2 - Eth+ARP (HTYPE = 1, PTYPE = 0x0800)
enqueue_line( 0, 3'b0, {src_mac[15:0],16'h0806,16'h0001,16'h0800});
// Line 3 - HLEN=6, PLEN=4 OPER=1
enqueue_line( 0, 3'b0, {8'h06,8'h04,16'h0001,src_mac[47:16]});
// Line 4 - ARP
enqueue_line( 0, 3'b0, {src_mac[15:0],src_ip[31:0],dst_mac[47:32]});
// Line 5 - ARP
enqueue_line( 1, 3'b0, {dst_mac[31:0],dst_ip[31:0]});
end
endtask // enqueue_arp_req
reg [11:0] frame_count =12'h0;
task enqueue_vita_pkt;
// We assume that we always have SID and TSF fields.
input [47:0] mac;
input [31:0] ip;
input [15:0] udp;
input [15:0] vita_size;
input [63:0] vita_tsf;
input [31:0] vita_sid;
integer i;
reg [15:0] j;
reg [19:0] vrl_size;
reg [15:0] udp_size;
reg [15:0] ip_size;
begin
vrl_size = vita_size + 3;
udp_size = vrl_size*4 + 8;
ip_size = udp_size + 20;
@(negedge clk);
// Line 0
enqueue_line( 0, 3'b0, {48'h0,mac[47:32]});
// Line 1 - Eth
enqueue_line( 0, 3'b0, {mac[31:0],32'h11223344});
// Line 2 - Eth+IP
enqueue_line( 0, 3'b0, {16'h5566,16'h0800,16'h0000,ip_size});
// Line 3 - IP
enqueue_line( 0, 3'b0, 'h11<<16);
// Line 4 - IP
enqueue_line( 0, 3'b0, {32'h09080706, ip});
// Line 5 - UDP
enqueue_line( 0, 3'b0, {16'h1234, udp, udp_size, 16'h0});
// Line 6 - VRL
enqueue_line( 0, 3'b0, {"VRLP",frame_count,vrl_size});
// Line 7 - VRT
enqueue_line( 0, 3'b0, {16'b0001000000010000, vita_size,vita_sid}); //vita hdr + SID
enqueue_line( 0, 3'b0, vita_tsf);
j = 0;
for (i = 6; i < vita_size; i = i + 2) begin
enqueue_line( 0 , 3'b0, {j,j+16'h1,j+16'h2,j+16'h3});
j = j + 4;
end
if (i-vita_size==0) // 2x32words to finish VITA packet.
enqueue_line( 1, 3'b0, {j,j+16'h1,j+16'h2,j+16'h3});
else // 1x32bit word to finish VITA packet
enqueue_line( 1, 3'h4, {j,j+16'h1,j+16'h2,j+16'h3});
end
endtask // enqueue_packet
//
// Simulation specific testbench is included here
//
`include "simulation_script.v"
//
// Input FIFO
//
axi_fifo_short
#(.WIDTH(69)) axi_fifo_short_in
(
.clk(clk),
.reset(reset),
.clear(clear),
.o_tdata({in_tlast,in_tuser,in_tdata}),
.o_tvalid(in_tvalid),
.o_tready(in_tready),
.i_tdata({last_in,user_in,data_in}),
.i_tvalid(valid_in),
.i_tready(ready_in),
.space(),
.occupied()
);
//
// Output Sinks
//
axi_probe_tb
#(.FILENAME("zpu.txt"),.VITA_PORT0(60000),.VITA_PORT1(60001)) axi_probe_tb_zpu
(
.clk(clk),
.reset(reset),
.clear(clear),
.tdata(zpu_tdata),
.tvalid(zpu_tvalid),
.tready(zpu_tready),
.tlast(zpu_tlast)
);
assign zpu_tready = 1'b1;
axi_probe_tb
#(.FILENAME("xo.txt"),.VITA_PORT0(60000),.VITA_PORT1(60001)) axi_probe_tb_xo
(
.clk(clk),
.reset(reset),
.clear(clear),
.tdata(xo_tdata),
.tvalid(xo_tvalid),
.tready(xo_tready),
.tlast(xo_tlast)
);
assign xo_tready = 1'b1;
axi_probe_tb
#(.FILENAME("vita.txt"),.VITA_PORT0(60000),.VITA_PORT1(60001),.START_AT_VRL(1)) axi_probe_tb_vita
(
.clk(clk),
.reset(reset),
.clear(clear),
.tdata(vita_tdata),
.tvalid(vita_tvalid),
.tready(vita_tready),
.tlast(vita_tlast)
);
assign vita_tready = 1'b1;
endmodule // eth_dispatch_tb
|