OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [rtl/] [src_noc/] [router_two_stage.sv] - Blame information for rev 56

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 54 alirezamon
`include "pronoc_def.v"
2 48 alirezamon
 
3
//`define MONITORE_PATH
4
 
5
/***********************************************************************
6
 **     File: router.v
7
 **
8
 **     Copyright (C) 2014-2017  Alireza Monemi
9
 **
10
 **     This file is part of ProNoC
11
 **
12
 **     ProNoC ( stands for Prototype Network-on-chip)  is free software:
13
 **     you can redistribute it and/or modify it under the terms of the GNU
14
 **     Lesser General Public License as published by the Free Software Foundation,
15
 **     either version 2 of the License, or (at your option) any later version.
16
 **
17
 **     ProNoC is distributed in the hope that it will be useful, but WITHOUT
18
 **     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19
 **     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
20
 **     Public License for more details.
21
 **
22
 **     You should have received a copy of the GNU Lesser General Public
23
 **     License along with ProNoC. If not, see .
24
 **
25
 **
26
 **     Description:
27
 **     A two stage router
28
 **   stage1: lk-route,sw/VC allocation
29
 **   stage2: switch-traversal
30
 **************************************************************/
31
 
32
 
33 56 alirezamon
module router_two_stage #(
34
        parameter NOC_ID=0,
35
        parameter P=5
36
) (
37 54 alirezamon
                current_r_id,
38 48 alirezamon
                current_r_addr,// connected to constant parameter
39
 
40
                chan_in,
41
                chan_out,
42
 
43
                ctrl_in,
44
                ctrl_out,
45
 
46
                //internal router status
47
                ivc_info,
48
                ovc_info,
49
                iport_info,
50
                oport_info,
51
 
52
                smart_ctrl_in,
53
 
54
                clk,
55
                reset
56
 
57 56 alirezamon
);
58 48 alirezamon
 
