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 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
**      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 48 alirezamon
                                .flit_in_wr_all(flit_in_wr_all),
320
                                .flit_in_all(flit_in_all),
321
                                .any_ivc_sw_request_granted_all(any_ivc_sw_request_granted_all),
322
                                .any_ovc_granted_in_outport_all(any_ovc_granted_in_outport_all),
323
                                .ovc_avalable_all(ovc_avalable_all),
324
                                .clk(clk),
325
                                .reset(reset),
326
                        .ssa_ctrl_o(ssa_ctrl)
327
                    );
328
 
329
                end else begin :non_ssa
330
                        for(i=0;i< P;i=i+1) begin :p_
331
                                assign  ssa_ctrl[i] = {SSA_CTRL_w{1'b0}};
332
                        end
333
                end
334
 
335
 
336
 
337
            for(i=0;i< P;i=i+1) begin :p_
338
                assign ssa_flit_wr_all [i] = ssa_ctrl[i].ssa_flit_wr;
339
            end//for
340
 
341
        //synthesis translate_off
342
        //synopsys  translate_off
343
        if(DEBUG_EN && MIN_PCK_SIZE >1 )begin :dbg
344
                wire [PV-1 : 0] non_vsa_ivc_num_getting_ovc_grant_all;
345
                integer kk;
346
                for(i=0;i< P;i=i+1) begin :p_
347
                        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;
348
                end//for
349
                always @(posedge clk ) begin
350
                        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
351
                                $display("%t: ERROR: the ovc %d released and allocat signal is asserted in the same clock cycle : %m",$time,kk);
352
                                $finish;
353
                        end
354
                        end
355
                end
356
                //synopsys  translate_on
357
                //synthesis translate_on
358
        endgenerate
359
endmodule
360
 
361
 
362
 
363
 
364
 
365
 /******************
366
 
367
    output_vc_status
368
 
369
 ******************/
370
 
371
 module output_vc_status #(
372
    parameter V =  4,
373
    parameter B =  16,
374
    parameter CAND_VC_SEL_MODE = 0,   // 0: use arbiteration between not full vcs, 1: select the vc with most availble free space
375
    parameter CRDTw = 4
376
)(
377
        credit_init_val_in,
378
        wr_in,
379
        credit_in,
380
        nearly_full_vc,
381
        full_vc,
382
        empty_vc,
383
        cand_vc,
384
        cand_wr_vc_en,
385
        clk,
386
        reset
387
);
388
 
389
 
390
        input   [V-1 : 0] [CRDTw-1 : 0 ] credit_init_val_in ;
391
        input   [V-1 :0] wr_in;
392
        input   [V-1 :0] credit_in;
393
        output  [V-1 :0] nearly_full_vc;
394
        output  [V-1 : 0] full_vc;
395
        output  [V-1 :0] empty_vc;
396 54 alirezamon
        output  [V-1 :0] cand_vc;
397 48 alirezamon
        input   cand_wr_vc_en;
398
        input   clk;
399
        input   reset;
400
 
401
 
402
    function integer log2;
403
      input integer number; begin
404
         log2=(number <=1) ? 1: 0;
405
         while(2**log2
406
            log2=log2+1;
407
         end
408
      end
409
    endfunction // log2
410
 
411
 
412
    localparam  DEPTH_WIDTH =   log2(B+1);
413
 
414
 
415 54 alirezamon
    logic  [DEPTH_WIDTH-1 : 0] credit    [V-1 : 0];
416
    logic  [DEPTH_WIDTH-1 : 0] credit_next    [V-1 : 0];
417 48 alirezamon
    wire  [V-1 : 0] cand_vc_next;
418
 
419
    wire  [V-1 :0] request;
420
 
421
    genvar i;
422
    generate
423
        for(i=0;i
424 54 alirezamon
 
425
 
426
 
427
 
428
                pronoc_register_reset_init #(
429
                                .W(DEPTH_WIDTH)
430
                        )reg1(
431
                                .in(credit_next[i]),
432
                                .reset(reset),
433
                                .clk(clk),
434
                                .out(credit[i]),
435
                                .reset_to(credit_init_val_in[i][DEPTH_WIDTH-1:0])
436
                        );
437
 
438
 
439
 
440
            always @ ( * )begin
441
                  credit_next[i] = credit [i];
442
                  if(  wr_in[i]  && ~credit_in[i])   credit_next[i] = credit[i]-1'b1;
443
                  if( ~wr_in[i]  &&  credit_in[i])   credit_next[i] = credit[i]+1'b1;
444 48 alirezamon
            end//always
445
 
446
            assign  full_vc[i]   = (credit[i] == {DEPTH_WIDTH{1'b0}});
447
            assign  nearly_full_vc[i]=  (credit[i] == 1) |  full_vc[i];
448
            assign  empty_vc[i]  = (credit[i] == credit_init_val_in[i][DEPTH_WIDTH-1:0]);
449
 
450
            assign  request[i]   = ~ nearly_full_vc[i] & cand_wr_vc_en;
451
        end//for
452
 
453
    endgenerate
454
 
455
 
456
            arbiter #(
457
                .ARBITER_WIDTH      (V)
458
                )
459
                the_nic_arbiter
460
                (
461
                    .clk                (clk),
462
                    .reset          (reset),
463
                    .request            (request),
464
                    .grant          (cand_vc_next),
465
                    .any_grant       ()
466
                );
467
 
468 54 alirezamon
    logic [V-1 : 0] cand_vc_ld_next;
469
        pronoc_register #(.W(V)) reg2 (.in(cand_vc_ld_next ), .out(cand_vc), .reset(reset), .clk(clk));
470
 
471
        always  @ ( *) begin
472
                cand_vc_ld_next = cand_vc;
473
                if(cand_wr_vc_en)    cand_vc_ld_next  =  cand_vc_next;
474
    end
475 48 alirezamon
 
476
endmodule
477
 
478
 
479
/*************************
480
    vc_alloc_request_gen
481
 
482
************************/
483
 
484
 
485
module  vc_alloc_request_gen
486
import pronoc_pkg::*;
487
#(
488
 
489
    parameter P = 5
490
 
491
)(
492 54 alirezamon
        ivc_info,
493
        ovc_avalable_all,
494 48 alirezamon
    dest_port_decoded_all,
495
    masked_ovc_request_all,
496
    port_pre_sel,
497
    swap_port_presel,
498
    sel,
499
    reset,
500
    clk,
501 54 alirezamon
    destport_clear,
502 48 alirezamon
    ivc_num_getting_ovc_grant,
503
    smart_ctrl_in,
504
    ssa_ctrl_in
505
);
506
 
507
    localparam  P_1     = (SELF_LOOP_EN == "NO")?  P-1 : P,
508
                        PV      =   V       *   P,
509
                PVV     =   PV      *  V,
510
                PVP_1   =   PV      *   P_1,
511
                PVDSTPw= PV * DSTPw;
512
 
513 54 alirezamon
 
514
 
515 48 alirezamon
    input   [PV-1       :   0]  ovc_avalable_all;
516 54 alirezamon
    input   [PVP_1-1    :   0]  dest_port_decoded_all;
517 48 alirezamon
    output  [PVV-1      :   0]  masked_ovc_request_all;
518 54 alirezamon
 
519 48 alirezamon
    input   [PPSw-1 : 0] port_pre_sel;
520
    output  [PV-1   : 0] sel;
521
    output  [PV-1   : 0] swap_port_presel;
522
    input   reset;
523
    input   clk;
524 54 alirezamon
    output  [DSTPw-1 : 0] destport_clear [P-1 : 0][V-1 : 0];
525
 
526 48 alirezamon
    input   [PV-1 : 0] ivc_num_getting_ovc_grant;
527
    input   ssa_ctrl_t  ssa_ctrl_in [P-1: 0];
528
    input   smart_ctrl_t  smart_ctrl_in [P-1: 0];
529 54 alirezamon
    input   ivc_info_t   ivc_info    [P-1 : 0][V-1 : 0];
530
 
531
    wire   [PV-1       :   0]  ivc_request_all;
532
    wire   [PVDSTPw-1  :   0]  dest_port_encoded_all;
533
    wire   [PVV-1      :   0]  candidate_ovc_all;
534
    wire   [PV-1       :   0]  ovc_is_assigned_all;
535 48 alirezamon
 
536
    wire [PV-1 : 0] ovc_avalable_all_masked;
537 54 alirezamon
    wire [PV-1 : 0] non_vsa_ivc_num_getting_ovc_grant_all;
538
    wire [PVDSTPw-1 : 0] destport_clear_all;
539 48 alirezamon
 
540 54 alirezamon
    genvar i,j;
541 48 alirezamon
    generate
542
 
543
    for(i=0;i< P;i=i+1) begin :p_
544
                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];
545
        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;
546 54 alirezamon
        for(j=0;j< V;j=j+1) begin :V_
547
                assign ivc_request_all[i*V+j] = ivc_info[i][j].ivc_req;
548
                assign ovc_is_assigned_all[i*V+j] = ivc_info[i][j].ovc_is_assigned;
549
                assign dest_port_encoded_all [(i*V+j+1)*DSTPw-1  :  (i*V+j)*DSTPw]=ivc_info[i][j].dest_port_encoded;
550
                assign candidate_ovc_all[(i*V+j+1)*V-1  :  (i*V+j)*V]= ivc_info[i][j].candidate_ovc;
551
                assign destport_clear [i][j]=destport_clear_all [(i*V+j+1)*DSTPw-1  :  (i*V+j)*DSTPw];
552
        end
553 48 alirezamon
    end//for
554
 
555
 
556
 
557
    /* verilator lint_off WIDTH */
558
    if(ROUTE_TYPE == "DETERMINISTIC") begin : dtrmn
559
    /* verilator lint_on WIDTH */
560
 
561
        vc_alloc_request_gen_determinstic #(
562
                .P(P),
563
                .V(V),
564 54 alirezamon
                .SELF_LOOP_EN(SELF_LOOP_EN),
565
                .CAST_TYPE(CAST_TYPE)
566 48 alirezamon
        )
567
        vc_request_gen
568
        (
569
                .ovc_avalable_all(ovc_avalable_all_masked),
570
                .ivc_request_all(ivc_request_all),
571
                .ovc_is_assigned_all(ovc_is_assigned_all),
572
                .dest_port_in_all(dest_port_decoded_all),
573
                .masked_ovc_request_all(masked_ovc_request_all),
574
                .candidate_ovc_all(candidate_ovc_all)
575
        );
576
 
577
        assign swap_port_presel = {PV{1'bx}};
578
        assign destport_clear_all={PVDSTPw{1'b0}};
579
        assign sel = {PV{1'bx}};
580
 
581
    end else begin: adptv
582
 
583
      if(P==5 && SELF_LOOP_EN == "NO" )begin:sl_mesh // combine portsel and available VC mux as proposed in ProNoC paper
584
 
585
      mesh_torus_vc_alloc_request_gen_adaptive #(
586
        .ROUTE_TYPE(ROUTE_TYPE),
587
        .V(V),
588
        .DSTPw(DSTPw),
589
        .SSA_EN(SSA_EN),
590
        .ESCAP_VC_MASK(ESCAP_VC_MASK),
591
        .PPSw(PPSw)
592
      )
593
      vc_alloc_request_gen
594
      (
595
        .ovc_avalable_all(ovc_avalable_all_masked),
596
        .dest_port_coded_all(dest_port_encoded_all),
597
        .ivc_request_all(ivc_request_all),
598
        .ovc_is_assigned_all(ovc_is_assigned_all),
599
        .masked_ovc_request_all(masked_ovc_request_all),
600
        .candidate_ovc_all(candidate_ovc_all),
601
        .port_pre_sel(port_pre_sel),
602
        .swap_port_presel(swap_port_presel),
603
        .sel(sel),
604
        .destport_clear_all(destport_clear_all),
605
        .ivc_num_getting_ovc_grant(ivc_num_getting_ovc_grant),
606
        .ssa_ivc_num_getting_ovc_grant_all(non_vsa_ivc_num_getting_ovc_grant_all),
607
        .reset(reset),
608
        .clk(clk)
609
      );
610
 
611
      end else begin :ml_mesh // there are several local ports connected to one router or self loop is enabled
612
      //select the port first then select the available vc
613
 
614
 
615
 
616
         mesh_torus_dynamic_portsel_control #(
617
                .P(P),
618
                .ROUTE_TYPE(ROUTE_TYPE),
619
                .V(V),
620
                .DSTPw(DSTPw),
621
                .SSA_EN(SSA_EN),
622
                .PPSw(PPSw),
623
                .ESCAP_VC_MASK(ESCAP_VC_MASK)
624
         )
625
         dynamic_portsel_control
626
         (
627
                .dest_port_coded_all(dest_port_encoded_all),
628
                .ivc_request_all(ivc_request_all),
629
                .ovc_is_assigned_all(ovc_is_assigned_all),
630
                .port_pre_sel(port_pre_sel),
631
                .swap_port_presel(swap_port_presel),
632
                .masked_ovc_request_all(masked_ovc_request_all),
633
                .sel(sel),
634
                .destport_clear_all(destport_clear_all),
635
                .ivc_num_getting_ovc_grant(ivc_num_getting_ovc_grant),
636
                .ssa_ivc_num_getting_ovc_grant_all(non_vsa_ivc_num_getting_ovc_grant_all),
637
                .reset(reset),
638
                .clk(clk)
639
         );
640
 
641
        vc_alloc_request_gen_determinstic #(
642
            .P(P),
643
            .V(V),
644
            .SELF_LOOP_EN(SELF_LOOP_EN)
645
        )
646
        vc_request_gen
647
        (
648
            .ovc_avalable_all(ovc_avalable_all_masked),
649
            .ivc_request_all(ivc_request_all),
650
            .ovc_is_assigned_all(ovc_is_assigned_all),
651
            .dest_port_in_all(dest_port_decoded_all),
652
            .masked_ovc_request_all(masked_ovc_request_all),
653
            .candidate_ovc_all(candidate_ovc_all)
654
        );
655
 
656
 
657
      end
658
 
659
    end
660
    endgenerate
661
 
662
endmodule
663
 
664
 
665
module  vc_alloc_request_gen_determinstic #(
666
    parameter P = 5,
667
    parameter V = 4,
668 54 alirezamon
    parameter SELF_LOOP_EN="NO",
669
    parameter CAST_TYPE = "UNICAST"
670 48 alirezamon
 
671
)(
672
    ovc_avalable_all,
673
    candidate_ovc_all,
674
    ivc_request_all,
675
    ovc_is_assigned_all,
676
    dest_port_in_all,
677
    masked_ovc_request_all
678
);
679
 
680
        localparam  P_1     =  (SELF_LOOP_EN == "NO")?  P-1 : P,
681
                PV      =   V       *   P,
682
                PVV     =   PV      *   V,
683
                PVP_1   =   PV      *   P_1,
684
                VP_1    =   V       *   P_1;
685
 
686
    input   [PV-1       :   0]  ovc_avalable_all;
687
    input   [PV-1       :   0]  ivc_request_all;
688
    input   [PV-1       :   0]  ovc_is_assigned_all;
689
    input   [PVP_1-1    :   0]  dest_port_in_all;
690
    output  [PVV-1      :   0]  masked_ovc_request_all;
691
    input   [PVV-1      :   0]  candidate_ovc_all;
692
 
693
    wire    [PV-1       :   0]  non_assigned_ovc_request_all;
694
    wire    [VP_1-1     :   0]  ovc_avalable_perport        [P-1    :   0];
695
    wire    [VP_1-1     :   0]  ovc_avalable_ivc            [PV-1   :   0];
696
    wire    [P_1-1      :   0]  dest_port_ivc               [PV-1   :   0];
697
    wire    [V-1        :   0]  ovc_avb_muxed               [PV-1   :   0];
698
    wire    [V-1        :   0]  ovc_request_ivc             [PV-1   :   0];
699
 
700
    assign non_assigned_ovc_request_all =   ivc_request_all & ~ovc_is_assigned_all;
701
 
702
 
703
  genvar i;
704
 
705
generate
706 54 alirezamon
        if(SELF_LOOP_EN == "NO" ) begin :nslp
707 48 alirezamon
                //remove available ovc of receiver port
708
                for(i=0;i< P;i=i+1) begin :port_loop
709
                if(i==0) begin : first assign ovc_avalable_perport[i]=ovc_avalable_all [PV-1              :   V]; end
710
                else if(i==(P-1)) begin : last assign ovc_avalable_perport[i]=ovc_avalable_all [PV-V-1               :   0]; end
711
                else  begin : midle  assign ovc_avalable_perport[i]={ovc_avalable_all [PV-1  :   (i+1)*V],ovc_avalable_all [(i*V)-1  :   0]}; end
712
            end
713 54 alirezamon
    end else begin :slp
714 48 alirezamon
        for(i=0;i< P;i=i+1) begin :port_loop
715
                 assign ovc_avalable_perport[i]=ovc_avalable_all;
716
            end
717
    end
718
    // IVC loop
719
    for(i=0;i< PV;i=i+1) begin :total_vc_loop
720
        //separate input/output
721
        assign ovc_avalable_ivc[i]  =   ovc_avalable_perport[(i/V)];
722
        assign dest_port_ivc   [i]  =   dest_port_in_all [(i+1)*P_1-1  :   i*P_1   ];
723
        assign ovc_request_ivc [i]  = (non_assigned_ovc_request_all[i])? candidate_ovc_all  [(i+1)*V-1  :   i*V ]: {V{1'b0}};
724
 
725
        //available ovc multiplexer
726
        onehot_mux_1D #(
727
            .W       (V),
728
            .N      (P_1)
729
        )
730
        multiplexer
731
        (
732
            .in     (ovc_avalable_ivc   [i]),
733
            .out    (ovc_avb_muxed      [i]),
734
            .sel    (dest_port_ivc      [i])
735
 
736
        );
737
 
738
        // mask unavailable ovc from requests
739
        assign masked_ovc_request_all  [(i+1)*V-1   :   i*V ]     =   ovc_avb_muxed[i] & ovc_request_ivc [i];
740
 
741
    end
742
   endgenerate
743
endmodule
744
 
745
 
746
 

powered by: WebSVN 2.1.0

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