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 54

Go to most recent revision | 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
module router_two_stage
34
                import pronoc_pkg::*;
35
 
36
                # (
37
                        parameter P = 6     // router port num
38
                )(
39 54 alirezamon
                current_r_id,
40 48 alirezamon
                current_r_addr,// connected to constant parameter
41
 
42
                chan_in,
43
                chan_out,
44
 
45
                ctrl_in,
46
                ctrl_out,
47
 
48
                //internal router status
49
                ivc_info,
50
                ovc_info,
51
                iport_info,
52
                oport_info,
53
 
54
                smart_ctrl_in,
55
 
56
                clk,
57
                reset
58
 
59
                );
60
 
61
 
62
 
63
        // The current/neighbor routers addresses/port. These values are fixed in each router and they are supposed to be given as parameter.
64
        // However, in order to give an identical RTL code to each router, they are given as input ports. The identical RTL code reduces the
65
        // compilation time. Note that they wont be implemented as  input ports in the final synthesized code.
66
 
67
        input [RAw-1 :  0]  current_r_addr;
68 54 alirezamon
        input [31:0] current_r_id;
69 48 alirezamon
 
70
        input   flit_chanel_t chan_in  [P-1 : 0];
71
        output  flit_chanel_t chan_out [P-1 : 0];
72
        input   ctrl_chanel_t ctrl_in  [P-1 : 0];
73
        output  ctrl_chanel_t ctrl_out [P-1 : 0];
74
        input   clk,reset;
75
 
76
 
77
        output  ivc_info_t       ivc_info    [P-1 : 0][V-1 : 0];
78
        output  ovc_info_t   ovc_info    [P-1 : 0][V-1 : 0];
79
        output  iport_info_t iport_info  [P-1 : 0];
80
        output  oport_info_t oport_info  [P-1 : 0];
81
 
82
        input   smart_ctrl_t   smart_ctrl_in [P-1 : 0];
83
 
84
 
85
        vsa_ctrl_t   vsa_ctrl    [P-1 : 0];
86
 
87
        localparam
88
                PV = V * P,
89
                VV = V*V,
90
                PVV = PV * V,
91
                P_1 = ( SELF_LOOP_EN=="NO")?  P-1 : P,
92
                PP_1 = P_1 * P,
93
                PVP_1 = PV * P_1,
94
                PFw = P*Fw,
95
                CONG_ALw = CONGw* P,    //  congestion width per router
96
                W = WEIGHTw,
97
                WP = W * P,
98
                WPP=  WP * P,
99
                PRAw= P * RAw;
100
 
101
 
102 54 alirezamon
        flit_chanel_t chan_in_tmp  [P-1 : 0];
103 48 alirezamon
 
104
 
105
 
106
        wire  [PFw-1 :  0]  flit_in_all;
107
        wire  [P-1 :  0]  flit_in_wr_all;
108
        wire  [PV-1 :  0]  credit_out_all;
109
        wire  [CONG_ALw-1 :  0]  congestion_in_all;
110
 
111
        wire  [PFw-1 :  0]  flit_out_all;
112
        wire  [P-1 :  0]  flit_out_wr_all;
113
        wire  [PV-1 :  0]  credit_in_all;
114
        wire  [CONG_ALw-1 :  0]  congestion_out_all;
115
 
116 54 alirezamon
        wire  [PV-1 : 0] credit_release_out;
117 48 alirezamon
 
118
 
119
        // old router verilog code
120
 
121
 
122
 
123
        //internal wires
124
        wire  [PV-1 : 0] ovc_allocated_all;
125
        wire  [PVV-1 : 0] granted_ovc_num_all;
126
        wire  [PV-1 : 0] ivc_num_getting_sw_grant;
127
        wire  [PV-1 : 0] ivc_num_getting_ovc_grant;
128
        wire  [PVV-1 : 0] spec_ovc_num_all;
129
        wire  [PV-1 : 0] nonspec_first_arbiter_granted_ivc_all;
130
        wire  [PV-1 : 0] spec_first_arbiter_granted_ivc_all;
131
        wire  [PP_1-1 : 0] nonspec_granted_dest_port_all;
132
        wire  [PP_1-1 : 0] spec_granted_dest_port_all;
133
        wire  [PP_1-1 : 0] granted_dest_port_all;
134
        wire  [P-1 : 0] any_ivc_sw_request_granted_all;
135
        wire  [P-1 :  0] any_ovc_granted_in_outport_all;