59 56 alirezamon
        `NOC_CONF
60 48 alirezamon
 
61
 
62
        // The current/neighbor routers addresses/port. These values are fixed in each router and they are supposed to be given as parameter.
63
        // However, in order to give an identical RTL code to each router, they are given as input ports. The identical RTL code reduces the
64
        // compilation time. Note that they wont be implemented as  input ports in the final synthesized code.
65
 
66
        input [RAw-1 :  0]  current_r_addr;
67 54 alirezamon
        input [31:0] current_r_id;
68 48 alirezamon
 
69
        input   flit_chanel_t chan_in  [P-1 : 0];
70
        output  flit_chanel_t chan_out [P-1 : 0];
71
        input   ctrl_chanel_t ctrl_in  [P-1 : 0];
72
        output  ctrl_chanel_t ctrl_out [P-1 : 0];
73
        input   clk,reset;
74
 
75
 
76
        output  ivc_info_t       ivc_info    [P-1 : 0][V-1 : 0];
77
        output  ovc_info_t   ovc_info    [P-1 : 0][V-1 : 0];
78
        output  iport_info_t iport_info  [P-1 : 0];
79
        output  oport_info_t oport_info  [P-1 : 0];
80
 
81
        input   smart_ctrl_t   smart_ctrl_in [P-1 : 0];
82
 
83
 
84
        vsa_ctrl_t   vsa_ctrl    [P-1 : 0];
85
 
86
        localparam
87
                PV = V * P,
88
                VV = V*V,
89
                PVV = PV * V,
90
                P_1 = ( SELF_LOOP_EN=="NO")?  P-1 : P,
91
                PP_1 = P_1 * P,
92
                PVP_1 = PV * P_1,
93
                PFw = P*Fw,
94
                CONG_ALw = CONGw* P,    //  congestion width per router
95
                W = WEIGHTw,
96
                WP = W * P,
97
                WPP=  WP * P,
98
                PRAw= P * RAw;
99
 
100
 
101 54 alirezamon
        flit_chanel_t chan_in_tmp  [P-1 : 0];
102 48 alirezamon
 
103
 
104
 
105
        wire  [PFw-1 :  0]  flit_in_all;
106
        wire  [P-1 :  0]  flit_in_wr_all;
107
        wire  [PV-1 :  0]  credit_out_all;
108
        wire  [CONG_ALw-1 :  0]  congestion_in_all;
109
 
110
        wire  [PFw-1 :  0]  flit_out_all;
111
        wire  [P-1 :  0]  flit_out_wr_all;
112
        wire  [PV-1 :  0]  credit_in_all;
113
        wire  [CONG_ALw-1 :  0]  congestion_out_all;
114
 
115 54 alirezamon
        wire  [PV-1 : 0] credit_release_out;
116 48 alirezamon
 
117
 
118
        // old router verilog code
119
 
120
 
121
 
122
        //internal wires
123
        wire  [PV-1 : 0] ovc_allocated_all;
124
        wire  [PVV-1 : 0] granted_ovc_num_all;
125
        wire  [PV-1 : 0] ivc_num_getting_sw_grant;
126
        wire  [PV-1 : 0] ivc_num_getting_ovc_grant;
127
        wire  [PVV-1 : 0] spec_ovc_num_all;
128
        wire  [PV-1 : 0] nonspec_first_arbiter_granted_ivc_all;
129
        wire  [PV-1 : 0] spec_first_arbiter_granted_ivc_all;
130
        wire  [PP_1-1 : 0] nonspec_granted_dest_port_all;
131
        wire  [PP_1-1 : 0] spec_granted_dest_port_all;
132
        wire  [PP_1-1 : 0] granted_dest_port_all;
133
        wire  [P-1 : 0] any_ivc_sw_request_granted_all;
134
        wire  [P-1 :  0] any_ovc_granted_in_outport_all;
135
        wire  [P-1 : 0] granted_dst_is_from_a_single_flit_pck;
136
        // to vc/sw allocator
137
        wire  [PVP_1-1 :  0] dest_port_all;
138
        wire  [PV-1 : 0] ovc_is_assigned_all;
139
        wire  [PV-1 : 0] ivc_request_all;
140
        wire  [PV-1 : 0] assigned_ovc_not_full_all;
141
        wire  [PVV-1: 0] masked_ovc_request_all;
142 54 alirezamon
 
143 48 alirezamon
        wire  [PV-1 : 0] vc_weight_is_consumed_all;
144
        wire  [P-1  : 0] iport_weight_is_consumed_all;
145
    wire  [PV-1 : 0] vsa_ovc_released_all;
146
    wire  [PV-1 : 0] vsa_credit_decreased_all;
147
 
148
        // to/from the crossbar
149
        wire  [PFw-1 : 0] iport_flit_out_all;
150
        wire  [P-1 : 0] ssa_flit_wr_all;
151 54 alirezamon
        logic [PP_1-1 : 0] granted_dest_port_all_delayed;
152 48 alirezamon
        wire  [PFw-1 :  0]  crossbar_flit_out_all;
153
        wire  [P-1   :  0]  crossbar_flit_out_wr_all;
154
        wire  [PFw-1 :  0]  link_flit_out_all;
155
        wire  [P-1   :  0]  link_flit_out_wr_all;
156
        wire  [PV-1  :  0] flit_is_tail_all;
157
 
158
 
159
        //to weight control
160
        wire [WP-1 : 0] iport_weight_all;
161
        wire [WPP-1: 0] oports_weight_all;
162
        wire refresh_w_counter;
163
 
164
 
165
        //ctrl port
166
        wire [PRAw-1  :  0] neighbors_r_addr;
167
        wire [CRDTw-1 : 0 ] credit_init_val_in  [P-1 : 0][V-1 : 0];
168
        wire [CRDTw-1 : 0 ] credit_init_val_out [P-1 : 0][V-1 : 0];
169
 
170
 
171
 
172 54 alirezamon
 
173
 
174
 
175 48 alirezamon
        genvar i,j;
176 54 alirezamon
        generate
177
                for (i=0; i
178
 
179
                        if(CAST_TYPE == "UNICAST") begin : uni
180
                                assign chan_in_tmp[i] = chan_in[i];
181
                        end else begin : multi
182
                                multicast_chan_in_process #(
183 56 alirezamon
                                        .NOC_ID(NOC_ID),
184 54 alirezamon
                                        .P(P),
185
                                        .SW_LOC  (i)
186
                                ) multicast_process (
187
                                        .endp_port       (ctrl_in[i].endp_port),
188
                                        .current_r_addr  (current_r_addr ),
189
                                        .chan_in         (chan_in[i]     ),
190
                                        .chan_out        (chan_in_tmp[i] ),
191
                                        .clk                     (clk)
192
                                );
193
 
194
                        end
195
 
196
 
197 48 alirezamon
                        assign  neighbors_r_addr  [(i+1)*RAw-1:  i*RAw] = ctrl_in[i].neighbors_r_addr;
198 54 alirezamon
                        assign  flit_in_all       [(i+1)*Fw-1:  i*Fw] = chan_in_tmp[i].flit;
199
                        assign  flit_in_wr_all    [i] = chan_in_tmp[i].flit_wr;
200
                        assign  credit_in_all     [(i+1)*V-1:  i*V] = chan_in_tmp[i].credit;
201
                        assign  congestion_in_all [(i+1)*CONGw-1:  i*CONGw] = chan_in_tmp[i].congestion;
202 48 alirezamon
 
203
                        assign  ctrl_out[i].neighbors_r_addr = current_r_addr;
204 54 alirezamon
                        assign  ctrl_out[i].endp_port =1'b0;
205
 
206
 
207 48 alirezamon
                        assign  chan_out[i].flit=          flit_out_all       [(i+1)*Fw-1:  i*Fw];
208
                        assign  chan_out[i].flit_wr=       flit_out_wr_all    [i];
209 54 alirezamon
                        assign  chan_out[i].credit=        credit_out_all     [(i+1)*V-1:  i*V] | credit_release_out [(i+1)*V-1:  i*V];
210 48 alirezamon
                        assign  chan_out[i].congestion=    congestion_out_all [(i+1)*CONGw-1:  i*CONGw];
211
 
212 54 alirezamon
 
213 48 alirezamon
                        assign  iport_info[i].swa_first_level_grant =nonspec_first_arbiter_granted_ivc_all[(i+1)*V-1:  i*V];
214
                        assign  iport_info[i].swa_grant = ivc_num_getting_sw_grant[(i+1)*V-1:  i*V];
215
                        assign  iport_info[i].any_ivc_get_swa_grant=    any_ivc_sw_request_granted_all[i];
216
                        assign  iport_info[i].ivc_req = ivc_request_all [(i+1)*V-1:  i*V];
217
 
218
                        assign  vsa_ctrl[i].ovc_is_allocated = ovc_allocated_all [(i+1)*V-1:  i*V];
219
                        assign  vsa_ctrl[i].ovc_is_released  = vsa_ovc_released_all[(i+1)*V-1:  i*V];
220
                        assign  vsa_ctrl[i].ivc_num_getting_sw_grant = ivc_num_getting_sw_grant [(i+1)*V-1:  i*V];
221
                        assign  vsa_ctrl[i].ivc_num_getting_ovc_grant=ivc_num_getting_ovc_grant [(i+1)*V-1:  i*V];
222
                        assign  vsa_ctrl[i].ivc_reset=flit_is_tail_all[(i+1)*V-1:  i*V] & ivc_num_getting_sw_grant[(i+1)*V-1:  i*V];
223
                        assign  vsa_ctrl[i].buff_space_decreased =  vsa_credit_decreased_all[(i+1)*V-1:  i*V];
224
                        assign  vsa_ctrl[i].ivc_granted_ovc_num = granted_ovc_num_all[(i+1)*VV-1:  i*VV];
225
 
226
                        if(SELF_LOOP_EN == "NO") begin :nslp
227
                                add_sw_loc_one_hot #(
228
                                                .P(P),
229
                                                .SW_LOC(i)
230
                                        )add
231
                                        (
232
                                                .destport_in(granted_dest_port_all[(i+1)*P_1-1:  i*P_1]),
233
                                                .destport_out(iport_info[i].granted_oport_one_hot[P-1 : 0])
234
                                        );
235
                        end else begin :slp
236
                                assign iport_info[i].granted_oport_one_hot[P-1 : 0] = granted_dest_port_all[(i+1)*P_1-1:  i*P_1];
237
                        end
238
 
239
                        for (j=0;j
240 54 alirezamon
 
241
                                //credit_release. Only activated for local ports as credit_release_en never be asserted in router to router connection.
242
                                credit_release_gen #(
243 56 alirezamon
                                        .NOC_ID(NOC_ID),
244 54 alirezamon
                                        .CREDIT_NUM  (LB)
245
                                ) credit_release_gen (
246
                                        .clk         (clk        ),
247
                                        .reset       (reset      ),
248
                                        .en          (ctrl_in[i].credit_release_en[j] ),
249
                                        .credit_out  (credit_release_out[i*V+j] )
250
                                );
251
 
252
 
253
                                assign ctrl_out[i].credit_release_en[j] =1'b0;
254
                                assign credit_init_val_in[i][j]       = ctrl_in[i].credit_init_val[j];
255
                                assign ctrl_out[i].credit_init_val[j] = credit_init_val_out [i][j];
256
 
257
 
258
 
259
 
260 48 alirezamon
                        end
261
 
262 54 alirezamon
 
263
 
264 48 alirezamon
                end
265
        endgenerate
266
 
267
 
268
 
269
 
270 56 alirezamon
        inout_ports #(
271
                .NOC_ID(NOC_ID),
272
                .P(P)
273
        ) the_inout_ports (
274
                .current_r_addr(current_r_addr),
275
                .neighbors_r_addr(neighbors_r_addr),
276
                .flit_in_all(flit_in_all),
277
                .flit_in_wr_all(flit_in_wr_all),
278
                .credit_out_all(credit_out_all),
279
                .credit_in_all(credit_in_all),
280
                .masked_ovc_request_all(masked_ovc_request_all),
281
                .granted_dst_is_from_a_single_flit_pck(granted_dst_is_from_a_single_flit_pck),
282
                .vsa_ovc_allocated_all(ovc_allocated_all),
283
                .granted_ovc_num_all(granted_ovc_num_all),
284
                .ivc_num_getting_ovc_grant(ivc_num_getting_ovc_grant),
285
                .spec_ovc_num_all(spec_ovc_num_all),
286
                .nonspec_first_arbiter_granted_ivc_all(nonspec_first_arbiter_granted_ivc_all),
287
                .spec_first_arbiter_granted_ivc_all(spec_first_arbiter_granted_ivc_all),
288
                .nonspec_granted_dest_port_all(nonspec_granted_dest_port_all),
289
                .spec_granted_dest_port_all(spec_granted_dest_port_all),
290
                .granted_dest_port_all(granted_dest_port_all),
291
                .any_ivc_sw_request_granted_all(any_ivc_sw_request_granted_all),
292
                .any_ovc_granted_in_outport_all(any_ovc_granted_in_outport_all),
293
                .dest_port_all(dest_port_all),
294
                .ovc_is_assigned_all(ovc_is_assigned_all),
295
                .ivc_request_all(ivc_request_all),
296
                .assigned_ovc_not_full_all(assigned_ovc_not_full_all),
297
                .flit_out_all(iport_flit_out_all),
298
                .congestion_in_all(congestion_in_all),
299
                .congestion_out_all(congestion_out_all),
300
                //  .lk_destination_all(lk_destination_all),
301
                .ssa_flit_wr_all(ssa_flit_wr_all),
302
                .iport_weight_all(iport_weight_all),
303
                .oports_weight_all(oports_weight_all),
304
                .vc_weight_is_consumed_all(vc_weight_is_consumed_all),
305
                .iport_weight_is_consumed_all(iport_weight_is_consumed_all),
306
                .refresh_w_counter(refresh_w_counter),
307
                .clk(clk),
308
                .reset(reset),
309
                .ivc_info(ivc_info),
310
                .ovc_info(ovc_info),
311
                .oport_info(oport_info),
312
                .smart_ctrl_in(smart_ctrl_in),
313
                .vsa_ctrl_in(vsa_ctrl),
314
                .credit_init_val_in (credit_init_val_in),
315
                .credit_init_val_out (credit_init_val_out),
316
                .flit_is_tail_all(flit_is_tail_all),
317
                .crossbar_flit_out_wr_all(crossbar_flit_out_wr_all),
318
                .vsa_ovc_released_all(vsa_ovc_released_all),
319
                .vsa_credit_decreased_all(vsa_credit_decreased_all)
320
        );
321 48 alirezamon
 
322
 
323
        combined_vc_sw_alloc #(
324 56 alirezamon
                .NOC_ID(NOC_ID),
325
                .P(P)
326
        ) vsa (
327
                .dest_port_all(dest_port_all),
328
                .masked_ovc_request_all(masked_ovc_request_all),
329
                .granted_dst_is_from_a_single_flit_pck(granted_dst_is_from_a_single_flit_pck),
330
                .ovc_allocated_all(ovc_allocated_all),
331
                .granted_ovc_num_all(granted_ovc_num_all),
332
                .ivc_num_getting_ovc_grant(ivc_num_getting_ovc_grant),
333
                .ivc_num_getting_sw_grant(ivc_num_getting_sw_grant),
334
                .spec_first_arbiter_granted_ivc_all(spec_first_arbiter_granted_ivc_all),
335
                .nonspec_first_arbiter_granted_ivc_all(nonspec_first_arbiter_granted_ivc_all),
336
                .nonspec_granted_dest_port_all(nonspec_granted_dest_port_all),
337
                .spec_granted_dest_port_all(spec_granted_dest_port_all),
338
                .granted_dest_port_all(granted_dest_port_all),
339
                .any_ivc_sw_request_granted_all(any_ivc_sw_request_granted_all),
340
                .any_ovc_granted_in_outport_all(any_ovc_granted_in_outport_all),
341
                .spec_ovc_num_all(spec_ovc_num_all),
342
                // .lk_destination_all(lk_destination_all),
343
                .vc_weight_is_consumed_all(vc_weight_is_consumed_all),
344
                .iport_weight_is_consumed_all(iport_weight_is_consumed_all),
345
                .ivc_info(ivc_info),
346
                .clk(clk),
347
                .reset(reset)
348
        );
349 48 alirezamon
 
350 54 alirezamon
        pronoc_register #(.W(PP_1)) reg2 (.in(granted_dest_port_all ), .out(granted_dest_port_all_delayed), .reset(reset), .clk(clk));
351 48 alirezamon
 
352 54 alirezamon
 
353 56 alirezamon
                crossbar #(
354
                                .NOC_ID(NOC_ID),
355 48 alirezamon
                                .TOPOLOGY(TOPOLOGY),
356
                                .V (V),     // vc_num_per_port
357
                                .P (P),     // router port num
358
                                .Fw (Fw),
359
                                .MUX_TYPE (MUX_TYPE),
360
                                .SSA_EN (SSA_EN),
361 56 alirezamon
                                .SELF_LOOP_EN(SELF_LOOP_EN)
362 48 alirezamon
                        )
363
                        the_crossbar
364
                        (
365
                                .granted_dest_port_all (granted_dest_port_all_delayed),
366
                                .flit_in_all (iport_flit_out_all),
367
                                .ssa_flit_wr_all (ssa_flit_wr_all),
368
                                .flit_out_all (crossbar_flit_out_all),
369 56 alirezamon
                                .flit_out_wr_all (crossbar_flit_out_wr_all)
370 48 alirezamon
                        );
371
 
372
                //link reg
373
                generate
374
                //if( ADD_PIPREG_AFTER_CROSSBAR == 1 || SMART_EN == 1) begin :link_reg
375
                if( ADD_PIPREG_AFTER_CROSSBAR == 1 ) begin :link_reg
376
 
377
 
378
                        reg [PFw-1 : 0] flit_out_all_pipe;
379
                        reg [P-1 : 0] flit_out_wr_all_pipe;
380 54 alirezamon
 
381
                        pronoc_register #(.W(PFw)) reg1 (.in(crossbar_flit_out_all    ), .out(flit_out_all_pipe), .reset(reset), .clk(clk));
382
                        pronoc_register #(.W(P)  ) reg2 (.in(crossbar_flit_out_wr_all ), .out(flit_out_wr_all_pipe), .reset(reset), .clk(clk));
383
 
384 48 alirezamon
 
385
                        assign link_flit_out_all    = flit_out_all_pipe;
386
                        assign link_flit_out_wr_all = flit_out_wr_all_pipe;
387
 
388
 
389
                end else begin :no_link_reg
390
 
391
                        assign    link_flit_out_all     =   crossbar_flit_out_all;
392
                        assign    link_flit_out_wr_all  =   crossbar_flit_out_wr_all;
393
 
394
                end
395
 
396
 
397
                /* verilator lint_off WIDTH */
398
                if (SWA_ARBITER_TYPE != "RRA" ) begin : wrra_
399
                /* verilator lint_on WIDTH */
400
 
401
                        wire [WP-1 : 0] contention_all;
402
                        wire [WP-1 : 0] limited_oport_weight_all;
403
 
404
                        wrra_contention_gen #(
405
                                .WEIGHTw(WEIGHTw),
406
                                .WRRA_CONFIG_INDEX(WRRA_CONFIG_INDEX),
407
                                .V(V),
408
                                .P(P),
409
                                .SELF_LOOP_EN(SELF_LOOP_EN)
410
                        )
411
                        contention_gen
412
                        (
413
                                .limited_oport_weight_all(limited_oport_weight_all),
414
                                .dest_port_all(dest_port_all),
415
                                .ivc_request_all(ivc_request_all),
416
                                .ovc_is_assigned_all(ovc_is_assigned_all),
417
                                .contention_all(contention_all),
418
                                .iport_weight_all(iport_weight_all),
419
                                .oports_weight_all(oports_weight_all)
420
 
421
                        );
422
 
423
                        weights_update #(
424 56 alirezamon
                                .NOC_ID(NOC_ID),
425 48 alirezamon
                                .ARBITER_TYPE(SWA_ARBITER_TYPE),
426
                                .V(V),
427
                                .P(P),
428
                                .Fw(Fw),
429
                                .WEIGHTw(WEIGHTw),
430
                                .WRRA_CONFIG_INDEX(WRRA_CONFIG_INDEX),
431
                                .C(C),
432
                                .TOPOLOGY(TOPOLOGY),
433
                                .EAw(EAw),
434
                                .DSTPw(DSTPw),
435
                                .ADD_PIPREG_AFTER_CROSSBAR(ADD_PIPREG_AFTER_CROSSBAR)
436
 
437
                        )
438
                        updater
439
                        (
440
                                .limited_oports_weight(limited_oport_weight_all),
441
                                .refresh_w_counter(refresh_w_counter),
442
                                .iport_weight_all(iport_weight_all),
443
                                .contention_all(contention_all),
444
                                .flit_in_all(link_flit_out_all),
445
                                .flit_out_all(flit_out_all),
446
                                .flit_out_wr_all(flit_out_wr_all),
447
                                .clk(clk),
448
                                .reset(reset)
449
                        );
450
 
451
        end // WRRA
452
        else begin : rra_
453
                assign flit_out_all  =  link_flit_out_all;
454
                assign refresh_w_counter = 1'b0;
455
        end
456
        endgenerate
457
                assign  flit_out_wr_all = link_flit_out_wr_all;
458
 
459
 
460
                //synthesis translate_off
461
                //synopsys  translate_off
462
                generate
463
                /* verilator lint_off WIDTH */
464
                if(DEBUG_EN && TOPOLOGY == "MESH")begin :dbg
465
                /* verilator lint_on WIDTH */
466
                debug_mesh_edges #(
467
                        .T1(T1),
468
                        .T2(T2),
469
                        .T3(T3),
470
                        .T4(T4),
471
                        .RAw(RAw),
472
                        .P(P)
473
                )
474
                debug_edges
475
                (
476
                        .clk(clk),
477
                        .current_r_addr(current_r_addr),
478
                        .flit_out_wr_all(flit_out_wr_all)
479
                );
480
        end// DEBUG
481
                endgenerate
482
                // synopsys  translate_on
483
                // synthesis translate_on
484
 
485
 
486
 
487
                // for testing the route path
488
 
489
 
490
 
491
                // synthesis translate_off
492
                // synopsys  translate_off
493
                `ifdef MONITORE_PATH
