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 48

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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