forked from EttusResearch/uhd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
New Text Document.txt
329 lines (299 loc) · 12.5 KB
/
New Text Document.txt
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
//
// Copyright 2020 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: LGPL-3.0-or-later
//
// Module: rfnoc_block_scheduler
//
// Description:
//
// <Add block description here>
//
// Parameters:
//
// THIS_PORTID : Control crossbar port to which this block is connected
// CHDR_W : AXIS-CHDR data bus width
// MTU : Maximum transmission unit (i.e., maximum packet size in
// CHDR words is 2**MTU).
//
`default_nettype none
module rfnoc_block_scheduler #(
parameter [9:0] THIS_PORTID = 10'd0,
parameter CHDR_W = 64,
parameter [5:0] MTU = 10
)(
// RFNoC Framework Clocks and Resets
input wire rfnoc_chdr_clk,
input wire rfnoc_ctrl_clk,
// RFNoC Backend Interface
input wire [511:0] rfnoc_core_config,
output wire [511:0] rfnoc_core_status,
// AXIS-CHDR Input Ports (from framework)
input wire [(1)*CHDR_W-1:0] s_rfnoc_chdr_tdata,
input wire [(1)-1:0] s_rfnoc_chdr_tlast,
input wire [(1)-1:0] s_rfnoc_chdr_tvalid,
output wire [(1)-1:0] s_rfnoc_chdr_tready,
// AXIS-CHDR Output Ports (to framework)
output wire [(1)*CHDR_W-1:0] m_rfnoc_chdr_tdata,
output wire [(1)-1:0] m_rfnoc_chdr_tlast,
output wire [(1)-1:0] m_rfnoc_chdr_tvalid,
input wire [(1)-1:0] m_rfnoc_chdr_tready,
// AXIS-Ctrl Input Port (from framework)
input wire [31:0] s_rfnoc_ctrl_tdata,
input wire s_rfnoc_ctrl_tlast,
input wire s_rfnoc_ctrl_tvalid,
output wire s_rfnoc_ctrl_tready,
// AXIS-Ctrl Output Port (to framework)
output wire [31:0] m_rfnoc_ctrl_tdata,
output wire m_rfnoc_ctrl_tlast,
output wire m_rfnoc_ctrl_tvalid,
input wire m_rfnoc_ctrl_tready
);
//---------------------------------------------------------------------------
// Signal Declarations
//---------------------------------------------------------------------------
// Clocks and Resets
wire ctrlport_clk;
wire ctrlport_rst;
wire axis_data_clk;
wire axis_data_rst;
// CtrlPort Master
(* keep = "true" *) wire m_ctrlport_req_wr;
(* keep = "true" *) wire m_ctrlport_req_rd;
(* keep = "true" *) wire [19:0] m_ctrlport_req_addr;
(* keep = "true" *) wire [31:0] m_ctrlport_req_data;
(* keep = "true" *) wire m_ctrlport_resp_ack;
(* keep = "true" *) wire [31:0] m_ctrlport_resp_data;
// CtrlPort Slave
(* keep = "true" *) wire s_ctrlport_req_wr;
(* keep = "true" *) wire s_ctrlport_req_rd;
(* keep = "true" *) wire [19:0] s_ctrlport_req_addr;
(* keep = "true" *) wire [9:0] s_ctrlport_req_portid;
(* keep = "true" *) wire [31:0] s_ctrlport_req_data;
(* keep = "true" *) wire s_ctrlport_resp_ack;
(* keep = "true" *) wire [31:0] s_ctrlport_resp_data;
// Payload Stream to User Logic: in
(* keep = "true" *) wire [32*1-1:0] m_in_payload_tdata;
(* keep = "true" *) wire [1-1:0] m_in_payload_tkeep;
(* keep = "true" *) wire m_in_payload_tlast;
(* keep = "true" *) wire m_in_payload_tvalid;
(* keep = "true" *) wire m_in_payload_tready;
// Context Stream to User Logic: in
(* keep = "true" *) wire [CHDR_W-1:0] m_in_context_tdata;
(* keep = "true" *) wire [3:0] m_in_context_tuser;
(* keep = "true" *) wire m_in_context_tlast;
(* keep = "true" *) wire m_in_context_tvalid;
(* keep = "true" *) wire m_in_context_tready;
// Payload Stream from User Logic: out
wire [32*1-1:0] s_out_payload_tdata;
wire [0:0] s_out_payload_tkeep;
wire s_out_payload_tlast;
wire s_out_payload_tvalid;
wire s_out_payload_tready;
// Context Stream from User Logic: out
wire [CHDR_W-1:0] s_out_context_tdata;
wire [3:0] s_out_context_tuser;
wire s_out_context_tlast;
wire s_out_context_tvalid;
wire s_out_context_tready;
//---------------------------------------------------------------------------
// NoC Shell
//---------------------------------------------------------------------------
noc_shell_scheduler #(
.CHDR_W (CHDR_W),
.THIS_PORTID (THIS_PORTID),
.MTU (MTU)
) noc_shell_scheduler_i (
//---------------------
// Framework Interface
//---------------------
// Clock Inputs
.rfnoc_chdr_clk (rfnoc_chdr_clk),
.rfnoc_ctrl_clk (rfnoc_ctrl_clk),
// Reset Outputs
.rfnoc_chdr_rst (),
.rfnoc_ctrl_rst (),
// RFNoC Backend Interface
.rfnoc_core_config (rfnoc_core_config),
.rfnoc_core_status (rfnoc_core_status),
// CHDR Input Ports (from framework)
.s_rfnoc_chdr_tdata (s_rfnoc_chdr_tdata),
.s_rfnoc_chdr_tlast (s_rfnoc_chdr_tlast),
.s_rfnoc_chdr_tvalid (s_rfnoc_chdr_tvalid),
.s_rfnoc_chdr_tready (s_rfnoc_chdr_tready),
// CHDR Output Ports (to framework)
.m_rfnoc_chdr_tdata (m_rfnoc_chdr_tdata),
.m_rfnoc_chdr_tlast (m_rfnoc_chdr_tlast),
.m_rfnoc_chdr_tvalid (m_rfnoc_chdr_tvalid),
.m_rfnoc_chdr_tready (m_rfnoc_chdr_tready),
// AXIS-Ctrl Input Port (from framework)
.s_rfnoc_ctrl_tdata (s_rfnoc_ctrl_tdata),
.s_rfnoc_ctrl_tlast (s_rfnoc_ctrl_tlast),
.s_rfnoc_ctrl_tvalid (s_rfnoc_ctrl_tvalid),
.s_rfnoc_ctrl_tready (s_rfnoc_ctrl_tready),
// AXIS-Ctrl Output Port (to framework)
.m_rfnoc_ctrl_tdata (m_rfnoc_ctrl_tdata),
.m_rfnoc_ctrl_tlast (m_rfnoc_ctrl_tlast),
.m_rfnoc_ctrl_tvalid (m_rfnoc_ctrl_tvalid),
.m_rfnoc_ctrl_tready (m_rfnoc_ctrl_tready),
//---------------------
// Client Interface
//---------------------
// CtrlPort Clock and Reset
.ctrlport_clk (ctrlport_clk),
.ctrlport_rst (ctrlport_rst),
// CtrlPort Master
.m_ctrlport_req_wr (m_ctrlport_req_wr),
.m_ctrlport_req_rd (m_ctrlport_req_rd),
.m_ctrlport_req_addr (m_ctrlport_req_addr),
.m_ctrlport_req_data (m_ctrlport_req_data),
.m_ctrlport_resp_ack (m_ctrlport_resp_ack),
.m_ctrlport_resp_data (m_ctrlport_resp_data),
// CtrlPort Slave
.s_ctrlport_req_wr (s_ctrlport_req_wr),
.s_ctrlport_req_rd (s_ctrlport_req_rd),
.s_ctrlport_req_addr (s_ctrlport_req_addr),
.s_ctrlport_req_portid (s_ctrlport_req_portid),
.s_ctrlport_req_data (s_ctrlport_req_data),
.s_ctrlport_resp_ack (s_ctrlport_resp_ack),
.s_ctrlport_resp_data (s_ctrlport_resp_data),
// AXI-Stream Payload Context Clock and Reset
.axis_data_clk (axis_data_clk),
.axis_data_rst (axis_data_rst),
// Payload Stream to User Logic: in
.m_in_payload_tdata (m_in_payload_tdata),
.m_in_payload_tkeep (m_in_payload_tkeep),
.m_in_payload_tlast (m_in_payload_tlast),
.m_in_payload_tvalid (m_in_payload_tvalid),
.m_in_payload_tready (m_in_payload_tready),
// Context Stream to User Logic: in
.m_in_context_tdata (m_in_context_tdata),
.m_in_context_tuser (m_in_context_tuser),
.m_in_context_tlast (m_in_context_tlast),
.m_in_context_tvalid (m_in_context_tvalid),
.m_in_context_tready (m_in_context_tready),
// Payload Stream from User Logic: out
.s_out_payload_tdata (s_out_payload_tdata),
.s_out_payload_tkeep (s_out_payload_tkeep),
.s_out_payload_tlast (s_out_payload_tlast),
.s_out_payload_tvalid (s_out_payload_tvalid),
.s_out_payload_tready (s_out_payload_tready),
// Context Stream from User Logic: out
.s_out_context_tdata (s_out_context_tdata),
.s_out_context_tuser (s_out_context_tuser),
.s_out_context_tlast (s_out_context_tlast),
.s_out_context_tvalid (s_out_context_tvalid),
.s_out_context_tready (s_out_context_tready)
);
//---------------------------------------------------------------------------
// User Logic
//---------------------------------------------------------------------------
wire tableWrite;
wire run_ack, stop_ack;
wire [31:0] run_resp, stop_resp;
wire [31:0] run_data, stop_data;
wire [31:0] tableData;
reg custom_reset;
payloadDecoder decode(
.clk (axis_data_clk),
.reset (custom_reset),
.m_in_payload_tdata (m_in_payload_tdata),
.m_in_payload_tkeep (m_in_payload_tkeep),
.m_in_payload_tlast (m_in_payload_tlast),
.m_in_payload_tvalid (m_in_payload_tvalid),
.m_in_payload_tready (m_in_payload_tready),
.m_in_context_tdata (m_in_context_tdata),
.m_in_context_tuser (m_in_context_tuser),
.m_in_context_tlast (m_in_context_tlast),
.m_in_context_tvalid (m_in_context_tvalid),
.m_in_context_tready (m_in_context_tready),
.phase (tableData),
.writeEn (tableWrite));
REG_MODULE #(.addr (128))
REG_RUN (.clk (ctrlport_clk),
.reset (custom_reset),
.write (m_ctrlport_req_wr),
.read (m_ctrlport_req_rd),
.address (m_ctrlport_req_addr),
.i_data (m_ctrlport_req_data),
.ack (run_ack),
.o_data (run_data),
.o_resp (run_resp)
);
REG_MODULE #(.addr (129))
REG_STOP (.clk (ctrlport_clk),
.reset (custom_reset),
.write (m_ctrlport_req_wr),
.read (m_ctrlport_req_rd),
.address (m_ctrlport_req_addr),
.i_data (m_ctrlport_req_data),
.ack (stop_ack),
.o_data (stop_data),
.o_resp (stop_resp)
);
scheduler #(.tableLength (10), .phaseWidth (32), .hopCycles (10000))
hops (
.ctrlport_clk (ctrlport_clk),
.ctrlport_rst (custom_reset),
.axis_data_clk (axis_data_clk),
.axis_data_rst (custom_reset),
.start (run_data),
// .stop (),
.writeEn (tableWrite),
.writePhase (tableData),
.readPhase (s_ctrlport_req_data),
.outValid (s_ctrlport_req_wr));
always@(posedge ctrlport_clk) begin
if (stop_ack && stop_resp[0]) begin
custom_reset <= 1;
end else begin
custom_reset <= 0;
end
end
assign m_ctrlport_resp_ack = run_ack | stop_ack;
assign m_ctrlport_resp_data = run_ack ? run_resp : stop_ack ? stop_resp : 0;
assign s_ctrlport_req_addr = 132*8;
assign s_ctrlport_req_portid = 2;
assign s_out_payload_tdata = m_in_payload_tdata;
assign s_out_context_tdata = m_in_context_tdata;
// Nothing to do yet, so just drive control signals to default values
// assign m_ctrlport_resp_ack = 1'b0;
assign s_ctrlport_req_rd = 1'b0;
assign m_in_payload_tready = 1'b1;
assign m_in_context_tready = 1'b1;
assign s_out_payload_tvalid = m_in_payload_tvalid;
assign s_out_context_tvalid = m_in_context_tvalid;
endmodule // rfnoc_block_scheduler
`default_nettype wire
module REG_MODULE #(parameter addr = 0, parameter width = 32)
(
input clk,
input reset,
input write,
input read,
input [19:0] address,
input [width -1 : 0] i_data,
output [width - 1: 0] o_resp,
output [width - 1: 0] o_data,
output ack );
reg [width - 1: 0] data, resp;
reg ack_out;
always @ (posedge clk) begin
ack_out <= 0;
resp <= 0;
if (reset) begin
data <= 0;
end else if (address == addr) begin
ack_out <= 1;
if (write) begin
data <= i_data;
resp <= 0;
end else if (read) begin
resp <= data;
end
end
end
assign ack = ack_out;
assign o_resp = resp;
assign o_data = data;
endmodule