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/] [inout_ports.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
**      File: inout_ports.v
4
**
5
**      Copyright (C) 2014-2017  Alireza Monemi
6
**
7
**      This file is part of ProNoC
8
**
9
**      ProNoC ( stands for Prototype Network-on-chip)  is free software:
10
**      you can redistribute it and/or modify it under the terms of the GNU
11
**      Lesser General Public License as published by the Free Software Foundation,
12
**      either version 2 of the License, or (at your option) any later version.
13
**
14
**      ProNoC is distributed in the hope that it will be useful, but WITHOUT
15
**      ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
**      or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
17
**      Public License for more details.
18
**
19
**      You should have received a copy of the GNU Lesser General Public
20
**      License along with ProNoC. If not, see .
21
**
22
**
23
**      Description:
24
**      NoC router Input/output module
25
**
26
**************************************************************/
27
 
28 56 alirezamon
module inout_ports #(
29
    parameter NOC_ID=0,
30
    parameter P=5
31
) (
32 48 alirezamon
    current_r_addr,
33
    neighbors_r_addr,
34
    clk,
35
    reset,
36
 
37
    // to/from neighboring router
38
    flit_in_all,
39
    flit_in_wr_all,
40
    credit_out_all,
41
    credit_in_all,
42
    congestion_in_all,
43
    congestion_out_all,
44
    credit_init_val_in,
45
    credit_init_val_out,
46
 
47
    // from vsa: local vc/sw allocator
48
    vsa_ovc_allocated_all,
49
    granted_ovc_num_all,
50
    ivc_num_getting_ovc_grant,
51
    spec_ovc_num_all,
52
    nonspec_first_arbiter_granted_ivc_all,
53
    spec_first_arbiter_granted_ivc_all,
54
    nonspec_granted_dest_port_all,
55
    spec_granted_dest_port_all,
56
    granted_dest_port_all,
57
    any_ivc_sw_request_granted_all,
58
    any_ovc_granted_in_outport_all,
59
    granted_dst_is_from_a_single_flit_pck,
60
 
61
    // to vc/sw allocator
62
    dest_port_all,
63
    ovc_is_assigned_all,
64
    ivc_request_all,
65
    assigned_ovc_not_full_all,
66
    masked_ovc_request_all,
67
    vc_weight_is_consumed_all,
68
    iport_weight_is_consumed_all,
69
    flit_is_tail_all,
70
 
71
    // to crossbar
72
    flit_out_all,
73
    ssa_flit_wr_all,
74
    iport_weight_all,
75
    oports_weight_all,
76
    refresh_w_counter,
77
    crossbar_flit_out_wr_all,
78
 
79
    // status
80
    vsa_credit_decreased_all,
81
    vsa_ovc_released_all,
82
    ivc_info,
83
    ovc_info,
84
    oport_info,
85
    vsa_ctrl_in,
86
    smart_ctrl_in
87
);
88 56 alirezamon
 
