1//
2// Copyright 2019 Ettus Research, A National Instruments Brand
3//
4// SPDX-License-Identifier: LGPL-3.0-or-later
5//
6// Module: noc_shell_ddc
7//
8// Description:
9//
10//   This is a tool-generated NoC-shell for the ddc block.
11//   See the RFNoC specification for more information about NoC shells.
12//
13// Parameters:
14//
15//   THIS_PORTID : Control crossbar port to which this block is connected
16//   CHDR_W      : AXIS-CHDR data bus width
17//   MTU         : Maximum transmission unit (i.e., maximum packet size in
18//
19
20`default_nettype none
21
22
23module noc_shell_ddc #(
24  parameter [9:0] THIS_PORTID     = 10'd0,
25  parameter       CHDR_W          = 64,
26  parameter [5:0] MTU             = 10,
27  parameter       NUM_PORTS       = 1,
28  parameter       NUM_HB          = 3,
29  parameter       CIC_MAX_DECIM   = 255
30) (
31  //---------------------
32  // Framework Interface
33  //---------------------
34
35  // RFNoC Framework Clocks
36  input  wire rfnoc_chdr_clk,
37  input  wire rfnoc_ctrl_clk,
38  input  wire ce_clk,
39
40  // NoC Shell Generated Resets
41  output wire rfnoc_chdr_rst,
42  output wire rfnoc_ctrl_rst,
43  output wire ce_rst,
44
45  // RFNoC Backend Interface
46  input  wire [511:0]          rfnoc_core_config,
47  output wire [511:0]          rfnoc_core_status,
48
49  // AXIS-CHDR Input Ports (from framework)
50  input  wire [(0+NUM_PORTS)*CHDR_W-1:0] s_rfnoc_chdr_tdata,
51  input  wire [(0+NUM_PORTS)-1:0]        s_rfnoc_chdr_tlast,
52  input  wire [(0+NUM_PORTS)-1:0]        s_rfnoc_chdr_tvalid,
53  output wire [(0+NUM_PORTS)-1:0]        s_rfnoc_chdr_tready,
54  // AXIS-CHDR Output Ports (to framework)
55  output wire [(0+NUM_PORTS)*CHDR_W-1:0] m_rfnoc_chdr_tdata,
56  output wire [(0+NUM_PORTS)-1:0]        m_rfnoc_chdr_tlast,
57  output wire [(0+NUM_PORTS)-1:0]        m_rfnoc_chdr_tvalid,
58  input  wire [(0+NUM_PORTS)-1:0]        m_rfnoc_chdr_tready,
59
60  // AXIS-Ctrl Control Input Port (from framework)
61  input  wire [31:0]           s_rfnoc_ctrl_tdata,
62  input  wire                  s_rfnoc_ctrl_tlast,
63  input  wire                  s_rfnoc_ctrl_tvalid,
64  output wire                  s_rfnoc_ctrl_tready,
65  // AXIS-Ctrl Control Output Port (to framework)
66  output wire [31:0]           m_rfnoc_ctrl_tdata,
67  output wire                  m_rfnoc_ctrl_tlast,
68  output wire                  m_rfnoc_ctrl_tvalid,
69  input  wire                  m_rfnoc_ctrl_tready,
70
71  //---------------------
72  // Client Interface
73  //---------------------
74
75  // CtrlPort Clock and Reset
76  output wire               ctrlport_clk,
77  output wire               ctrlport_rst,
78  // CtrlPort Master
79  output wire               m_ctrlport_req_wr,
80  output wire               m_ctrlport_req_rd,
81  output wire [19:0]        m_ctrlport_req_addr,
82  output wire [31:0]        m_ctrlport_req_data,
83  output wire               m_ctrlport_req_has_time,
84  output wire [63:0]        m_ctrlport_req_time,
85  input  wire               m_ctrlport_resp_ack,
86  input  wire [31:0]        m_ctrlport_resp_data,
87
88  // AXI-Stream Data Clock and Reset
89  output wire               axis_data_clk,
90  output wire               axis_data_rst,
91  // Data Stream to User Logic: in
92  output wire [NUM_PORTS*32*1-1:0]   m_in_axis_tdata,
93  output wire [NUM_PORTS*1-1:0]      m_in_axis_tkeep,
94  output wire [NUM_PORTS-1:0]        m_in_axis_tlast,
95  output wire [NUM_PORTS-1:0]        m_in_axis_tvalid,
96  input  wire [NUM_PORTS-1:0]        m_in_axis_tready,
97  output wire [NUM_PORTS*64-1:0]     m_in_axis_ttimestamp,
98  output wire [NUM_PORTS-1:0]        m_in_axis_thas_time,
99  output wire [NUM_PORTS*16-1:0]     m_in_axis_tlength,
100  output wire [NUM_PORTS-1:0]        m_in_axis_teov,
101  output wire [NUM_PORTS-1:0]        m_in_axis_teob,
102  // Data Stream to User Logic: out
103  input  wire [NUM_PORTS*32*1-1:0]   s_out_axis_tdata,
104  input  wire [NUM_PORTS*1-1:0]      s_out_axis_tkeep,
105  input  wire [NUM_PORTS-1:0]        s_out_axis_tlast,
106  input  wire [NUM_PORTS-1:0]        s_out_axis_tvalid,
107  output wire [NUM_PORTS-1:0]        s_out_axis_tready,
108  input  wire [NUM_PORTS*64-1:0]     s_out_axis_ttimestamp,
109  input  wire [NUM_PORTS-1:0]        s_out_axis_thas_time,
110  input  wire [NUM_PORTS-1:0]        s_out_axis_teov,
111  input  wire [NUM_PORTS-1:0]        s_out_axis_teob
112);
113
114  //---------------------------------------------------------------------------
115  //  Backend Interface
116  //---------------------------------------------------------------------------
117
118  wire         data_i_flush_en;
119  wire [31:0]  data_i_flush_timeout;
120  wire [63:0]  data_i_flush_active;
121  wire [63:0]  data_i_flush_done;
122  wire         data_o_flush_en;
123  wire [31:0]  data_o_flush_timeout;
124  wire [63:0]  data_o_flush_active;
125  wire [63:0]  data_o_flush_done;
126
127  backend_iface #(
128    .NOC_ID        (32'hDDC00000),
129    .NUM_DATA_I    (0+NUM_PORTS),
130    .NUM_DATA_O    (0+NUM_PORTS),
131    .CTRL_FIFOSIZE ($clog2(64)),
132    .MTU           (MTU)
133  ) backend_iface_i (
134    .rfnoc_chdr_clk       (rfnoc_chdr_clk),
135    .rfnoc_chdr_rst       (rfnoc_chdr_rst),
136    .rfnoc_ctrl_clk       (rfnoc_ctrl_clk),
137    .rfnoc_ctrl_rst       (rfnoc_ctrl_rst),
138    .rfnoc_core_config    (rfnoc_core_config),
139    .rfnoc_core_status    (rfnoc_core_status),
140    .data_i_flush_en      (data_i_flush_en),
141    .data_i_flush_timeout (data_i_flush_timeout),
142    .data_i_flush_active  (data_i_flush_active),
143    .data_i_flush_done    (data_i_flush_done),
144    .data_o_flush_en      (data_o_flush_en),
145    .data_o_flush_timeout (data_o_flush_timeout),
146    .data_o_flush_active  (data_o_flush_active),
147    .data_o_flush_done    (data_o_flush_done)
148  );
149
150  //---------------------------------------------------------------------------
151  //  Reset Generation
152  //---------------------------------------------------------------------------
153
154  wire ce_rst_pulse;
155
156  pulse_synchronizer #(.MODE ("POSEDGE")) pulse_synchronizer_ce (
157    .clk_a(rfnoc_chdr_clk), .rst_a(1'b0), .pulse_a (rfnoc_chdr_rst), .busy_a (),
158    .clk_b(ce_clk), .pulse_b (ce_rst_pulse)
159  );
160
161  pulse_stretch_min #(.LENGTH(32)) pulse_stretch_min_ce (
162    .clk(ce_clk), .rst(1'b0),
163    .pulse_in(ce_rst_pulse), .pulse_out(ce_rst)
164  );
165
166  //---------------------------------------------------------------------------
167  //  Control Path
168  //---------------------------------------------------------------------------
169
170  assign ctrlport_clk = ce_clk;
171  assign ctrlport_rst = ce_rst;
172
173  ctrlport_endpoint #(
174    .THIS_PORTID      (THIS_PORTID),
175    .SYNC_CLKS        (0),
176    .AXIS_CTRL_MST_EN (0),
177    .AXIS_CTRL_SLV_EN (1),
178    .SLAVE_FIFO_SIZE  ($clog2(64))
179  ) ctrlport_endpoint_i (
180    .rfnoc_ctrl_clk            (rfnoc_ctrl_clk),
181    .rfnoc_ctrl_rst            (rfnoc_ctrl_rst),
182    .ctrlport_clk              (ctrlport_clk),
183    .ctrlport_rst              (ctrlport_rst),
184    .s_rfnoc_ctrl_tdata        (s_rfnoc_ctrl_tdata),
185    .s_rfnoc_ctrl_tlast        (s_rfnoc_ctrl_tlast),
186    .s_rfnoc_ctrl_tvalid       (s_rfnoc_ctrl_tvalid),
187    .s_rfnoc_ctrl_tready       (s_rfnoc_ctrl_tready),
188    .m_rfnoc_ctrl_tdata        (m_rfnoc_ctrl_tdata),
189    .m_rfnoc_ctrl_tlast        (m_rfnoc_ctrl_tlast),
190    .m_rfnoc_ctrl_tvalid       (m_rfnoc_ctrl_tvalid),
191    .m_rfnoc_ctrl_tready       (m_rfnoc_ctrl_tready),
192    .m_ctrlport_req_wr         (m_ctrlport_req_wr),
193    .m_ctrlport_req_rd         (m_ctrlport_req_rd),
194    .m_ctrlport_req_addr       (m_ctrlport_req_addr),
195    .m_ctrlport_req_data       (m_ctrlport_req_data),
196    .m_ctrlport_req_byte_en    (),
197    .m_ctrlport_req_has_time   (m_ctrlport_req_has_time),
198    .m_ctrlport_req_time       (m_ctrlport_req_time),
199    .m_ctrlport_resp_ack       (m_ctrlport_resp_ack),
200    .m_ctrlport_resp_status    (2'b0),
201    .m_ctrlport_resp_data      (m_ctrlport_resp_data),
202    .s_ctrlport_req_wr         (1'b0),
203    .s_ctrlport_req_rd         (1'b0),
204    .s_ctrlport_req_addr       (20'b0),
205    .s_ctrlport_req_portid     (10'b0),
206    .s_ctrlport_req_rem_epid   (16'b0),
207    .s_ctrlport_req_rem_portid (10'b0),
208    .s_ctrlport_req_data       (32'b0),
209    .s_ctrlport_req_byte_en    (4'hF),
210    .s_ctrlport_req_has_time   (1'b0),
211    .s_ctrlport_req_time       (64'b0),
212    .s_ctrlport_resp_ack       (),
213    .s_ctrlport_resp_status    (),
214    .s_ctrlport_resp_data      ()
215  );
216
217  //---------------------------------------------------------------------------
218  //  Data Path
219  //---------------------------------------------------------------------------
220
221  genvar i;
222
223  assign axis_data_clk = ce_clk;
224  assign axis_data_rst = ce_rst;
225
226  //---------------------
227  // Input Data Paths
228  //---------------------
229
230  for (i = 0; i < NUM_PORTS; i = i + 1) begin: gen_input_in
231    chdr_to_axis_data #(
232      .CHDR_W         (CHDR_W),
233      .ITEM_W         (32),
234      .NIPC           (1),
235      .SYNC_CLKS      (0),
236      .INFO_FIFO_SIZE ($clog2(32)),
237      .PYLD_FIFO_SIZE ($clog2(MTU))
238    ) chdr_to_axis_data_in_in (
239      .axis_chdr_clk      (rfnoc_chdr_clk),
240      .axis_chdr_rst      (rfnoc_chdr_rst),
241      .axis_data_clk      (axis_data_clk),
242      .axis_data_rst      (axis_data_rst),
243      .s_axis_chdr_tdata  (s_rfnoc_chdr_tdata[((0+i)*CHDR_W)+:CHDR_W]),
244      .s_axis_chdr_tlast  (s_rfnoc_chdr_tlast[0+i]),
245      .s_axis_chdr_tvalid (s_rfnoc_chdr_tvalid[0+i]),
246      .s_axis_chdr_tready (s_rfnoc_chdr_tready[0+i]),
247      .m_axis_tdata       (m_in_axis_tdata[(32*1)*i+:(32*1)]),
248      .m_axis_tkeep       (m_in_axis_tkeep[1*i+:1]),
249      .m_axis_tlast       (m_in_axis_tlast[i]),
250      .m_axis_tvalid      (m_in_axis_tvalid[i]),
251      .m_axis_tready      (m_in_axis_tready[i]),
252      .m_axis_ttimestamp  (m_in_axis_ttimestamp[64*i+:64]),
253      .m_axis_thas_time   (m_in_axis_thas_time[i]),
254      .m_axis_tlength     (m_in_axis_tlength[i*16+:16]),
255      .m_axis_teov        (m_in_axis_teov[i]),
256      .m_axis_teob        (m_in_axis_teob[i]),
257      .flush_en           (data_i_flush_en),
258      .flush_timeout      (data_i_flush_timeout),
259      .flush_active       (data_i_flush_active[0+i]),
260      .flush_done         (data_i_flush_done[0+i])
261    );
262  end
263
264  //---------------------
265  // Output Data Paths
266  //---------------------
267
268  for (i = 0; i < NUM_PORTS; i = i + 1) begin: gen_output_out
269    axis_data_to_chdr #(
270      .CHDR_W         (CHDR_W),
271      .ITEM_W         (32),
272      .NIPC           (1),
273      .SYNC_CLKS      (0),
274      .INFO_FIFO_SIZE ($clog2(32)),
275      .PYLD_FIFO_SIZE ($clog2(MTU)),
276      .MTU            (MTU)
277    ) axis_data_to_chdr_out_out (
278      .axis_chdr_clk      (rfnoc_chdr_clk),
279      .axis_chdr_rst      (rfnoc_chdr_rst),
280      .axis_data_clk      (axis_data_clk),
281      .axis_data_rst      (axis_data_rst),
282      .m_axis_chdr_tdata  (m_rfnoc_chdr_tdata[(0+i)*CHDR_W+:CHDR_W]),
283      .m_axis_chdr_tlast  (m_rfnoc_chdr_tlast[0+i]),
284      .m_axis_chdr_tvalid (m_rfnoc_chdr_tvalid[0+i]),
285      .m_axis_chdr_tready (m_rfnoc_chdr_tready[0+i]),
286      .s_axis_tdata       (s_out_axis_tdata[(32*1)*i+:(32*1)]),
287      .s_axis_tkeep       (s_out_axis_tkeep[1*i+:1]),
288      .s_axis_tlast       (s_out_axis_tlast[i]),
289      .s_axis_tvalid      (s_out_axis_tvalid[i]),
290      .s_axis_tready      (s_out_axis_tready[i]),
291      .s_axis_ttimestamp  (s_out_axis_ttimestamp[64*i+:64]),
292      .s_axis_thas_time   (s_out_axis_thas_time[i]),
293      .s_axis_teov        (s_out_axis_teov[i]),
294      .s_axis_teob        (s_out_axis_teob[i]),
295      .flush_en           (data_o_flush_en),
296      .flush_timeout      (data_o_flush_timeout),
297      .flush_active       (data_o_flush_active[0+i]),
298      .flush_done         (data_o_flush_done[0+i])
299    );
300  end
301
302endmodule // noc_shell_ddc
303
304
305`default_nettype wire
306