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/] [comb_nonspec.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
 
3
/**********************************************************************
4
**      File: comb-nonspec.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
**      VC allocator combined with non-speculative switch
26
**      allocator where the free VC availability is checked at
27
**      the beginning of switch allocation (comb-nonspec).
28
**
29
***********************************************************************/
30
 
31
 
32
module comb_nonspec_allocator
33
   import pronoc_pkg::*;
34
#(
35
    parameter P = 5 //port number
36
)
37
(
38
    //VC allocator
39
    //input
40
    dest_port_all,         // from input port
41
    masked_ovc_request_all,
42
    pck_is_single_flit_all,
43
 
44
 
45
    //output
46
    ovc_allocated_all,//to the output port
47
    granted_ovc_num_all, // to the input port
48
    ivc_num_getting_ovc_grant,
49
 
50
    //switch_alloc
51
    ivc_info,
52
    vc_weight_is_consumed_all,
53
    iport_weight_is_consumed_all,
54
 
55
    //output
56
    granted_dest_port_all,
57
    ivc_num_getting_sw_grant,
58
    nonspec_first_arbiter_granted_ivc_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
    // global
64
    clk,
65
    reset
66
 
67
);
68
 
69
    localparam
70
        P_1 = (SELF_LOOP_EN == "NO")? P-1 : P,
71
        PV = V * P,
72
        VV = V * V,
73
        VP_1 = V * P_1,
74
        PP_1 = P_1 * P,
75
        PVV = PV * V,
76
        PVP_1 = PV * P_1;
77
 
78
 
79
    input  ivc_info_t ivc_info [P-1 : 0][V-1 : 0];
80
 
81
    input  [PVV-1 : 0] masked_ovc_request_all;
82
    input  [PVP_1-1 : 0] dest_port_all;
83
 
84
    input  [PV-1 : 0] pck_is_single_flit_all;
85
    output [PV-1 : 0] ovc_allocated_all;
86
    output [PVV-1 : 0] granted_ovc_num_all;
87
    output [PV-1 : 0] ivc_num_getting_ovc_grant;
88
 
89
 
90
    output [PP_1-1 : 0] granted_dest_port_all;
91
    output [PV-1 : 0] ivc_num_getting_sw_grant;
92
    output [P-1 : 0] any_ivc_sw_request_granted_all;
93
    output [P-1 : 0] any_ovc_granted_in_outport_all;
94
    output [PV-1 : 0] nonspec_first_arbiter_granted_ivc_all;
95
  //  input  [PVP_1-1 : 0] lk_destination_all;
96
    input  clk,reset;
97
    input  [PV-1 : 0] vc_weight_is_consumed_all;
98
    input  [P-1 : 0] iport_weight_is_consumed_all;
99
    output   [P-1 : 0] granted_dst_is_from_a_single_flit_pck;
100
 
101
 
102
 
103
    //internal wires switch allocator
104
    wire   [PV-1 : 0] first_arbiter_granted_ivc_all;
105
    wire   [PV-1 : 0] ivc_request_masked_all;
106
    wire   [P-1 : 0] any_cand_ovc_exsit;
107
 
108
 
109
    wire  [PV-1 : 0] ivc_request_all;
110
    wire  [PV-1 : 0] ovc_is_assigned_all;
111
    wire  [PV-1 : 0] assigned_ovc_not_full_all;
112
 
113
 
114
    assign nonspec_first_arbiter_granted_ivc_all = first_arbiter_granted_ivc_all;
115
 
116
 
117
    //nonspeculative switch allocator
118
    nonspec_sw_alloc #(
119
        .V(V),
120
        .P(P),
121
        .FIRST_ARBITER_EXT_P_EN(FIRST_ARBITER_EXT_P_EN),
122
        .SWA_ARBITER_TYPE (SWA_ARBITER_TYPE),
123
        .MIN_PCK_SIZE(MIN_PCK_SIZE),
124
        .SELF_LOOP_EN(SELF_LOOP_EN)
125
    )
126
    nonspeculative_sw_allocator
127
    (
128
 
129
        .ivc_granted_all (ivc_num_getting_sw_grant),
130
        .ivc_request_masked_all (ivc_request_masked_all),
131
        .pck_is_single_flit_all(pck_is_single_flit_all),
132
        .granted_dst_is_from_a_single_flit_pck(granted_dst_is_from_a_single_flit_pck),
133
        .dest_port_all (dest_port_all),
134
        .granted_dest_port_all (granted_dest_port_all),
135
        .first_arbiter_granted_ivc_all (first_arbiter_granted_ivc_all),
136
        .any_ivc_granted_all (any_ivc_sw_request_granted_all),
137
        .any_ovc_granted_all (any_ovc_granted_in_outport_all),
138
        .vc_weight_is_consumed_all(vc_weight_is_consumed_all),
139
        .iport_weight_is_consumed_all(iport_weight_is_consumed_all),
140
        .clk (clk),
141
        .reset (reset)
142
 
143
    );
144
 
145
 
146
 