494
 
495
 
496
                reg[P-1 :0] t1,t2;
497
                generate
498
                        for (i=0;i
499
 
500
 
501
                                always @(posedge clk) begin
502 56 alirezamon
                                        if(`pronoc_reset)begin
503 48 alirezamon
                                                t1[i]<=1'b0;
504
                                                t2[i]<=1'b0;
505
                                        end else begin
506 54 alirezamon
                                                if(flit_out_wr_all[i]>0 && t2[i]==0)begin
507
                                                        $display("%t :Out router (id=%d, addr=%h, port=%d), flitout=%h",$time,current_r_id,current_r_addr,i,flit_out_all[(i+1)*Fw-1 : i*Fw]);
508
                                                        t2[i]<=1;
509
                                                end
510
 
511 48 alirezamon
                                                if(flit_in_wr_all[i]>0 && t1[i]==0)begin
512 54 alirezamon
                                                        $display("%t :In router (id=%d, addr=%h, port=%d), flitin=%h",$time,current_r_id,current_r_addr,i,flit_in_all[(i+1)*Fw-1 : i*Fw]);
513 48 alirezamon
                                                        t1[i]<=1;
514
                                                end
515 54 alirezamon
 
516 48 alirezamon
 
517
 
518
                                        end
519
                                end
520
                        end
521
                endgenerate
522
        `endif
523
 
524
 
525
 
526
        /*
527
 
528
 
529
 
530
    reg [10 :  0]  counter;
531
    reg [31 :  0]  flit_counter;
532
 
533 54 alirezamon
    always @ (`pronoc_clk_reset_edge )begin
534
                if(`pronoc_reset) begin
535 48 alirezamon
            flit_counter <=0;
536
            counter <= 0;
537
        end else begin
538
            if(flit_in_wr_all>0 )begin
539
                counter <=0;
540
                flit_counter<=flit_counter+1'b1;
541
 
542
            end else begin
543
                counter <= counter+1'b1;
544
                if( counter == 512 ) $display("%t : total flits received in (x=%d,Y=%d) is %d ",$time,current_r_addr,current_y,flit_counter);
545
            end
546
        end
547
    end
548
         */
549
 
550
 
551 55 alirezamon
//TRACE_DUMP_PER is defined in pronoc_def file
552
 
553
 
554
`ifdef TRACE_DUMP_PER_NoC
555
        pronoc_trace_dump #(
556 56 alirezamon
                .NOC_ID(NOC_ID),
557 55 alirezamon
                .P(P),
558
                .TRACE_DUMP_PER("NOC"), //NOC, ROUTER, PORT
559
                .CYCLE_REPORT(0) // 1 : enable, 0 : disable
560
 
561
        )dump1
562
        (
563
                .current_r_id(current_r_id),
564
                .chan_in(chan_in),
565
                .chan_out(chan_out),
566
                .clk(clk)
567
        );
568
`endif
569
`ifdef TRACE_DUMP_PER_ROUTER
570
        pronoc_trace_dump #(
571 56 alirezamon
                .NOC_ID(NOC_ID),
572 55 alirezamon
                .P(P),
573
                .TRACE_DUMP_PER("ROUTER"), //NOC, ROUTER, PORT
574
                .CYCLE_REPORT(0) // 1 : enable, 0 : disable
575
 
576
        )dump2
577
        (
578
                .current_r_id(current_r_id),
579
                .chan_in(chan_in),
580
                .chan_out(chan_out),
581
                .clk(clk)
582
        );
583
`endif
584
`ifdef TRACE_DUMP_PER_PORT
585
        pronoc_trace_dump #(
586 56 alirezamon
                .NOC_ID(NOC_ID),
587 55 alirezamon
                .P(P),
588
                .TRACE_DUMP_PER("PORT"), //NOC, ROUTER, PORT
589
                .CYCLE_REPORT(0) // 1 : enable, 0 : disable
590
 
591
        )dump3
592
        (
593
                .current_r_id(current_r_id),
594
                .chan_in(chan_in),
595
                .chan_out(chan_out),
596
                .clk(clk)
597
        );
598
`endif
599
 
600
 
601
 
602
 
603 48 alirezamon
        //synopsys  translate_on
604
        //synthesis translate_on
605
 
606
 
607
endmodule
608
 
609 54 alirezamon
 
610
 
611 55 alirezamon
 
612
 
613 56 alirezamon
module credit_release_gen #(
614
        parameter NOC_ID=0,
615 54 alirezamon
        parameter CREDIT_NUM=4
616 56 alirezamon
)
617
(
618 54 alirezamon
        clk,
619
        reset,
620
        en,
621
        credit_out
622
);
623 56 alirezamon
 
624
        `NOC_CONF
625
 
626 54 alirezamon
        input  clk,     reset;
627
        input  en;
628
        output reg credit_out;
629
 
630
        localparam W=log2(CREDIT_NUM +1);
631
 
632
        reg [W-1 : 0] counter;
633
        wire counter_is_zero = counter=={W{1'b0}};
634
        wire counter_is_max = counter==CREDIT_NUM;
635
        wire counter_incr = (en & counter_is_zero ) | (~counter_is_zero & ~counter_is_max);
636
 
637
 
638
 
639
 
640
        always @ (`pronoc_clk_reset_edge )begin