89
        `NOC_CONF
90 48 alirezamon
 
91
    localparam
92
        PV = V * P,
93
        PVV = PV * V,
94
        P_1 = ( SELF_LOOP_EN=="NO")?  P-1 : P,
95
        PP_1 = P_1 * P,
96
        PVP_1 = PV * P_1,
97
        PFw = P * Fw,
98
        CONG_ALw = CONGw*P,    //  congestion width per router
99
        W = WEIGHTw,
100
        WP = W * P,
101
        WPP = WP * P,
102
        PVDSTPw= PV * DSTPw,
103
        PRAw= P * RAw;
104
 
105
 
106
    input [RAw-1 : 0] current_r_addr;
107
    input [PRAw-1: 0] neighbors_r_addr;
108
 
109
 
110
    input [PFw-1 : 0] flit_in_all;
111
    input [P-1 : 0] flit_in_wr_all;
112
    output[PV-1 : 0] credit_out_all;
113
    input [PV-1 : 0] credit_in_all;
114
    input [PV-1 : 0] vsa_ovc_allocated_all;
115
    input [PVV-1 : 0] granted_ovc_num_all;
116
 
117
 
118
 
119
    input [PV-1 : 0] ivc_num_getting_ovc_grant;
120
    input [PVV-1 : 0] spec_ovc_num_all;
121
    input [PV-1 : 0] nonspec_first_arbiter_granted_ivc_all;
122
    input [PV-1 : 0] spec_first_arbiter_granted_ivc_all;
123
    input [PP_1-1 : 0] nonspec_granted_dest_port_all;
124
    input [PP_1-1 : 0] spec_granted_dest_port_all;
125
    input [PP_1-1 : 0] granted_dest_port_all;
126
    input [P-1 : 0] any_ivc_sw_request_granted_all;
127
    input [P-1 : 0] any_ovc_granted_in_outport_all;
128
 
129
    input [CONG_ALw-1 : 0] congestion_in_all;
130
    output[CONG_ALw-1 : 0] congestion_out_all;
131
    output[PV-1 : 0] vc_weight_is_consumed_all;
132
    output[P-1 : 0] iport_weight_is_consumed_all;
133
    input [P-1 : 0] granted_dst_is_from_a_single_flit_pck;
134
 
135
 
136
    // to vc/sw allocator
137
    output [PVP_1-1 : 0] dest_port_all;
138
    output [PV-1 : 0] ovc_is_assigned_all;
139
    output [PV-1 : 0] ivc_request_all;
140
    output [PV-1 : 0] assigned_ovc_not_full_all;
141
    output [PVV-1: 0] masked_ovc_request_all;
142
    output [PV-1 : 0] flit_is_tail_all;
143
 
144
    // to crossbar
145
    output [PFw-1 : 0] flit_out_all;
146
    output [P-1 : 0] ssa_flit_wr_all;
147
    output [WP-1: 0] iport_weight_all;
148
    output [WPP-1:0] oports_weight_all;
149
    input refresh_w_counter;
150
    input [P-1 : 0] crossbar_flit_out_wr_all;
151
 
152
    input clk,reset;
153
 
154
    output  [PV-1 : 0] vsa_ovc_released_all;
155
    output  [PV-1 : 0] vsa_credit_decreased_all;
156 54 alirezamon
    output  ivc_info_t ivc_info    [P-1 : 0][V-1 : 0];
157
    output  ovc_info_t ovc_info    [P-1 : 0][V-1 : 0];
158 48 alirezamon
 
159
    output  oport_info_t oport_info  [P-1 : 0];
160
    input   smart_ctrl_t   smart_ctrl_in [P-1 : 0];
161
    input   vsa_ctrl_t   vsa_ctrl_in [P-1 : 0];
162
    input   [CRDTw-1 : 0 ] credit_init_val_in  [P-1 : 0][V-1 : 0];
163 56 alirezamon
    output  [CRDTw-1 : 0 ] credit_init_val_out [P-1 : 0][V-1 : 0];
164 48 alirezamon
 
165
 
166
    wire [PPSw-1 : 0] port_pre_sel;
167
    wire [PV-1 :  0]  swap_port_presel;
168 54 alirezamon
    wire [PV-1 : 0] reset_ivc_all;
169 48 alirezamon
    wire [PV-1 : 0] sel;
170
    wire [PV-1 : 0] ovc_avalable_all;
171
 
172 54 alirezamon
    wire [DSTPw-1 : 0] destport_clear [P-1 : 0][V-1 : 0];   // clear non preferable ports in adaptive routing
173 48 alirezamon
    wire [PV-1 : 0] ivc_num_getting_sw_grant;
174
 
175 56 alirezamon
    ssa_ctrl_t ssa_ctrl [P-1 : 0];
176 48 alirezamon
 
177
 
178 56 alirezamon
        input_ports #(
179
                .NOC_ID(NOC_ID),
180
        .P(P)
181
        ) the_input_port (
182 48 alirezamon
                .current_r_addr (current_r_addr),
183
                .neighbors_r_addr(neighbors_r_addr),
184
                .ivc_num_getting_sw_grant (ivc_num_getting_sw_grant ),
185
                .any_ivc_sw_request_granted_all (any_ivc_sw_request_granted_all),
186
                .flit_in_all (flit_in_all),
187
                .flit_in_wr_all (flit_in_wr_all),
188
                .reset_ivc_all (reset_ivc_all),
189
                .flit_is_tail_all (flit_is_tail_all),
190
                .ivc_request_all (ivc_request_all),
191
                .dest_port_all(dest_port_all),
192
                .flit_out_all (flit_out_all),
193
                .assigned_ovc_not_full_all(assigned_ovc_not_full_all),
194
                .ovc_is_assigned_all(ovc_is_assigned_all),
195
                .sel (sel),
196
                .port_pre_sel(port_pre_sel),
197
                .swap_port_presel(swap_port_presel),
198 54 alirezamon
                .credit_out_all(credit_out_all),
199 48 alirezamon
                // .lk_destination_encoded_all (lk_destination_encoded_all),
200
                .nonspec_first_arbiter_granted_ivc_all(nonspec_first_arbiter_granted_ivc_all),
201 54 alirezamon
                .destport_clear (destport_clear),
202 48 alirezamon
                .vc_weight_is_consumed_all (vc_weight_is_consumed_all),
203
                .iport_weight_is_consumed_all (iport_weight_is_consumed_all),
204
                .iport_weight_all(iport_weight_all),
205
                .oports_weight_all(oports_weight_all),
206
                .granted_dest_port_all(granted_dest_port_all),
207
                .refresh_w_counter(refresh_w_counter),
208
                .ivc_info(ivc_info),
209
                .smart_ctrl_in(smart_ctrl_in),
210
                .vsa_ctrl_in(vsa_ctrl_in),
211
                .ssa_ctrl_in(ssa_ctrl),
212
                .credit_init_val_out(credit_init_val_out),
213
                .reset (reset),
214
                .clk (clk)
215
        );
216
 
217
 
218
        output_ports #(
219 56 alirezamon
        .NOC_ID(NOC_ID),
220 48 alirezamon
                .P (P)
221 56 alirezamon
        ) output_ports (
222 48 alirezamon
                .vsa_ovc_allocated_all                      (vsa_ovc_allocated_all),
223
                .flit_is_tail_all                           (flit_is_tail_all),
224
                .dest_port_all                              (dest_port_all),
225
                .nonspec_granted_dest_port_all              (nonspec_granted_dest_port_all),
226
                .credit_in_all                              (credit_in_all),
227
                .nonspec_first_arbiter_granted_ivc_all      (nonspec_first_arbiter_granted_ivc_all),
228
                .ivc_num_getting_sw_grant                   (ivc_num_getting_sw_grant ),
229
                .ovc_avalable_all                           (ovc_avalable_all),
230
                .assigned_ovc_not_full_all                  (assigned_ovc_not_full_all),
231
                .port_pre_sel                               (port_pre_sel),//only valid for adaptive routing
232
                .congestion_in_all                          (congestion_in_all),//only valid for adaptive routing
233
                .granted_ovc_num_all                                            (granted_ovc_num_all),
234
 
235
                .granted_dst_is_from_a_single_flit_pck      (granted_dst_is_from_a_single_flit_pck),
236
                .reset                                      (reset),
237
                .clk                                        (clk),
238
                .crossbar_flit_out_wr_all                                       (crossbar_flit_out_wr_all),
239
                .any_ovc_granted_in_outport_all ( any_ovc_granted_in_outport_all),
240
                .vsa_ovc_released_all (vsa_ovc_released_all),
241
                .vsa_credit_decreased_all(vsa_credit_decreased_all),
242
                .oport_info (oport_info),
243 54 alirezamon
                .ivc_info(ivc_info),
244 48 alirezamon
                .ovc_info (ovc_info),
245
                .smart_ctrl_in(smart_ctrl_in),
246
                .vsa_ctrl_in(vsa_ctrl_in),
247
                .ssa_ctrl_in(ssa_ctrl),
248
                .credit_init_val_in(credit_init_val_in)
249
        );
250
 
251
 
252
    vc_alloc_request_gen #(
253 56 alirezamon
        .NOC_ID(NOC_ID),
254
        .P(P)
255
    ) vc_alloc_req_gen (
256 54 alirezamon
        .ivc_info(ivc_info),
257
        .ovc_avalable_all(ovc_avalable_all),
258 48 alirezamon
        .dest_port_decoded_all(dest_port_all),
259
        .masked_ovc_request_all(masked_ovc_request_all),
260 54 alirezamon
 
261 48 alirezamon
        .port_pre_sel(port_pre_sel),
262
        .swap_port_presel(swap_port_presel),
263
        .sel(sel),
264
        .reset(reset),
265
        .clk(clk),
266 54 alirezamon
        .destport_clear(destport_clear),
267 48 alirezamon
        .ivc_num_getting_ovc_grant(ivc_num_getting_ovc_grant),
268
        //.ssa_ivc_num_getting_ovc_grant_all(nla_ivc_num_getting_ovc_grant_all),
269
        .smart_ctrl_in (smart_ctrl_in),
270
        .ssa_ctrl_in (ssa_ctrl)
271
    );
272
 
273
 
274
   congestion_out_gen #(
275
        .P(P),
276
        .V(V),
277
        .ROUTE_TYPE(ROUTE_TYPE),
278
        .CONGESTION_INDEX(CONGESTION_INDEX),
279
        .CONGw(CONGw)
280
   )
281
   congestion_out
282
   (
283
        .ovc_avalable_all(ovc_avalable_all),
284
        .ivc_request_all(ivc_request_all),
285
        .ivc_num_getting_sw_grant(ivc_num_getting_sw_grant ),
286
        .congestion_out_all(congestion_out_all),
287
        .clk(clk),
288
        .reset(reset)
289
   );
290
 
291 54 alirezamon
 
292
 
293 48 alirezamon
 
294
 
295
 
296
 
297
   genvar i;
298
   generate
299
 
300
            /* verilator lint_off WIDTH */
301
                if( SSA_EN =="YES" ) begin : ssa
302
                /* verilator lint_on WIDTH */
303
                        ss_allocator #(
304 56 alirezamon
                                .NOC_ID(NOC_ID),
305
                .P(P)
306 48 alirezamon
                        )
307
                        the_ssa
308
                        (
309 54 alirezamon
                                .ivc_info(ivc_info),
310 55 alirezamon
                                .ovc_info(ovc_info),
311 48 alirezamon
                                .flit_in_wr_all(flit_in_wr_all),
312
                                .flit_in_all(flit_in_all),
313
                                .any_ivc_sw_request_granted_all(any_ivc_sw_request_granted_all),
314
                                .any_ovc_granted_in_outport_all(any_ovc_granted_in_outport_all),
315
                                .ovc_avalable_all(ovc_avalable_all),
316
                                .clk(clk),
317
                                .reset(reset),
318
                        .ssa_ctrl_o(ssa_ctrl)
319
                    );
320
 
321
                end else begin :non_ssa
322
                        for(i=0;i< P;i=i+1) begin :p_
323
                                assign  ssa_ctrl[i] = {SSA_CTRL_w{1'b0}};
324
                        end
325
                end
326
 
327
 
328
 
329
            for(i=0;i< P;i=i+1) begin :p_
330
                assign ssa_flit_wr_all [i] = ssa_ctrl[i].ssa_flit_wr;
331
            end//for
332
 
333
        //synthesis translate_off
334
        //synopsys  translate_off
335
        if(DEBUG_EN && MIN_PCK_SIZE >1 )begin :dbg
336
                wire [PV-1 : 0] non_vsa_ivc_num_getting_ovc_grant_all;
337
                integer kk;
338
                for(i=0;i< P;i=i+1) begin :p_
339
                        assign non_vsa_ivc_num_getting_ovc_grant_all [(i+1)*V-1 : i*V] = ssa_ctrl[i].ivc_num_getting_ovc_grant | smart_ctrl_in[i].ivc_num_getting_ovc_grant;
340
                end//for
341
                always @(posedge clk ) begin
342
                        for(kk=0; kk< PV; kk=kk+1'b1 ) if(reset_ivc_all[kk] & (ivc_num_getting_ovc_grant[kk] | non_vsa_ivc_num_getting_ovc_grant_all[kk])) begin
343
                                $display("%t: ERROR: the ovc %d released and allocat signal is asserted in the same clock cycle : %m",$time,kk);
344
                                $finish;
345
                        end
346
                        end
347
                end
348
                //synopsys  translate_on
349
                //synthesis translate_on
350
        endgenerate
351
endmodule
352
 
353
 
354
 
355
 
356
 
357
 /******************
358
 
359
    output_vc_status
360
 
361
 ******************/
362
 
363
 module output_vc_status #(
364
    parameter V =  4,
365
    parameter B =  16,
366
    parameter CAND_VC_SEL_MODE = 0,   // 0: use arbiteration between not full vcs, 1: select the vc with most availble free space
367
    parameter CRDTw = 4
368
)(
369
        credit_init_val_in,
370
        wr_in,
371
        credit_in,
372
        nearly_full_vc,
373
        full_vc,
374
        empty_vc,
375
        cand_vc,
376
        cand_wr_vc_en,
377
        clk,
378
        reset
379
);
380
 
381
 
382
        input   [V-1 : 0] [CRDTw-1 : 0 ] credit_init_val_in ;
383
        input   [V-1 :0] wr_in;
384
        input   [V-1 :0] credit_in;
385
        output  [V-1 :0] nearly_full_vc;
386
        output  [V-1 : 0] full_vc;
387
        output  [V-1 :0] empty_vc;
388 54 alirezamon
        output  [V-1 :0] cand_vc;
389 48 alirezamon
        input   cand_wr_vc_en;
390
        input   clk;
391
        input   reset;
392
 
393
 
394
    function integer log2;
395
      input integer number; begin
396
         log2=(number <=1) ? 1: 0;
397
         while(2**log2
398
            log2=log2+1;
399
         end
400
      end
401
    endfunction // log2
402
 
403
 
404
    localparam  DEPTH_WIDTH =   log2(B+1);
405
 
406
 
407 54 alirezamon
    logic  [DEPTH_WIDTH-1 : 0] credit    [V-1 : 0];
408
    logic  [DEPTH_WIDTH-1 : 0] credit_next    [V-1 : 0];
409 48 alirezamon
    wire  [V-1 : 0] cand_vc_next;
410
 
411
    wire  [V-1 :0] request;
412
 
413
    genvar i;
414
    generate
415
        for(i=0;i
416 54 alirezamon
 
417
 
418
 
419
 
420
                pronoc_register_reset_init #(
421
                                .W(DEPTH_WIDTH)
422
                        )reg1(
423
                                .in(credit_next[i]),
424
                                .reset(reset),
425
                                .clk(clk),
426
                                .out(credit[i]),
427
                                .reset_to(credit_init_val_in[i][DEPTH_WIDTH-1:0])
428
                        );
429
 
430
 
431
 
432
            always @ ( * )begin
433
                  credit_next[i] = credit [i];
434
                  if(  wr_in[i]  && ~credit_in[i])   credit_next[i] = credit[i]-1'b1;
435
                  if( ~wr_in[i]  &&  credit_in[i])   credit_next[i] = credit[i]+1'b1;
436 48 alirezamon
            end//always
437
 
438
            assign  full_vc[i]   = (credit[i] == {DEPTH_WIDTH{1'b0}});
439
            assign  nearly_full_vc[i]=  (credit[i] == 1) |  full_vc[i];
440
            assign  empty_vc[i]  = (credit[i] == credit_init_val_in[i][DEPTH_WIDTH-1:0]);
441
 
442
            assign  request[i]   = ~ nearly_full_vc[i] & cand_wr_vc_en;
443
        end//for
444
 
445
    endgenerate
446
 
447
 
448
            arbiter #(
449
                .ARBITER_WIDTH      (V)
450
                )
451
                the_nic_arbiter
452
                (
453
                    .clk                (clk),
454
                    .reset          (reset),
455
                    .request            (request),
456
                    .grant          (cand_vc_next),
457
                    .any_grant       ()
458
                );
459
 
460 54 alirezamon
    logic [V-1 : 0] cand_vc_ld_next;
461
        pronoc_register #(.W(V)) reg2 (.in(cand_vc_ld_next ), .out(cand_vc), .reset(reset), .clk(clk));
462
 
463
        always  @ ( *) begin
464
                cand_vc_ld_next = cand_vc;
465
                if(cand_wr_vc_en)    cand_vc_ld_next  =  cand_vc_next;
466
    end
467 48 alirezamon
 
468
endmodule
469
 
470
 
471
/*************************
472
    vc_alloc_request_gen
473
 
474
************************/
475
 
476
 
477 56 alirezamon
module  vc_alloc_request_gen #(
478
    parameter NOC_ID=0,
479
    parameter P=5
480
) (
481 54 alirezamon
        ivc_info,
482
        ovc_avalable_all,
483 48 alirezamon
    dest_port_decoded_all,
484
    masked_ovc_request_all,
485
    port_pre_sel,
486
    swap_port_presel,
487
    sel,
488
    reset,
489
    clk,
490 54 alirezamon
    destport_clear,
491 48 alirezamon
    ivc_num_getting_ovc_grant,
492
    smart_ctrl_in,
493
    ssa_ctrl_in
494
);
495 56 alirezamon
 
496
        `NOC_CONF