147
    wire   [PVV-1 : 0] masked_ovc_request_all;
148
    wire   [V-1 : 0] masked_non_assigned_request    [PV-1 : 0] ;
149
    wire   [PV-1 : 0] masked_assigned_request;
150
    wire   [PV-1 : 0] assigned_ovc_request_all ;
151
    wire   [VV-1 : 0] masked_candidate_ovc_per_port    [P-1 : 0] ;
152
    wire   [V-1 : 0] first_arbiter_granted_ivc_per_port[P-1 : 0] ;
153
    wire   [V-1 : 0] candidate_ovc_local_num   [P-1 : 0] ;
154
    wire   [V-1 : 0] first_arbiter_ovc_granted        [PV-1 : 0];
155
    wire   [P_1-1 : 0] granted_dest_port_per_port        [P-1 : 0];
156
    wire   [VP_1-1 : 0] cand_ovc_granted           [P-1 : 0];
157
    wire   [P_1-1 : 0] ovc_allocated_all_gen   [PV-1 : 0];
158
    wire   [V-1 : 0] granted_ovc_local_num_per_port     [P-1 : 0];
159
    wire   [V-1 : 0] ivc_local_num_getting_ovc_grant[P-1 : 0];
160
    wire   [V : 0] summ_in [PV-1 : 0];
161
    wire   [V-1 : 0]  vc_pririty [PV-1 : 0] ;
162
 
163
    assign assigned_ovc_request_all      =   ivc_request_all &   ovc_is_assigned_all;
164
 
165
    genvar i,j;
166
 
167
 
168
    generate
169
    // IVC loop
170
    for(i=0;i< PV;i=i+1) begin :total_vc_loop
171
 
172
 
173
 
174
        // mask unavailable ovc from requests
175
        assign masked_non_assigned_request    [i]  =    masked_ovc_request_all [(i+1)*V-1 : i*V ];
176
        assign masked_assigned_request        [i]  =    assigned_ovc_not_full_all [i] & assigned_ovc_request_all [i];
177
 
178
        // summing assigned and non-assigned VC requests
179
        assign summ_in[i] ={masked_non_assigned_request    [i],masked_assigned_request        [i]};
180
        assign ivc_request_masked_all[i] = | summ_in[i];
181
 
182
 
183
        //first level arbiter to candidate only one OVC
184
      //  if(VC_ARBITER_TYPE=="RRA")begin :round_robin
185
 
186
            arbiter #(
187
                .ARBITER_WIDTH(V)
188
              )
189
              ovc_arbiter
190
              (
191
                .clk        (clk),
192
                .reset        (reset),
193
                .request    (masked_non_assigned_request    [i]),
194
                .grant        (first_arbiter_ovc_granted[i]),
195
                .any_grant    ()
196
              );
197
       /*
198
        end  else begin :fixarb
199
 
200
            vc_priority_based_dest_port#(
201
                .P(P),
202
                .V(V)
203
             )
204
             priority_setting
205
             (
206
                .dest_port(lk_destination_all [((i+1)*P_1)-1 : i*P_1]),
207
                .vc_pririty(vc_pririty[i])
208
             );
209
 
210
 
211
 
212
            arbiter_ext_priority #(
213
              .ARBITER_WIDTH (V)
214
            )
215
            ovc_arbiter
216
            (
217
                 .request (masked_non_assigned_request    [i]),
218
                 .priority_in(vc_pririty[i]),
219
                 .grant(first_arbiter_ovc_granted[i]),
220
                 .any_grant()
221
              );
222
 
223
         end
224
       */
225
 
226
    end//for
227
 
228
    wire [P-1 : 0] ovc_assigned_local;
229
 
230
    for(i=0;i< P;i=i+1) begin :port_loop3
231
            for(j=0;j< V;j=j+1) begin :vc_loop
232
                //merge masked_candidate_ovc in each port
233
 
234
                assign ivc_request_all[i*V+j] = ivc_info[i][j].ivc_req;
235
                assign ovc_is_assigned_all[i*V+j] = ivc_info[i][j].ovc_is_assigned;
236
                assign assigned_ovc_not_full_all[i*V+j] =ivc_info[i][j].assigned_ovc_not_full;
237
 
238
 
239
                assign masked_candidate_ovc_per_port[i][(j+1)*V-1 : j*V] =    first_arbiter_ovc_granted    [i*V+j];
240
            end//for j
241
 
242
            assign first_arbiter_granted_ivc_per_port[i]=first_arbiter_granted_ivc_all[(i+1)*V-1 : i*V];
243
            assign granted_dest_port_per_port[i]=granted_dest_port_all[(i+1)*P_1-1 : i*P_1];
244
 
245
 
246
        // multiplex candidate OVC of first level switch allocatore winner
247
        onehot_mux_1D #(
248
            .W (V),
249
            .N (V)
250
        )
251
        multiplexer2
252
        (
253
                .in            (masked_candidate_ovc_per_port    [i]),
254
                .out            (candidate_ovc_local_num    [i]),
255
            .sel                (first_arbiter_granted_ivc_per_port        [i])
256
 
257
        );