641
                if(`pronoc_reset) begin
642
                        counter <= {W{1'b0}};
643
                        credit_out<=1'b0;
644
                end else begin
645
                        if(counter_incr) begin
646
                                counter<= counter +1'b1;
647
                                credit_out<=1'b1;
648
                        end else begin
649
                                credit_out<=1'b0;
650
                        end
651
                end
652
        end
653
 
654
 
655 56 alirezamon
endmodule
656 54 alirezamon
 
657 55 alirezamon
 
658
 
659
 
660
//synthesis translate_off
661 56 alirezamon
module pronoc_trace_dump #(
662
        parameter NOC_ID=0,
663 55 alirezamon
        parameter P = 6,
664
        parameter TRACE_DUMP_PER= "ROUTER", //NOC, ROUTER, PORT
665
        parameter CYCLE_REPORT=0 // 1 : enable, 0 : disable
666 56 alirezamon
)
667
(
668 55 alirezamon
        current_r_id,
669
        chan_in,
670
        chan_out,
671
        clk
672
);
673 56 alirezamon
 
674 55 alirezamon
 
675 56 alirezamon
        `NOC_CONF
676
 
677 55 alirezamon
        input  [31:0] current_r_id;
678
        input   flit_chanel_t chan_in  [P-1 : 0];
679
        input   flit_chanel_t chan_out [P-1 : 0];
680
        input   clk;
681
 
682
        pronoc_trace_dump_sub #(
683 56 alirezamon
                .NOC_ID(NOC_ID),
684 55 alirezamon
                .P(P),
685
                .TRACE_DUMP_PER(TRACE_DUMP_PER), //NOC, ROUTER, PORT
686
                .DIRECTION("in"), // in,out
687
                .CYCLE_REPORT(CYCLE_REPORT) // 1 : enable, 0 : disable
688
 
689
        )dump_in
