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 55

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

powered by: WebSVN 2.1.0

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