136
        wire  [P-1 : 0] granted_dst_is_from_a_single_flit_pck;
137
        // to vc/sw allocator
138
        wire  [PVP_1-1 :  0] dest_port_all;
139
        wire  [PV-1 : 0] ovc_is_assigned_all;
140
        wire  [PV-1 : 0] ivc_request_all;
141
        wire  [PV-1 : 0] assigned_ovc_not_full_all;
142
        wire  [PVV-1: 0] masked_ovc_request_all;
143 54 alirezamon
 
144 48 alirezamon
        wire  [PV-1 : 0] vc_weight_is_consumed_all;
145
        wire  [P-1  : 0] iport_weight_is_consumed_all;
146
    wire  [PV-1 : 0] vsa_ovc_released_all;
147
    wire  [PV-1 : 0] vsa_credit_decreased_all;
148
 
149
        // to/from the crossbar
150
        wire  [PFw-1 : 0] iport_flit_out_all;
151
        wire  [P-1 : 0] ssa_flit_wr_all;
152 54 alirezamon
        logic [PP_1-1 : 0] granted_dest_port_all_delayed;
153 48 alirezamon
        wire  [PFw-1 :  0]  crossbar_flit_out_all;
154
        wire  [P-1   :  0]  crossbar_flit_out_wr_all;
155
        wire  [PFw-1 :  0]  link_flit_out_all;
156
        wire  [P-1   :  0]  link_flit_out_wr_all;
157
        wire  [PV-1  :  0] flit_is_tail_all;
158
 
159
 
160
        //to weight control
161
        wire [WP-1 : 0] iport_weight_all;
162
        wire [WPP-1: 0] oports_weight_all;
163
        wire refresh_w_counter;
164
 
165
 
166
        //ctrl port
167
        wire [PRAw-1  :  0] neighbors_r_addr;
168
        wire [CRDTw-1 : 0 ] credit_init_val_in  [P-1 : 0][V-1 : 0];
169
        wire [CRDTw-1 : 0 ] credit_init_val_out [P-1 : 0][V-1 : 0];
170
 
171
 
172
 
173 54 alirezamon
 
174
 
175
 
176 48 alirezamon
        genvar i,j;
177 54 alirezamon
        generate
178
                for (i=0; i
179
 
180
                        if(CAST_TYPE == "UNICAST") begin : uni
181
                                assign chan_in_tmp[i] = chan_in[i];
182
                        end else begin : multi
183
                                multicast_chan_in_process #(
184
                                        .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
                                        .CREDIT_NUM  (LB)
244
                                ) credit_release_gen (
245
                                        .clk         (clk        ),
246
                                        .reset       (reset      ),
247
                                        .en          (ctrl_in[i].credit_release_en[j] ),
248
                                        .credit_out  (credit_release_out[i*V+j] )
249
                                );
250
 
251
 
252
                                assign ctrl_out[i].credit_release_en[j] =1'b0;
253
                                assign credit_init_val_in[i][j]       = ctrl_in[i].credit_init_val[j];
254
                                assign ctrl_out[i].credit_init_val[j] = credit_init_val_out [i][j];
255
 
256
 
257
 
258
 
259 48 alirezamon
                        end
260
 
261 54 alirezamon
 
262
 
263 48 alirezamon
                end
264
        endgenerate
265
 
266
 
267
 
268
 
269
        inout_ports
270
                #(
271
                        .P(P)
272
                )
273
                the_inout_ports