690
        (
691
                .current_r_id(current_r_id),
692
                .chan_in(chan_in),
693
                .clk(clk)
694
        );
695
 
696
        pronoc_trace_dump_sub #(
697 56 alirezamon
                .NOC_ID(NOC_ID),
698 55 alirezamon
                .P(P),
699
                .TRACE_DUMP_PER(TRACE_DUMP_PER), //NOC, ROUTER, PORT
700
                .DIRECTION("out"), // in,out
701
                .CYCLE_REPORT(CYCLE_REPORT) // 1 : enable, 0 : disable
702
 
703
        )dump_out
704
        (
705
                .current_r_id(current_r_id),
706
                .chan_in(chan_out),
707
                .clk(clk)
708
        );
709
endmodule
710
 
711 56 alirezamon
module pronoc_trace_dump_sub #(
712
        parameter NOC_ID=0,
713 55 alirezamon
        parameter P = 6,
714
        parameter TRACE_DUMP_PER= "ROUTER", //NOC, ROUTER, PORT
715
        parameter DIRECTION="in", // in,out
716
        parameter CYCLE_REPORT=0 // 1 : enable, 0 : disable
717 56 alirezamon
) (
718 55 alirezamon
        current_r_id,
719
        chan_in,
720
        clk
721
);
722
 