497 48 alirezamon
 
498
    localparam  P_1     = (SELF_LOOP_EN == "NO")?  P-1 : P,
499
                        PV      =   V       *   P,
500
                PVV     =   PV      *  V,
501
                PVP_1   =   PV      *   P_1,
502
                PVDSTPw= PV * DSTPw;
503
 
504 54 alirezamon
 
505
 
506 48 alirezamon
    input   [PV-1       :   0]  ovc_avalable_all;
507 54 alirezamon
    input   [PVP_1-1    :   0]  dest_port_decoded_all;
508 48 alirezamon
    output  [PVV-1      :   0]  masked_ovc_request_all;
509 54 alirezamon
 
510 48 alirezamon
    input   [PPSw-1 : 0] port_pre_sel;
511
    output  [PV-1   : 0] sel;
512
    output  [PV-1   : 0] swap_port_presel;
513
    input   reset;
514
    input   clk;
515 54 alirezamon
    output  [DSTPw-1 : 0] destport_clear [P-1 : 0][V-1 : 0];
516
 
517 48 alirezamon
    input   [PV-1 : 0] ivc_num_getting_ovc_grant;
518
    input   ssa_ctrl_t  ssa_ctrl_in [P-1: 0];
519
    input   smart_ctrl_t  smart_ctrl_in [P-1: 0];