258
 
259
 
260
 
261
        onehot_mux_1D #(
262
                        .W (1),
263
                        .N (V)
264
                )
265
                multiplexer2_1
266
                (
267
                        .in  (ovc_is_assigned_all[(i+1)*V-1 : i*V]),
268
                        .out (ovc_assigned_local[i]),
269
                        .sel (first_arbiter_granted_ivc_per_port [i])
270
 
271
                );
272
 
273
 
274
     //   assign any_cand_ovc_exsit[i] = | candidate_ovc_local_num    [i];
275
 
276
 
277
        //demultiplexer
278
        one_hot_demux #(
279
            .IN_WIDTH(V),
280
            .SEL_WIDTH(P_1)
281
        )
282
        demux1
283
        (
284
            .demux_sel(granted_dest_port_per_port [i]),//selectore
285
            .demux_in(candidate_ovc_local_num[i]),//repeated
286
            .demux_out(cand_ovc_granted [i])
287
        );
288
 
289
        assign granted_ovc_local_num_per_port    [i]=(any_ivc_sw_request_granted_all[i] )?  candidate_ovc_local_num[i] : {V{1'b0}};
290
        assign ivc_local_num_getting_ovc_grant    [i]= (any_ivc_sw_request_granted_all[i] & ~ovc_assigned_local[i])?     first_arbiter_granted_ivc_per_port [i] : {V{1'b0}};
291
        assign ivc_num_getting_ovc_grant   [(i+1)*V-1 : i*V] = ivc_local_num_getting_ovc_grant[i];
292
        for(j=0;j
293
            assign granted_ovc_num_all[(i*VV)+((j+1)*V)-1 : (i*VV)+(j*V)]=granted_ovc_local_num_per_port[i];
294
        end//j
295
    end//i
296
 
297
 
298
    for(i=0;i< PV;i=i+1) begin :total_vc_loop2
299
        for(j=0;j
300
            if(SELF_LOOP_EN == "NO") begin :nslp
301
                if((i/V)
302
                    assign ovc_allocated_all_gen[i][j-1] = cand_ovc_granted[j][i];
303
                end else if((i/V)>j) begin: hh
304
                    assign ovc_allocated_all_gen[i][j] = cand_ovc_granted[j][i-V];
305
 
306
                end
307
            end else begin : slp
308
                 assign ovc_allocated_all_gen[i][j] = cand_ovc_granted[j][i];
309
            end
310
        end//j
311
 
312
        assign ovc_allocated_all [i] = |ovc_allocated_all_gen[i];
313
 
314
    end//i
315
 
316
    endgenerate
317
 
318
endmodule
319
 
320
 
321
 
322
 
323
/**************************************************************
324
*
325
*             comb_nonspec_v2
326
*
327
* first arbiter has been shifted after first multiplexer
328
*
329
*
330
*********************************************************/
331
 
332
 
333
 
334
module  comb_nonspec_v2_allocator #(
335
    parameter V = 4,
336
    parameter P = 5,
337
    parameter FIRST_ARBITER_EXT_P_EN = 1,
338
    parameter SWA_ARBITER_TYPE = "WRRA",
339
    parameter MIN_PCK_SIZE=2, //minimum packet size in flits. The minimum value is 1.
340
    parameter SELF_LOOP_EN= "NO"
341
 
342
)(
343
    //VC allocator
344
    //input
345
    dest_port_all,      // from input port
346
    ovc_is_assigned_all,    //
347
    masked_ovc_request_all,
348
    pck_is_single_flit_all,
349
 
350
    //output
351
    ovc_allocated_all,//to the output port
352
    granted_ovc_num_all, // to the input port
353
    ivc_num_getting_ovc_grant,
354
 
355
    //switch_alloc
356
    ivc_request_all,
357
    assigned_ovc_not_full_all,
358
    vc_weight_is_consumed_all,
359
    iport_weight_is_consumed_all,
360
 
361
    //output
362
    granted_dest_port_all,
363
    ivc_num_getting_sw_grant,
364
    nonspec_first_arbiter_granted_ivc_all,
365
    any_ivc_sw_request_granted_all,
366
    any_ovc_granted_in_outport_all,
367
    granted_dst_is_from_a_single_flit_pck,
368
 
369
    // global
370
    clk,
371
    reset
372
 
373
);
374
 
375
 
376
    localparam
377
        P_1 = (SELF_LOOP_EN == "NO") ?  P-1 :P,
378
        PV = V * P,
379
        VV = V * V,
380
        VP_1 = V * P_1,
381
        PP_1 = P_1 * P,
382
        PVV = PV * V,
383
        PVP_1 = PV * P_1;
384
 
385
 
386
 
387
 
388
    input   [PVV-1 : 0] masked_ovc_request_all;
389
    input   [PVP_1-1 : 0] dest_port_all;
390
    input   [PV-1 : 0] ovc_is_assigned_all;
391
    input  [PV-1 : 0] pck_is_single_flit_all;
392
    output  [PV-1 : 0] ovc_allocated_all;
393
    output  [PVV-1 : 0] granted_ovc_num_all;
394
    output  [PV-1 : 0] ivc_num_getting_ovc_grant;
395
    input   [PV-1 : 0] ivc_request_all;
396
    input   [PV-1 : 0] assigned_ovc_not_full_all;
397
    output  [PP_1-1 : 0] granted_dest_port_all;
398
    output  [PV-1 : 0] ivc_num_getting_sw_grant;
399
    output  [P-1 : 0] any_ivc_sw_request_granted_all;
400
    output  [P-1 : 0] any_ovc_granted_in_outport_all;
401
    output  [PV-1 : 0] nonspec_first_arbiter_granted_ivc_all;
402
    input   clk,reset;
403
    input   [PV-1 : 0] vc_weight_is_consumed_all;
404
    input   [P-1 : 0] iport_weight_is_consumed_all;
405
 
406
    //internal wires switch allocator
407
    wire    [PV-1 : 0] first_arbiter_granted_ivc_all;
408
    wire    [PV-1 : 0] ivc_request_masked_all;
409
    wire    [P-1 : 0] any_cand_ovc_exsit;
410
    output  [P-1 : 0] granted_dst_is_from_a_single_flit_pck;
411
 
412
    assign nonspec_first_arbiter_granted_ivc_all = first_arbiter_granted_ivc_all;
413
 
414
    //nonspeculative switch allocator
415
    nonspec_sw_alloc #(
416
        .V(V),
417
        .P(P),
418
        .FIRST_ARBITER_EXT_P_EN(FIRST_ARBITER_EXT_P_EN),
419
        .SWA_ARBITER_TYPE(SWA_ARBITER_TYPE),
420
        .MIN_PCK_SIZE(MIN_PCK_SIZE)
421
    )
422
    nonspeculative_sw_allocator
423
    (
424
 
425
        .ivc_granted_all (ivc_num_getting_sw_grant),
426
        .ivc_request_masked_all (ivc_request_masked_all),
427
        .pck_is_single_flit_all(pck_is_single_flit_all),
428
        .granted_dst_is_from_a_single_flit_pck(granted_dst_is_from_a_single_flit_pck),
429
        .dest_port_all  (dest_port_all),
430
        .granted_dest_port_all (granted_dest_port_all),
431
        .first_arbiter_granted_ivc_all (first_arbiter_granted_ivc_all),
432
        //.first_arbiter_granted_port_all   (first_arbiter_granted_port_all),
433
        .any_ivc_granted_all (any_ivc_sw_request_granted_all),
434
        .any_ovc_granted_all (any_ovc_granted_in_outport_all),
435
        .vc_weight_is_consumed_all(vc_weight_is_consumed_all),
436
        .iport_weight_is_consumed_all(iport_weight_is_consumed_all),
437
        .clk  (clk),
438
        .reset (reset)
439
 
440
    );
441
 
442
    wire    [V-1 : 0] masked_non_assigned_request [PV-1 : 0] ;
443
    wire    [PV-1 : 0] masked_assigned_request;
444
    wire    [PV-1 : 0] assigned_ovc_request_all;
445
    wire    [VV-1 : 0] masked_non_assigned_request_per_port [P-1 : 0] ;
446
    wire    [V-1 : 0] first_arbiter_granted_ivc_per_port[P-1 : 0] ;
447
    wire    [V-1 : 0] candidate_ovc_local_num     [P-1 : 0] ;
448
    wire    [V-1 : 0] first_arbiter_ovc_granted [P-1:0];
449
    wire    [P_1-1 : 0] granted_dest_port_per_port  [P-1 : 0];
450
    wire    [VP_1-1 : 0] cand_ovc_granted    [P-1 : 0];
451
    wire    [P_1-1 : 0] ovc_allocated_all_gen   [PV-1 : 0];
452
    wire    [V-1 : 0] granted_ovc_local_num_per_port [P-1 : 0];
453
    wire    [V-1 : 0] ivc_local_num_getting_ovc_grant[P-1 : 0];
454
    wire    [V : 0] summ_in   [PV-1 : 0];
455
 
456
 
457
    assign assigned_ovc_request_all        =   ivc_request_all &   ovc_is_assigned_all;
458
 
459
    genvar i,j;
460
    generate
461
 
462
    // IVC loop
463
    for(i=0;i< PV;i=i+1) begin :total_vc_loop
464
 
465
        // mask unavailable ovc from requests
466
        assign masked_non_assigned_request  [i]  =   masked_ovc_request_all [(i+1)*V-1 : i*V ];
467
        assign masked_assigned_request      [i]  =   assigned_ovc_not_full_all[i] & assigned_ovc_request_all[i];
468
 
469
        // summing assigned and non-assigned VC requests
470
        assign summ_in[i]  ={masked_non_assigned_request   [i],masked_assigned_request     [i]};
471
        assign ivc_request_masked_all[i] = | summ_in[i];
472
 
473
    end//for
474
 
475
 
476
    for(i=0;i< P;i=i+1) begin :port_loop3
477
            for(j=0;j< V;j=j+1) begin :vc_loop
478
                //merge masked_candidate_ovc in each port
479
                assign masked_non_assigned_request_per_port[i][(j+1)*V-1 : j*V] =           masked_non_assigned_request [i*V+j];
480
            end//for j
481
 
482
            assign first_arbiter_granted_ivc_per_port[i]=first_arbiter_granted_ivc_all[(i+1)*V-1 : i*V];
483
 
484
            assign granted_dest_port_per_port[i]=granted_dest_port_all[(i+1)*P_1-1 : i*P_1];
485
 
486
 
487
        onehot_mux_1D #(
488
            .W  (V),
489
            .N  (V)
490
        )
491
        multiplexer2
492
        (
493
            .in          (masked_non_assigned_request_per_port   [i]),
494
            .out         (candidate_ovc_local_num    [i]),
495
            .sel         (first_arbiter_granted_ivc_per_port     [i])
496
 
497
        );
498
 
499
 
500
        assign any_cand_ovc_exsit[i] = | candidate_ovc_local_num    [i];
501
 
502
        //first level arbiter to candidate only one OVC
503
        arbiter #(
504
            .ARBITER_WIDTH (V)
505
        )
506
        first_arbiter
507
        (
508
            .clk (clk),
509
            .reset (reset),
510
            .request (candidate_ovc_local_num[i]),
511
            .grant (first_arbiter_ovc_granted[i]),
512
            .any_grant ( )
513
        );
514
 
515
 
516
        //demultiplexer
517
        one_hot_demux   #(
518
            .IN_WIDTH (V),
519
            .SEL_WIDTH (P_1)
520
        )
521
        demux1
522
        (
523
            .demux_sel (granted_dest_port_per_port [i]),//selectore
524
            .demux_in (first_arbiter_ovc_granted[i]),//repeated
525
            .demux_out (cand_ovc_granted [i])
526
        );
527
 
528
 
529
        assign granted_ovc_local_num_per_port   [i]=(any_ivc_sw_request_granted_all[i] )?  first_arbiter_ovc_granted[i] : {V{1'b0}};
530
        assign ivc_local_num_getting_ovc_grant  [i]= (any_ivc_sw_request_granted_all[i] & any_cand_ovc_exsit[i])?   first_arbiter_granted_ivc_per_port [i] : {V{1'b0}};
531
        assign ivc_num_getting_ovc_grant   [(i+1)*V-1 : i*V] = ivc_local_num_getting_ovc_grant[i];
532
        for(j=0;j
533
            assign granted_ovc_num_all[(i*VV)+((j+1)*V)-1 : (i*VV)+(j*V)]=granted_ovc_local_num_per_port[i];
534
        end//j
535
    end//i
536
 
537
 
538
    for(i=0;i< PV;i=i+1) begin :total_vc_loop2
539
        for(j=0;j
540
            if((i/V)
541
                assign ovc_allocated_all_gen[i][j-1] = cand_ovc_granted[j][i];
542
            end else if((i/V)>j) begin: hh
543
                assign ovc_allocated_all_gen[i][j] = cand_ovc_granted[j][i-V];
544
 
545
            end
546
        end//j
547
 
548
        assign ovc_allocated_all [i] = |ovc_allocated_all_gen[i];
549
 
550
    end//i
551
 
552
    endgenerate
553
 
554
 
555
endmodule
556
 
557
 
558
/********************************************
559
*
560
*    nonspeculative switch allocator
561
*
562
******************************************/
563
 
564
module nonspec_sw_alloc #(
565
    parameter V = 4,
566
    parameter P = 5,
567
    parameter FIRST_ARBITER_EXT_P_EN = 1,
568
    parameter SWA_ARBITER_TYPE = "WRRA",
569
    parameter MIN_PCK_SIZE=2, //minimum packet size in flits. The minimum value is 1.
570
    parameter SELF_LOOP_EN="NO"
571
 
572
)(
573
 
574
    ivc_granted_all,
575
    ivc_request_masked_all,
576
    pck_is_single_flit_all,
577
    granted_dst_is_from_a_single_flit_pck,
578
    dest_port_all,
579
    granted_dest_port_all,
580
    first_arbiter_granted_ivc_all,
581
    //first_arbiter_granted_port_all,
582
    any_ivc_granted_all,
583
    any_ovc_granted_all,
584
    vc_weight_is_consumed_all,
585
    iport_weight_is_consumed_all,
586
    clk,
587
    reset
588
 
589
);
590
 
591
   localparam
592
        P_1 = (SELF_LOOP_EN== "NO") ? P-1 : P,
593
        PV = V * P,
594
        VP_1 = V * P_1,
595
        PP_1 = P_1 * P,
596
        PVP_1 = PV * P_1,
597
        PP = P*P;
598
 
599
 
600
    output [PV-1 : 0] ivc_granted_all;
601
    output [P-1 : 0] granted_dst_is_from_a_single_flit_pck;
602
    input  [PV-1 : 0] ivc_request_masked_all;
603
    input  [PV-1 : 0] pck_is_single_flit_all;
604
    input  [PVP_1-1 : 0] dest_port_all;
605
    output [PP_1-1 : 0] granted_dest_port_all;
606
    output [PV-1 : 0] first_arbiter_granted_ivc_all;
607
    //output [PP_1-1 : 0] first_arbiter_granted_port_all;
608
    output [P-1 : 0] any_ivc_granted_all; //any ivc is granted in input  port [i]
609
    output [P-1 : 0] any_ovc_granted_all; //any ovc is granted in output port [i]
610
    input  clk, reset;
611
    input [PV-1 : 0] vc_weight_is_consumed_all;
612
    input [P-1: 0] iport_weight_is_consumed_all;
613
 
614
    //separte input per port
615
    wire [V-1 : 0] ivc_granted        [P-1 : 0];
616
    wire [V-1 : 0] pck_is_single_flit [P-1 : 0];
617
    wire [VP_1-1 : 0] dest_port_ivc       [P-1 : 0];
618
    wire [P_1-1 : 0] granted_dest_port  [P-1 : 0];
619
    wire [P_1-1 : 0] single_flit_granted_dst [P-1 : 0];
620
    wire [PP-1 : 0] single_flit_granted_dst_all;
621
 
622
    // internal wires
623
    wire    [V-1 : 0] ivc_masked     [P-1 : 0];//output of mask and
624
    wire    [V-1 : 0] first_arbiter_grant     [P-1 : 0];//output of first arbiter
625
    wire    [P-1 : 0] single_flit_pck_local_grant;
626
    wire    [P_1-1 : 0] dest_port      [P-1 : 0];//output of multiplexer
627
    wire    [P_1-1 : 0] second_arbiter_request  [P-1 : 0];
628
    wire    [P_1-1 : 0] second_arbiter_grant    [P-1 : 0];
629
    wire    [P_1-1 : 0] second_arbiter_weight_consumed [P-1 : 0];
630
    wire    [V-1 : 0] vc_weight_is_consumed [P-1 : 0];
631
    wire    [P-1    :0] winner_weight_consumed;
632
 
633
    genvar i,j;
634
    generate
635
 
636
    for(i=0;i< P;i=i+1) begin :port_loop
637
        //assign in/out to the port based wires
638
        //output
639
        assign ivc_granted_all [(i+1)*V-1 : i*V] =   ivc_granted [i];
640
        assign granted_dest_port_all    [(i+1)*P_1-1 : i*P_1]   =   granted_dest_port[i];
641
        assign first_arbiter_granted_ivc_all[(i+1)*V-1 : i*V]=           first_arbiter_grant[i];
642
        //input
643
        assign ivc_masked[i]  = ivc_request_masked_all [(i+1)*V-1 : i*V];
644
 
645
        assign dest_port_ivc[i]  = dest_port_all [(i+1)*VP_1-1 : i*VP_1];
646
        assign vc_weight_is_consumed[i]  =  vc_weight_is_consumed_all [(i+1)*V-1 : i*V];
647
 
648
        //first level arbiter
649
        swa_input_port_arbiter #(
650
                .ARBITER_WIDTH(V),
651
                .EXT_P_EN(FIRST_ARBITER_EXT_P_EN),
652
                .ARBITER_TYPE(SWA_ARBITER_TYPE)
653
        )
654
        input_arbiter
655
        (
656
                .ext_pr_en_i(any_ivc_granted_all[i]),
657
                .request(ivc_masked [i]),
658
                .grant(first_arbiter_grant[i]),
659
                .any_grant( ),
660
                .clk(clk),
661
                .reset(reset),
662
                .vc_weight_is_consumed(vc_weight_is_consumed[i]),
663
                .winner_weight_consumed(winner_weight_consumed[i])
664
        );
665
 
666
 
667
 
668
        //destination port multiplexer
669
        onehot_mux_1D #(
670
            .W (P_1),
671
            .N (V)
672
        )
673
        multiplexer
674
        (
675
            .in (dest_port_ivc  [i]),
676
            .out (dest_port      [i]),
677
            .sel(first_arbiter_grant[i])
678
 
679
        );
680
        if(MIN_PCK_SIZE == 1) begin :single_flit_supported
681
            //single_flit req multiplexer
682
            assign pck_is_single_flit[i] = pck_is_single_flit_all [(i+1)*V-1 : i*V];
683
            onehot_mux_1D #(
684
                .W (1),
685
                .N (V)
686
            )
687
            multiplexer2
688
            (
689
                .in (pck_is_single_flit  [i]),
690
                .out (single_flit_pck_local_grant[i]),
691
                .sel (first_arbiter_grant[i])
692
 
693
            );
694
 
695
            assign  single_flit_granted_dst[i] = (single_flit_pck_local_grant[i])?  granted_dest_port[i] : {P_1{1'b0}};
696
 
697
            if (SELF_LOOP_EN == "NO") begin :nslp
698
                add_sw_loc_one_hot #(
699
                    .P(P),
700
                    .SW_LOC(i)
701
                )
702
                add_sw_loc
703
                (
704
                    .destport_in(single_flit_granted_dst[i]),
705
                    .destport_out(single_flit_granted_dst_all[(i+1)*P-1 : i*P])
706
                );
707
            end else begin :slp
708
                assign single_flit_granted_dst_all[(i+1)*P-1 : i*P] = single_flit_granted_dst[i];
709
            end
710
 
711
        end else begin : single_flit_notsupported
712
            assign single_flit_pck_local_grant[i] = 1'bx;
713
            assign single_flit_granted_dst[i] = {P_1{1'bx}};
714
            assign single_flit_granted_dst_all[(i+1)*P-1 : i*P]={P{1'b0}};
715
        end
716
    //second arbiter input/output generate
717
 
718
 
719
    for(j=0;j
720
         if (SELF_LOOP_EN == "NO") begin :nslp
721
            if(i
722
                assign second_arbiter_request[i][j-1]  = dest_port[j][i];
723
                //assign second_arbiter_weight_consumed[i][j-1]  =winner_weight_consumed[j] ;
724
                assign second_arbiter_weight_consumed[i][j-1]  =iport_weight_is_consumed_all[j] ;
725
                assign granted_dest_port[j][i] = second_arbiter_grant  [i][j-1] ;
726
 
727
            end else if(i>j)begin: hh
728
                assign second_arbiter_request[i][j] = dest_port [j][i-1] ;
729
                //assign second_arbiter_weight_consumed[i][j]  =winner_weight_consumed[j];
730
                assign second_arbiter_weight_consumed[i][j]  =iport_weight_is_consumed_all[j];
731
                assign granted_dest_port[j][i-1] = second_arbiter_grant  [i][j] ;
732
            end
733
            //if(i==j) wires are left disconnected
734
        end else begin :slp
735
            assign second_arbiter_request[i][j]  = dest_port[j][i];
736
            assign second_arbiter_weight_consumed[i][j]  =iport_weight_is_consumed_all[j] ;
737
            assign granted_dest_port[j][i] = second_arbiter_grant  [i][j] ;
738
        end
739
    end
740
 
741
 
742
        //second level arbiter
743
        swa_output_port_arbiter #(
744
            .ARBITER_WIDTH(P_1),
745
            .ARBITER_TYPE(SWA_ARBITER_TYPE) // RRA, WRRA
746
        )
747
        output_arbiter
748
        (
749
           .weight_consumed(second_arbiter_weight_consumed[i]),  // only used for WRRA
750
           .clk(clk),
751
           .reset(reset),
752
           .request(second_arbiter_request [i]),
753
           .grant(second_arbiter_grant [i]),
754
           .any_grant(any_ovc_granted_all [i])
755
        );
756
 
757
 
758
        //any ivc
759
        assign  any_ivc_granted_all[i] = | granted_dest_port[i];
760
        assign  ivc_granted[i] =  (any_ivc_granted_all[i]) ? first_arbiter_grant[i] : {V{1'b0}};
761
 
762
 
763
    end//for
764
    endgenerate
765
 
766
 
767
          custom_or #(
768
            .IN_NUM(P),
769
            .OUT_WIDTH(P)
770
         )
771
         or_dst
772
         (
773
            .or_in(single_flit_granted_dst_all),
774
            .or_out(granted_dst_is_from_a_single_flit_pck)
775
        );
776
 
777
endmodule
778
 
779
 
780
 
781
/*******************
782
*    swa_input_port_arbiter
783
*
784
********************/
785
 
786
 
787
module swa_input_port_arbiter #(
788
    parameter ARBITER_WIDTH =4,
789
    parameter EXT_P_EN = 1,
790
    parameter ARBITER_TYPE = "WRRA"// RRA, WRRA
791
 
792
)(
793
   ext_pr_en_i,  // it is used only if the EXT_P_EN is 1
794
   clk,
795
   reset,
796
   request,
797
   grant,
798
   any_grant,
799
   vc_weight_is_consumed, // only for WRRA
800
   winner_weight_consumed // only for WRRA
801
);
802
 
803
 
804
 
805
 
806
 
807
    input ext_pr_en_i;
808
    input [ARBITER_WIDTH-1 : 0] request;
809
    output[ARBITER_WIDTH-1 : 0] grant;
810
    output any_grant;
811
    input  clk;
812
    input  reset;
813
    input  [ARBITER_WIDTH-1 : 0] vc_weight_is_consumed;
814
    output winner_weight_consumed;
815
 
816
 
817
    generate
818
    /* verilator lint_off WIDTH */
819
    if(ARBITER_TYPE != "RRA") begin : wrra_m
820
    /* verilator lint_on WIDTH */
821
 
822
        // one hot mux
823
        onehot_mux_1D #(
824
            .W(1),
825
            .N(ARBITER_WIDTH)
826
        )
827
        mux
828
        (
829
            .in(vc_weight_is_consumed),
830
            .out(winner_weight_consumed),
831
            .sel(grant)
832
        );
833
 
834
        wire priority_en = (EXT_P_EN == 1) ? ext_pr_en_i & winner_weight_consumed : winner_weight_consumed;
835
 
836
        //round robin arbiter with external priority
837
 
838
        arbiter_priority_en #(
839
            .ARBITER_WIDTH(ARBITER_WIDTH)
840
        )
841
        rra
842
        (
843
            .request(request),
844
            .grant(grant),
845
            .any_grant(any_grant),
846
            .clk(clk),
847
            .reset(reset),
848
            .priority_en(priority_en)
849
        );
850
 
851
    end else begin : rra_m //RRA
852
        assign winner_weight_consumed = 1'bx;
853
        if(EXT_P_EN==1) begin : arbiter_ext_en
854
 
855
            arbiter_priority_en #(
856
                .ARBITER_WIDTH (ARBITER_WIDTH)
857
            )
858
            arb
859
            (
860
                .clk (clk),
861
                .reset (reset),
862
                .request (request),
863
                .grant (grant),
864
                .any_grant (any_grant ),
865
                .priority_en (ext_pr_en_i)
866
            );
867
 
868
        end else  begin: first_lvl_arbiter_internal_en
869
 
870
            arbiter #(
871
                .ARBITER_WIDTH (ARBITER_WIDTH)
872
            )
873
            arb
874
            (
875
                .clk (clk),
876
                .reset (reset),
877
                .request (request),
878
                .grant (grant),
879
                .any_grant (any_grant )
880
            );
881
 
882
        end//else
883
 
884
    end
885
    endgenerate
886
 
887
endmodule
888
 
889
 
890
 
891
 
892
/*******************
893
*    swa_output_port_arbiter
894
*
895
********************/
896
 
897
 
898
module swa_output_port_arbiter #(
899
    parameter ARBITER_WIDTH =4,
900
    parameter ARBITER_TYPE = "WRRA" // RRA, WRRA
901
 
902
 
903
)(
904
   weight_consumed,  // only used for WRRA
905
   clk,
906
   reset,
907
   request,
908
   grant,
909
   any_grant
910
);
911
 
912
 
913
 
914
    input     [ARBITER_WIDTH-1  :    0]    request;
915
    output    [ARBITER_WIDTH-1  :    0]    grant;
916
    output                                 any_grant;
917
    input                                  clk;
918
    input                                  reset;
919
    input    [ARBITER_WIDTH-1  :    0]     weight_consumed;
920
 
921
 
922
 
923
 generate
924
    /* verilator lint_off WIDTH */
925
    if(ARBITER_TYPE == "WRRA") begin : wrra_mine
926
    /* verilator lint_on WIDTH */
927
        // second level wrra priority is only changed if the granted request weight is consumed
928
        wire pr_en;
929
 
930
        onehot_mux_1D #(
931
            .W(1),
932
            .N(ARBITER_WIDTH)
933
        )
934
        multiplexer
935
        (
936
            .in(weight_consumed),
937
            .out(pr_en),
938
            .sel(grant)
939
 
940
        );
941
 
942
 
943
        arbiter_priority_en #(
944
            .ARBITER_WIDTH (ARBITER_WIDTH)
945
        )
946
        arb
947
        (
948
            .clk (clk),
949
            .reset (reset),
950
            .request (request),
951
            .grant (grant),
952
            .any_grant (any_grant ),
953
            .priority_en (pr_en)
954
        );
955
 
956
 
957
     /* verilator lint_off WIDTH */
958
    end else if(ARBITER_TYPE == "WRRA_CLASSIC") begin : wrra_classic
959
    /* verilator lint_on WIDTH */
960
        // use classic WRRA. only for compasrion with propsoed wrra
961
 
962
        wire  [ARBITER_WIDTH-1  :    0] masked_req=       request & ~weight_consumed;
963
        wire sel = |masked_req;
964
        wire  [ARBITER_WIDTH-1  :    0] mux_req = (sel==1'b1)? masked_req : request;
965
 
966
        arbiter #(
967
            .ARBITER_WIDTH  (ARBITER_WIDTH )
968
        )
969
        arb
970
        (
971
            .clk (clk),
972
            .reset (reset),
973
            .request (mux_req),
974
            .grant (grant),
975
            .any_grant (any_grant )
976
        );
977
 
978
 
979
 
980
    end else begin : rra_m
981
 
982
        arbiter #(
983
            .ARBITER_WIDTH  (ARBITER_WIDTH )
984
        )
985
        arb
986
        (
987
            .clk (clk),
988
            .reset (reset),
989
            .request (request),
990
            .grant (grant),
991
            .any_grant (any_grant )
992
        );
993
 
994
   end
995
   endgenerate
996
endmodule
997
 

powered by: WebSVN 2.1.0

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