723 56 alirezamon
 
724
 
725
        `NOC_CONF
726 55 alirezamon
 
727
 
728 56 alirezamon
 
729
        input  [31:0] current_r_id;
730
        input   flit_chanel_t chan_in  [P-1 : 0];
731
        input   clk;
732
 
733
        integer out;
734
        string fname [P-1 : 0];
735
 
736
        genvar p;
737
        generate
738
        for (p=0;p
739 55 alirezamon
        initial begin
740
        /* verilator lint_off WIDTH */
741
                if(TRACE_DUMP_PER == "PORT"  ) fname[p] = $sformatf("trace_dump_R%0d_P%0d.out",current_r_id,p);
742
                if(TRACE_DUMP_PER == "ROUTER") fname[p] = $sformatf("trace_dump_R%0d.out",current_r_id);
743 56 alirezamon
                if(TRACE_DUMP_PER == "NOC"   ) fname[p] = $sformatf("trace_dump.out");
744 55 alirezamon
        /* verilator lint_on WIDTH */
745
                out = $fopen(fname[p],"w");
746
                $fclose(out);
747
        end
748
 
749
 
750
        always @(posedge clk) begin
751
                if(chan_in[p].flit_wr) begin
752
                        out = $fopen(fname[p],"a");
753
                        if(CYCLE_REPORT) $fwrite(out,"%t:",$time);
754
                        $fwrite(out, "Flit %s: Port %0d, Payload: %h\n",DIRECTION, p, chan_in[p].flit);
755
                        $fclose(out);
756
                end
757
                if(chan_in[p].credit>0) begin
758
                        out = $fopen(fname[p],"a");
759
                        if(CYCLE_REPORT) $fwrite(out,"%t:",$time);
760
                        $fwrite(out, "credit %s:%h Port %0d\n",DIRECTION, chan_in[p].credit,p);
761
                        $fclose(out);
762
                end
763
        end
764
 
765 56 alirezamon
        end
766
        endgenerate
767 55 alirezamon
endmodule
768
//synthesis translate_on
769
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.