520 54 alirezamon
    input   ivc_info_t   ivc_info    [P-1 : 0][V-1 : 0];
521
 
522
    wire   [PV-1       :   0]  ivc_request_all;
523
    wire   [PVDSTPw-1  :   0]  dest_port_encoded_all;
524
    wire   [PVV-1      :   0]  candidate_ovc_all;
525
    wire   [PV-1       :   0]  ovc_is_assigned_all;
526 48 alirezamon
 
527
    wire [PV-1 : 0] ovc_avalable_all_masked;
528 54 alirezamon
    wire [PV-1 : 0] non_vsa_ivc_num_getting_ovc_grant_all;
529
    wire [PVDSTPw-1 : 0] destport_clear_all;
530 48 alirezamon
 
531 54 alirezamon
    genvar i,j;
532 48 alirezamon
    generate
533
 
534
    for(i=0;i< P;i=i+1) begin :p_
535
                assign ovc_avalable_all_masked [(i+1)*V-1 : i*V] = (SMART_EN)?  ovc_avalable_all [(i+1)*V-1 : i*V] & ~smart_ctrl_in[i].mask_available_ovc : ovc_avalable_all [(i+1)*V-1 : i*V];
536
        assign non_vsa_ivc_num_getting_ovc_grant_all [(i+1)*V-1 : i*V] = ssa_ctrl_in[i].ivc_num_getting_ovc_grant | smart_ctrl_in[i].ivc_num_getting_ovc_grant;
