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 56

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

powered by: WebSVN 2.1.0

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