-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoCE_latency_eval.v
executable file
·268 lines (227 loc) · 7.42 KB
/
RoCE_latency_eval.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
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
`resetall `timescale 1ns / 1ps `default_nettype none
module RoCE_latency_eval (
input wire clk,
input wire rst,
input wire start_i,
//input wire [31:0] message_length,
// RX
input wire s_roce_rx_bth_valid,
input wire [ 7:0] s_roce_rx_bth_op_code,
input wire [15:0] s_roce_rx_bth_p_key,
input wire [23:0] s_roce_rx_bth_psn,
input wire [23:0] s_roce_rx_bth_dest_qp,
input wire s_roce_rx_bth_ack_req,
// AETH
input wire s_roce_rx_aeth_valid,
input wire [ 7:0] s_roce_rx_aeth_syndrome,
input wire [23:0] s_roce_rx_aeth_msn,
// RETH
/*
* TODO ADD
*/
// TX
// BTH
input wire s_roce_tx_bth_valid,
input wire [ 7:0] s_roce_tx_bth_op_code,
input wire [15:0] s_roce_tx_bth_p_key,
input wire [23:0] s_roce_tx_bth_psn,
input wire [23:0] s_roce_tx_bth_dest_qp,
input wire s_roce_tx_bth_ack_req,
// RETH
input wire s_roce_tx_reth_valid,
input wire [63:0] s_roce_tx_reth_v_addr,
input wire [31:0] s_roce_tx_reth_r_key,
input wire [31:0] s_roce_tx_reth_length,
// AETH
/*
* TODO ADD
*/
// Performance results
output wire [63:0] transfer_time_tot,
output wire [63:0] transfer_time_single,
output wire [63:0] latency_first_packet,
output wire [63:0] latency_last_packet
);
localparam [7:0]
RC_RDMA_WRITE_FIRST = 8'h06,
RC_RDMA_WRITE_MIDDLE = 8'h07,
RC_RDMA_WRITE_LAST = 8'h08,
RC_RDMA_WRITE_LAST_IMD= 8'h09,
RC_RDMA_WRITE_ONLY = 8'h0A,
RC_RDMA_WRITE_ONLY_IMD= 8'h0B,
RC_RDMA_ACK = 8'h11;
wire fifo_rst;
reg [63:0] free_running_ctr;
reg start_d;
wire [63:0] start_stamp_fifo_out_data;
wire start_stamp_fifo_out_valid;
wire start_fifos_out_ready;
wire last_fifos_out_ready;
axis_fifo #(
.DEPTH (1024),
.DATA_WIDTH (64),
.KEEP_ENABLE(0),
.KEEP_WIDTH (8),
.ID_ENABLE (0),
.DEST_ENABLE(0),
.USER_ENABLE(0),
.USER_WIDTH (1),
.FRAME_FIFO (0)
) fifo_start_message_time_stamp (
.clk(clk),
.rst(fifo_rst | rst),
// AXI input
.s_axis_tdata(free_running_ctr),
.s_axis_tkeep({8{1'b1}}),
.s_axis_tvalid(s_roce_tx_bth_valid & s_roce_tx_reth_valid),
.s_axis_tuser(0),
.s_axis_tlast(0),
.s_axis_tdest(0),
.s_axis_tid(0),
// AXI output
.m_axis_tdata (start_stamp_fifo_out_data),
.m_axis_tvalid(start_stamp_fifo_out_valid),
.m_axis_tready(start_fifos_out_ready)
);
wire [63:0] last_stamp_fifo_out_data;
wire last_stamp_fifo_out_valid;
wire last_psn_fifo_we;
axis_fifo #(
.DEPTH (1024),
.DATA_WIDTH (64),
.KEEP_ENABLE(0),
.KEEP_WIDTH (8),
.ID_ENABLE (0),
.DEST_ENABLE(0),
.USER_ENABLE(0),
.USER_WIDTH (1),
.FRAME_FIFO (0)
) fifo_last_message_time_stamp (
.clk(clk),
.rst(fifo_rst | rst),
// AXI input
.s_axis_tdata(free_running_ctr),
.s_axis_tkeep({8{1'b1}}),
.s_axis_tvalid(last_psn_fifo_we),
.s_axis_tuser(0),
.s_axis_tlast(0),
.s_axis_tdest(0),
.s_axis_tid(0),
// AXI output
.m_axis_tdata (last_stamp_fifo_out_data),
.m_axis_tvalid(last_stamp_fifo_out_valid),
.m_axis_tready(last_fifos_out_ready)
);
wire [23:0] start_psn_fifo_out_data;
wire start_psn_fifo_out_valid;
axis_fifo #(
.DEPTH (1024),
.DATA_WIDTH (24),
.KEEP_ENABLE(1),
.KEEP_WIDTH (3),
.ID_ENABLE (0),
.DEST_ENABLE(0),
.USER_ENABLE(0),
.USER_WIDTH (1),
.FRAME_FIFO (0)
) fifo_start_psn (
.clk(clk),
.rst(fifo_rst | rst),
// AXI input
.s_axis_tdata(s_roce_tx_bth_psn),
.s_axis_tkeep({3{1'b1}}),
.s_axis_tvalid(s_roce_tx_bth_valid & s_roce_tx_reth_valid), // RDMA WRITE FIRST or RDMA WRITE ONLY, start of packet
.s_axis_tuser(0),
.s_axis_tlast(0),
.s_axis_tdest(0),
.s_axis_tid(0),
// AXI output
.m_axis_tdata (start_psn_fifo_out_data),
.m_axis_tvalid(start_psn_fifo_out_valid),
.m_axis_tready(start_fifos_out_ready)
);
wire [23:0] last_psn_fifo_out_data;
wire last_psn_fifo_out_valid;
axis_fifo #(
.DEPTH (1024),
.DATA_WIDTH (24),
.KEEP_ENABLE(1),
.KEEP_WIDTH (3),
.ID_ENABLE (0),
.DEST_ENABLE(0),
.USER_ENABLE(0),
.USER_WIDTH (1),
.FRAME_FIFO (0)
) fifo_last_psn (
.clk(clk),
.rst(fifo_rst | rst),
// AXI input
.s_axis_tdata(s_roce_tx_bth_psn),
.s_axis_tkeep({3{1'b1}}),
.s_axis_tvalid(last_psn_fifo_we), // RDMA WRITE FIRST or RDMA WRITE ONLY, start of packet
.s_axis_tuser(0),
.s_axis_tlast(0),
.s_axis_tdest(0),
.s_axis_tid(0),
// AXI output
.m_axis_tdata (last_psn_fifo_out_data),
.m_axis_tvalid(last_psn_fifo_out_valid),
.m_axis_tready(last_fifos_out_ready)
);
assign last_psn_fifo_we = s_roce_tx_bth_valid & (s_roce_tx_bth_op_code == RC_RDMA_WRITE_LAST || s_roce_tx_bth_op_code == RC_RDMA_WRITE_LAST_IMD ||
s_roce_tx_bth_op_code == RC_RDMA_WRITE_ONLY || s_roce_tx_bth_op_code == RC_RDMA_WRITE_ONLY_IMD
);
assign start_fifos_out_ready = s_roce_rx_bth_valid & s_roce_rx_aeth_valid & (s_roce_rx_bth_psn == start_psn_fifo_out_data);
assign last_fifos_out_ready = s_roce_rx_bth_valid & s_roce_rx_aeth_valid & (s_roce_rx_bth_psn == last_psn_fifo_out_data);
assign fifo_rst = start_i & ~start_d;
always @(posedge clk) begin
start_d <= start_i;
end
always @(posedge clk) begin
if (rst) begin // reset counter when start of packet is detected at the transmitter side
free_running_ctr <= 64'd0;
end else begin
if (start_i & ~start_d) begin
free_running_ctr <= 64'd0;
end else begin
free_running_ctr <= free_running_ctr + 64'd1;
end
end
end
reg [63:0] transfer_time_wo_ack_reg;
reg [63:0] transfer_time_reg;
reg [63:0] tot_time_wo_ack_reg;
reg [63:0] tot_time_reg;
reg [63:0] latency_tot_first_reg;
reg [63:0] latency_tot_last_reg;
reg [63:0] latency_first_reg;
reg [63:0] latency_last_reg;
always @(posedge clk) begin
if (start_i & ~start_d) begin
latency_tot_first_reg <= 64'd0;
latency_tot_last_reg <= 64'd0;
transfer_time_reg <= 64'd0;
transfer_time_wo_ack_reg <= 64'd0;
tot_time_wo_ack_reg <= 64'd0;
tot_time_reg <= 64'd0;
latency_first_reg <= 64'd0;
latency_last_reg <= 64'd0;
end else begin
if (start_fifos_out_ready && start_stamp_fifo_out_valid) begin
latency_tot_first_reg <= latency_tot_first_reg + (free_running_ctr - start_stamp_fifo_out_data);
latency_first_reg <= free_running_ctr - start_stamp_fifo_out_data;
end
if (last_fifos_out_ready && last_stamp_fifo_out_valid) begin
latency_tot_last_reg <= latency_tot_last_reg + (free_running_ctr - last_stamp_fifo_out_data);
latency_last_reg <= free_running_ctr - last_stamp_fifo_out_data;
tot_time_reg <= free_running_ctr;
transfer_time_reg <= free_running_ctr - tot_time_reg;
end
end
end
assign transfer_time_tot = tot_time_reg;
assign transfer_time_single = transfer_time_reg;
assign latency_first_packet = latency_first_reg;
assign latency_last_packet = latency_last_reg;
endmodule
`resetall