274
                (
275
                        .current_r_addr(current_r_addr),
276
                        .neighbors_r_addr(neighbors_r_addr),
277
                        .flit_in_all(flit_in_all),
278
                        .flit_in_wr_all(flit_in_wr_all),
279
                        .credit_out_all(credit_out_all),
280
                        .credit_in_all(credit_in_all),
281 54 alirezamon
                        .masked_ovc_request_all(masked_ovc_request_all),
282 48 alirezamon
                        .granted_dst_is_from_a_single_flit_pck(granted_dst_is_from_a_single_flit_pck),
283
                        .vsa_ovc_allocated_all(ovc_allocated_all),
284
                        .granted_ovc_num_all(granted_ovc_num_all),
285
                        .ivc_num_getting_ovc_grant(ivc_num_getting_ovc_grant),
286
                        .spec_ovc_num_all(spec_ovc_num_all),
287
                        .nonspec_first_arbiter_granted_ivc_all(nonspec_first_arbiter_granted_ivc_all),
288
                        .spec_first_arbiter_granted_ivc_all(spec_first_arbiter_granted_ivc_all),
289
                        .nonspec_granted_dest_port_all(nonspec_granted_dest_port_all),
290
                        .spec_granted_dest_port_all(spec_granted_dest_port_all),
291
                        .granted_dest_port_all(granted_dest_port_all),
292
                        .any_ivc_sw_request_granted_all(any_ivc_sw_request_granted_all),
293
                        .any_ovc_granted_in_outport_all(any_ovc_granted_in_outport_all),
294
                        .dest_port_all(dest_port_all),
295
                        .ovc_is_assigned_all(ovc_is_assigned_all),
296
                        .ivc_request_all(ivc_request_all),
297
                        .assigned_ovc_not_full_all(assigned_ovc_not_full_all),
298
                        .flit_out_all(iport_flit_out_all),
299
                        .congestion_in_all(congestion_in_all),
300
                        .congestion_out_all(congestion_out_all),
301
                        //  .lk_destination_all(lk_destination_all),
302
                        .ssa_flit_wr_all(ssa_flit_wr_all),
303
                        .iport_weight_all(iport_weight_all),
304
                        .oports_weight_all(oports_weight_all),
305
                        .vc_weight_is_consumed_all(vc_weight_is_consumed_all),
306
                        .iport_weight_is_consumed_all(iport_weight_is_consumed_all),
307
                        .refresh_w_counter(refresh_w_counter),
308
                        .clk(clk),
309
                        .reset(reset),
310
                        .ivc_info(ivc_info),
311
                        .ovc_info(ovc_info),
312
                        .oport_info(oport_info),
313
                        .smart_ctrl_in(smart_ctrl_in),
314
                        .vsa_ctrl_in(vsa_ctrl),
315
                        .credit_init_val_in (credit_init_val_in),
316
                        .credit_init_val_out (credit_init_val_out),
317
                        .flit_is_tail_all(flit_is_tail_all),
318
                        .crossbar_flit_out_wr_all(crossbar_flit_out_wr_all),
319
                        .vsa_ovc_released_all(vsa_ovc_released_all),
320
                        .vsa_credit_decreased_all(vsa_credit_decreased_all)
321
                );
322
 
323
 
324
        combined_vc_sw_alloc #(
325 54 alirezamon
                        .P(P)
326 48 alirezamon
                )
327
                vsa
328
                (
329
                        .dest_port_all(dest_port_all),
330 54 alirezamon
                        .masked_ovc_request_all(masked_ovc_request_all),
331 48 alirezamon
                        .granted_dst_is_from_a_single_flit_pck(granted_dst_is_from_a_single_flit_pck),
332
                        .ovc_allocated_all(ovc_allocated_all),
333
                        .granted_ovc_num_all(granted_ovc_num_all),
334
                        .ivc_num_getting_ovc_grant(ivc_num_getting_ovc_grant),
335
                        .ivc_num_getting_sw_grant(ivc_num_getting_sw_grant),
336
                        .spec_first_arbiter_granted_ivc_all(spec_first_arbiter_granted_ivc_all),
337
                        .nonspec_first_arbiter_granted_ivc_all(nonspec_first_arbiter_granted_ivc_all),
338
                        .nonspec_granted_dest_port_all(nonspec_granted_dest_port_all),
339
                        .spec_granted_dest_port_all(spec_granted_dest_port_all),
340
                        .granted_dest_port_all(granted_dest_port_all),
341
                        .any_ivc_sw_request_granted_all(any_ivc_sw_request_granted_all),
342
                        .any_ovc_granted_in_outport_all(any_ovc_granted_in_outport_all),
343
                        .spec_ovc_num_all(spec_ovc_num_all),
344
                        // .lk_destination_all(lk_destination_all),
345
                        .vc_weight_is_consumed_all(vc_weight_is_consumed_all),
346
                        .iport_weight_is_consumed_all(iport_weight_is_consumed_all),
347 54 alirezamon
                        .ivc_info(ivc_info),
348 48 alirezamon
                        .clk(clk),
349
                        .reset(reset)
350
                );
351
 
352 54 alirezamon
        pronoc_register #(.W(PP_1)) reg2 (.in(granted_dest_port_all ), .out(granted_dest_port_all_delayed), .reset(reset), .clk(clk));
353 48 alirezamon
 
354 54 alirezamon
 
355 48 alirezamon
                crossbar #(