537 54 alirezamon
        for(j=0;j< V;j=j+1) begin :V_
538
                assign ivc_request_all[i*V+j] = ivc_info[i][j].ivc_req;
539
                assign ovc_is_assigned_all[i*V+j] = ivc_info[i][j].ovc_is_assigned;
540
                assign dest_port_encoded_all [(i*V+j+1)*DSTPw-1  :  (i*V+j)*DSTPw]=ivc_info[i][j].dest_port_encoded;
541
                assign candidate_ovc_all[(i*V+j+1)*V-1  :  (i*V+j)*V]= ivc_info[i][j].candidate_ovc;
542
                assign destport_clear [i][j]=destport_clear_all [(i*V+j+1)*DSTPw-1  :  (i*V+j)*DSTPw];
543
        end
544 48 alirezamon
    end//for
545
 
546
 
547
 
548
    /* verilator lint_off WIDTH */
549
    if(ROUTE_TYPE == "DETERMINISTIC") begin : dtrmn
550
    /* verilator lint_on WIDTH */
551
 
552
        vc_alloc_request_gen_determinstic #(
553
                .P(P),
554
                .V(V),
555 54 alirezamon
                .SELF_LOOP_EN(SELF_LOOP_EN),
556
                .CAST_TYPE(CAST_TYPE)