356
 
357
                                .TOPOLOGY(TOPOLOGY),
358
                                .V (V),     // vc_num_per_port
359
                                .P (P),     // router port num
360
                                .Fw (Fw),
361
                                .MUX_TYPE (MUX_TYPE),
362
                                .SSA_EN (SSA_EN),
363
                                .SELF_LOOP_EN(SELF_LOOP_EN)
364
 
365
                        )
366
                        the_crossbar
367
                        (
368
                                .granted_dest_port_all (granted_dest_port_all_delayed),
369
                                .flit_in_all (iport_flit_out_all),
370
                                .ssa_flit_wr_all (ssa_flit_wr_all),
371
                                .flit_out_all (crossbar_flit_out_all),
372
                                .flit_out_wr_all (crossbar_flit_out_wr_all)
373
 
374
                        );
375
 
376
                //link reg
377
                generate
378
                //if( ADD_PIPREG_AFTER_CROSSBAR == 1 || SMART_EN == 1) begin :link_reg
379
                if( ADD_PIPREG_AFTER_CROSSBAR == 1 ) begin :link_reg
380
 
381
 
382
                        reg [PFw-1 : 0] flit_out_all_pipe;
383
                        reg [P-1 : 0] flit_out_wr_all_pipe;
384 54 alirezamon
 
385
                        pronoc_register #(.W(PFw)) reg1 (.in(crossbar_flit_out_all    ), .out(flit_out_all_pipe), .reset(reset), .clk(clk));
386
                        pronoc_register #(.W(P)  ) reg2 (.in(crossbar_flit_out_wr_all ), .out(flit_out_wr_all_pipe), .reset(reset), .clk(clk));
387
 
388 48 alirezamon
 
389
                        assign link_flit_out_all    = flit_out_all_pipe;
390
                        assign link_flit_out_wr_all = flit_out_wr_all_pipe;
391
 
392
 
393
                end else begin :no_link_reg
394
 
395
                        assign    link_flit_out_all     =   crossbar_flit_out_all;
396
                        assign    link_flit_out_wr_all  =   crossbar_flit_out_wr_all;
397
 
398
                end
399
 
400
 
401
                /* verilator lint_off WIDTH */
402
                if (SWA_ARBITER_TYPE != "RRA" ) begin : wrra_
403
                /* verilator lint_on WIDTH */
404
 
405
                        wire [WP-1 : 0] contention_all;
406
                        wire [WP-1 : 0] limited_oport_weight_all;
407
 
408
                        wrra_contention_gen #(
409
                                .WEIGHTw(WEIGHTw),
410
                                .WRRA_CONFIG_INDEX(WRRA_CONFIG_INDEX),
411
                                .V(V),
412
                                .P(P),
413
                                .SELF_LOOP_EN(SELF_LOOP_EN)
414
                        )
415
                        contention_gen
416
                        (
417
                                .limited_oport_weight_all(limited_oport_weight_all),
418
                                .dest_port_all(dest_port_all),
419
                                .ivc_request_all(ivc_request_all),
420
                                .ovc_is_assigned_all(ovc_is_assigned_all),
421
                                .contention_all(contention_all),
422
                                .iport_weight_all(iport_weight_all),
423
                                .oports_weight_all(oports_weight_all)
424
 
425
                        );
426
 
427
                        weights_update #(
428
                                .ARBITER_TYPE(SWA_ARBITER_TYPE),
429
                                .V(V),
430
                                .P(P),
431
                                .Fw(Fw),
432
                                .WEIGHTw(WEIGHTw),
433
                                .WRRA_CONFIG_INDEX(WRRA_CONFIG_INDEX),
434
                                .C(C),
435
                                .TOPOLOGY(TOPOLOGY),
436
                                .EAw(EAw),
437
                                .DSTPw(DSTPw),
438
                                .ADD_PIPREG_AFTER_CROSSBAR(ADD_PIPREG_AFTER_CROSSBAR)
439
 
440
                        )
441
                        updater
442
                        (
443
                                .limited_oports_weight(limited_oport_weight_all),
444
                                .refresh_w_counter(refresh_w_counter),
445
                                .iport_weight_all(iport_weight_all),
446
                                .contention_all(contention_all),
447
                                .flit_in_all(link_flit_out_all),
448
                                .flit_out_all(flit_out_all),
449
                                .flit_out_wr_all(flit_out_wr_all),
450
                                .clk(clk),
451
                                .reset(reset)
452
                        );