557 48 alirezamon
        )
558
        vc_request_gen
559
        (
560
                .ovc_avalable_all(ovc_avalable_all_masked),
561
                .ivc_request_all(ivc_request_all),
562
                .ovc_is_assigned_all(ovc_is_assigned_all),
563
                .dest_port_in_all(dest_port_decoded_all),
564
                .masked_ovc_request_all(masked_ovc_request_all),
565
                .candidate_ovc_all(candidate_ovc_all)
566
        );
567
 
568
        assign swap_port_presel = {PV{1'bx}};
569
        assign destport_clear_all={PVDSTPw{1'b0}};
570
        assign sel = {PV{1'bx}};
571
 
572
    end else begin: adptv
573
 
574
      if(P==5 && SELF_LOOP_EN == "NO" )begin:sl_mesh // combine portsel and available VC mux as proposed in ProNoC paper
575
 
576
      mesh_torus_vc_alloc_request_gen_adaptive #(
577
        .ROUTE_TYPE(ROUTE_TYPE),
578
        .V(V),
579
        .DSTPw(DSTPw),
580
        .SSA_EN(SSA_EN),
581
        .ESCAP_VC_MASK(ESCAP_VC_MASK),
582
        .PPSw(PPSw)
583
      )
584
      vc_alloc_request_gen
585
      (
586
        .ovc_avalable_all(ovc_avalable_all_masked),
587
        .dest_port_coded_all(dest_port_encoded_all),
588
        .ivc_request_all(ivc_request_all),
589
        .ovc_is_assigned_all(ovc_is_assigned_all),
590
        .masked_ovc_request_all(masked_ovc_request_all),
591
        .candidate_ovc_all(candidate_ovc_all),
592
        .port_pre_sel(port_pre_sel),
593
        .swap_port_presel(swap_port_presel),
594
        .sel(sel),
595
        .destport_clear_all(destport_clear_all),
596
        .ivc_num_getting_ovc_grant(ivc_num_getting_ovc_grant),
597
        .ssa_ivc_num_getting_ovc_grant_all(non_vsa_ivc_num_getting_ovc_grant_all),
598
        .reset(reset),
599
        .clk(clk)
600
      );
601
 
602
      end else begin :ml_mesh // there are several local ports connected to one router or self loop is enabled
603
      //select the port first then select the available vc
604
 
605
 
606
 
607
         mesh_torus_dynamic_portsel_control #(
608
                .P(P),
609
                .ROUTE_TYPE(ROUTE_TYPE),
610
                .V(V),
611
                .DSTPw(DSTPw),
612
                .SSA_EN(SSA_EN),
613
                .PPSw(PPSw),
614
                .ESCAP_VC_MASK(ESCAP_VC_MASK)
615
         )
616
         dynamic_portsel_control
617
         (
618
                .dest_port_coded_all(dest_port_encoded_all),
619
                .ivc_request_all(ivc_request_all),
620
                .ovc_is_assigned_all(ovc_is_assigned_all),
621
                .port_pre_sel(port_pre_sel),
622
                .swap_port_presel(swap_port_presel),
623
                .masked_ovc_request_all(masked_ovc_request_all),
624
                .sel(sel),
625
                .destport_clear_all(destport_clear_all),
626
                .ivc_num_getting_ovc_grant(ivc_num_getting_ovc_grant),
627
                .ssa_ivc_num_getting_ovc_grant_all(non_vsa_ivc_num_getting_ovc_grant_all),
628
                .reset(reset),
629
                .clk(clk)
630
         );
631
 
632
        vc_alloc_request_gen_determinstic #(
633
            .P(P),
634
            .V(V),
635
            .SELF_LOOP_EN(SELF_LOOP_EN)
636
        )
637
        vc_request_gen
638
        (
639
            .ovc_avalable_all(ovc_avalable_all_masked),
640
            .ivc_request_all(ivc_request_all),
641
            .ovc_is_assigned_all(ovc_is_assigned_all),
642
            .dest_port_in_all(dest_port_decoded_all),
643
            .masked_ovc_request_all(masked_ovc_request_all),
644
            .candidate_ovc_all(candidate_ovc_all)
645
        );
646
 
647
 
648
      end
649
 
650
    end
651
    endgenerate
652
 
653
endmodule
654
 
655
 
656
module  vc_alloc_request_gen_determinstic #(
657
    parameter P = 5,
658
    parameter V = 4,
659 54 alirezamon
    parameter SELF_LOOP_EN="NO",
660
    parameter CAST_TYPE = "UNICAST"
661 48 alirezamon
 
662
)(
663
    ovc_avalable_all,
664
    candidate_ovc_all,
665
    ivc_request_all,
666
    ovc_is_assigned_all,
667
    dest_port_in_all,
668
    masked_ovc_request_all
669
);
670
 
671
        localparam  P_1     =  (SELF_LOOP_EN == "NO")?  P-1 : P,
672
                PV      =   V       *   P,
673
                PVV     =   PV      *   V,
674
                PVP_1   =   PV      *   P_1,
675
                VP_1    =   V       *   P_1;
676
 
677
    input   [PV-1       :   0]  ovc_avalable_all;
678
    input   [PV-1       :   0]  ivc_request_all;
679
    input   [PV-1       :   0]  ovc_is_assigned_all;
680
    input   [PVP_1-1    :   0]  dest_port_in_all;
681
    output  [PVV-1      :   0]  masked_ovc_request_all;
682
    input   [PVV-1      :   0]  candidate_ovc_all;
683
 
684
    wire    [PV-1       :   0]  non_assigned_ovc_request_all;
685
    wire    [VP_1-1     :   0]  ovc_avalable_perport        [P-1    :   0];
686
    wire    [VP_1-1     :   0]  ovc_avalable_ivc            [PV-1   :   0];
687
    wire    [P_1-1      :   0]  dest_port_ivc               [PV-1   :   0];
688
    wire    [V-1        :   0]  ovc_avb_muxed               [PV-1   :   0];
689
    wire    [V-1        :   0]  ovc_request_ivc             [PV-1   :   0];
690
 
691
    assign non_assigned_ovc_request_all =   ivc_request_all & ~ovc_is_assigned_all;
692
 
693
 
694
  genvar i;
695
 
696
generate
697 54 alirezamon
        if(SELF_LOOP_EN == "NO" ) begin :nslp
698 48 alirezamon
                //remove available ovc of receiver port
699
                for(i=0;i< P;i=i+1) begin :port_loop
700
                if(i==0) begin : first assign ovc_avalable_perport[i]=ovc_avalable_all [PV-1              :   V]; end
701
                else if(i==(P-1)) begin : last assign ovc_avalable_perport[i]=ovc_avalable_all [PV-V-1               :   0]; end
702
                else  begin : midle  assign ovc_avalable_perport[i]={ovc_avalable_all [PV-1  :   (i+1)*V],ovc_avalable_all [(i*V)-1  :   0]}; end
703
            end
704 54 alirezamon
    end else begin :slp
705 48 alirezamon
        for(i=0;i< P;i=i+1) begin :port_loop
706
                 assign ovc_avalable_perport[i]=ovc_avalable_all;
707
            end
708
    end
709
    // IVC loop
710
    for(i=0;i< PV;i=i+1) begin :total_vc_loop
711
        //separate input/output
712
        assign ovc_avalable_ivc[i]  =   ovc_avalable_perport[(i/V)];
713
        assign dest_port_ivc   [i]  =   dest_port_in_all [(i+1)*P_1-1  :   i*P_1   ];
714
        assign ovc_request_ivc [i]  = (non_assigned_ovc_request_all[i])? candidate_ovc_all  [(i+1)*V-1  :   i*V ]: {V{1'b0}};
715
 
716
        //available ovc multiplexer
717
        onehot_mux_1D #(
718
            .W       (V),
719
            .N      (P_1)
720
        )
721
        multiplexer
722
        (
723
            .in     (ovc_avalable_ivc   [i]),
724
            .out    (ovc_avb_muxed      [i]),
725
            .sel    (dest_port_ivc      [i])
726
 
727
        );
728
 
729
        // mask unavailable ovc from requests
730
        assign masked_ovc_request_all  [(i+1)*V-1   :   i*V ]     =   ovc_avb_muxed[i] & ovc_request_ivc [i];
731
 
732
    end
733
   endgenerate
734
endmodule
735
 
736
 
737
 

powered by: WebSVN 2.1.0

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