453
 
454
        end // WRRA
455
        else begin : rra_
456
                assign flit_out_all  =  link_flit_out_all;
457
                assign refresh_w_counter = 1'b0;
458
        end
459
        endgenerate
460
                assign  flit_out_wr_all = link_flit_out_wr_all;
461
 
462
 
463
                //synthesis translate_off
464
                //synopsys  translate_off
465
                generate
466
                /* verilator lint_off WIDTH */
467
                if(DEBUG_EN && TOPOLOGY == "MESH")begin :dbg
468
                /* verilator lint_on WIDTH */
469
                debug_mesh_edges #(
470
                        .T1(T1),
471
                        .T2(T2),
472
                        .T3(T3),
473
                        .T4(T4),
474
                        .RAw(RAw),
475
                        .P(P)
476
                )
477
                debug_edges
478
                (
479
                        .clk(clk),
480
                        .current_r_addr(current_r_addr),
481
                        .flit_out_wr_all(flit_out_wr_all)
482
                );
483
        end// DEBUG
484
                endgenerate
485
                // synopsys  translate_on
486
                // synthesis translate_on
487
 
488
 
489
 
490
                // for testing the route path
491
 
492
 
493
 
494
                // synthesis translate_off
495
                // synopsys  translate_off
496
                `ifdef MONITORE_PATH
497
 
498
 
499
                reg[P-1 :0] t1,t2;
500
                generate
501
                        for (i=0;i
502
 
503
 
504
                                always @(posedge clk) begin
505
                                        if(reset)begin
506
                                                t1[i]<=1'b0;
507
                                                t2[i]<=1'b0;
508
                                        end else begin
509 54 alirezamon
                                                if(flit_out_wr_all[i]>0 && t2[i]==0)begin
510
                                                        $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]);
511
                                                        t2[i]<=1;
512
                                                end
513
 
514 48 alirezamon
                                                if(flit_in_wr_all[i]>0 && t1[i]==0)begin
515 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]);
516 48 alirezamon
                                                        t1[i]<=1;
517
                                                end
518 54 alirezamon
 
519 48 alirezamon
 
520
 
521
                                        end
522
                                end
523
                        end
524
                endgenerate
525
        `endif
526
 
527
 
528
 
529
        /*
530
 
531
 
532
 
533
    reg [10 :  0]  counter;
534
    reg [31 :  0]  flit_counter;
535
 
536 54 alirezamon
    always @ (`pronoc_clk_reset_edge )begin
537
                if(`pronoc_reset) begin
538 48 alirezamon
            flit_counter <=0;
539
            counter <= 0;
540
        end else begin
541
            if(flit_in_wr_all>0 )begin
542
                counter <=0;
543
                flit_counter<=flit_counter+1'b1;
544
 
545
            end else begin
546
                counter <= counter+1'b1;
547
                if( counter == 512 ) $display("%t : total flits received in (x=%d,Y=%d) is %d ",$time,current_r_addr,current_y,flit_counter);
548
            end
549
        end
550
    end
551
         */
552
 
553
 
554
        //synopsys  translate_on
555
        //synthesis translate_on
556
 
557
 
558
endmodule
559
 
560 54 alirezamon
 
561
 
562
module credit_release_gen
563
        import pronoc_pkg::*;
564
#(
565
        parameter CREDIT_NUM=4
566
)(
567
        clk,
568
        reset,
569
        en,
570
        credit_out
571
);
572
        input  clk,     reset;
573
        input  en;
574
        output reg credit_out;
575
 
576
        localparam W=log2(CREDIT_NUM +1);
577
 
578
        reg [W-1 : 0] counter;
579
        wire counter_is_zero = counter=={W{1'b0}};
580
        wire counter_is_max = counter==CREDIT_NUM;
581
        wire counter_incr = (en & counter_is_zero ) | (~counter_is_zero & ~counter_is_max);
582
 
583
 
584
 
585
 
586
        always @ (`pronoc_clk_reset_edge )begin
587
                if(`pronoc_reset) begin
588
                        counter <= {W{1'b0}};
589
                        credit_out<=1'b0;
590
                end else begin
591
                        if(counter_incr) begin
592
                                counter<= counter +1'b1;
593
                                credit_out<=1'b1;
594
                        end else begin
595
                                credit_out<=1'b0;
596
                        end
597
                end
598
        end
599
 
600
 
601
endmodule
602
 

powered by: WebSVN 2.1.0

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