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/] [arbiter.v] - Blame information for rev 54

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
 `timescale     1ns/1ps
2
/**********************************************************************
3
**      File: arbiter.v
4
**
5
**      Copyright (C) 2014-2017  Alireza Monemi
6
**
7
**      This file is part of ProNoC
8
**
9
**      ProNoC ( stands for Prototype Network-on-chip)  is free software:
10
**      you can redistribute it and/or modify it under the terms of the GNU
11
**      Lesser General Public License as published by the Free Software Foundation,
12
**      either version 2 of the License, or (at your option) any later version.
13
**
14
**      ProNoC is distributed in the hope that it will be useful, but WITHOUT
15
**      ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
**      or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
17
**      Public License for more details.
18
**
19
**      You should have received a copy of the GNU Lesser General Public
20
**      License along with ProNoC. If not, see <http:**www.gnu.org/licenses/>.
21
**
22
**
23
**
24
**      Description:
25
**      This file contains several Fixed prority and round robin
26
**      arbiters
27
**
28
******************************************************************************/
29
 
30
 
31
/*****************************************
32
*
33
* general round robin arbiter
34
*
35
*
36
******************************************/
37 54 alirezamon
`include "pronoc_def.v"
38 48 alirezamon
 
39 54 alirezamon
 
40
 
41 48 alirezamon
module arbiter #(
42
    parameter    ARBITER_WIDTH    =8
43
 
44
)
45
(
46
   clk,
47
   reset,
48
   request,
49
   grant,
50
   any_grant
51
);
52
 
53
 
54
    input    [ARBITER_WIDTH-1             :    0]    request;
55
    output    [ARBITER_WIDTH-1            :    0]    grant;
56
    output                                        any_grant;
57
    input                                        clk;
58
    input                                        reset;
59
 
60
 
61
 
62
    generate
63
    if(ARBITER_WIDTH==1)  begin: w1
64
        assign grant= request;
65
        assign any_grant =request;
66
    end else if(ARBITER_WIDTH<=4) begin: w4
67
        //my own arbiter 
68
        my_one_hot_arbiter #(
69
            .ARBITER_WIDTH    (ARBITER_WIDTH)
70
        )
71
        one_hot_arb
72
        (
73
            .clk            (clk),
74
            .reset         (reset),
75
            .request        (request),
76
            .grant        (grant),
77
            .any_grant    (any_grant)
78
        );
79
 
80
    end else begin : wb4
81
 
82
        thermo_arbiter #(
83
            .ARBITER_WIDTH    (ARBITER_WIDTH)
84
        )
85
        one_hot_arb
86
        (
87
            .clk            (clk),
88
            .reset         (reset),
89
            .request        (request),
90
            .grant        (grant),
91
            .any_grant    (any_grant)
92
        );
93
    end
94
    endgenerate
95
endmodule
96
 
97
/*****************************************
98
*
99
*        arbiter_priority_en
100
* RRA with external priority enable signal
101
*
102
******************************************/
103
 
104
module arbiter_priority_en #(
105
        parameter    ARBITER_WIDTH    =8
106
 
107
)
108
(
109
   clk,
110
   reset,
111
   request,
112
   grant,
113
   any_grant,
114
   priority_en
115
);
116
 
117
 
118
 
119
 
120
    input        [ARBITER_WIDTH-1             :    0]    request;
121
    output    [ARBITER_WIDTH-1            :    0]    grant;
122
    output                                            any_grant;
123
    input                                                clk;
124
    input                                                reset;
125
    input                                              priority_en;
126
 
127
 
128
    generate
129
    if(ARBITER_WIDTH==1)  begin: w1
130
        assign grant= request;
131
        assign any_grant =request;
132
    end else if(ARBITER_WIDTH<=4) begin: w4
133
        //my own arbiter 
134
        my_one_hot_arbiter_priority_en #(
135
            .ARBITER_WIDTH    (ARBITER_WIDTH)
136
        )
137
        one_hot_arb
138
        (
139
            .clk            (clk),
140
            .reset         (reset),
141
            .request        (request),
142
            .grant        (grant),
143
            .any_grant    (any_grant),
144
            .priority_en (priority_en)
145
 
146
        );
147
 
148
    end else begin :wb4
149
 
150
        thermo_arbiter_priority_en #(
151
            .ARBITER_WIDTH    (ARBITER_WIDTH)
152
        )
153
        one_hot_arb
154
        (
155
            .clk            (clk),
156
            .reset         (reset),
157
            .request        (request),
158
            .grant        (grant),
159
            .any_grant    (any_grant),
160
            .priority_en (priority_en)
161
        );
162
    end
163
endgenerate
164
endmodule
165
 
166
 
167
 
168
/******************************************************
169
*       my_one_hot_arbiter
170
* RRA with binary-coded priority register. Binary-coded
171
* Priority results in less area cost and CPD for arbire
172
* width of 4 and smaller only.
173
*
174
******************************************************/
175
 
176
 
177
 
178
module my_one_hot_arbiter #(
179
    parameter ARBITER_WIDTH    =4
180
 
181
 
182
)
183
(
184
    input        [ARBITER_WIDTH-1             :    0]    request,
185
    output    [ARBITER_WIDTH-1            :    0]    grant,
186
    output                                            any_grant,
187
    input                                                clk,
188
    input                                                reset
189
);
190
 
191
    function integer log2;
192
      input integer number; begin
193
         log2=(number <=1) ? 1: 0;
194
         while(2**log2<number) begin
195
            log2=log2+1;
196
         end
197
      end
198
    endfunction // log2 
199
 
200
    localparam ARBITER_BIN_WIDTH= log2(ARBITER_WIDTH);
201
    reg     [ARBITER_BIN_WIDTH-1        :    0]     low_pr;
202
    wire     [ARBITER_BIN_WIDTH-1        :    0]     grant_bcd;
203
 
204
    one_hot_to_bin #(
205
        .ONE_HOT_WIDTH    (ARBITER_WIDTH)
206
    )conv
207
    (
208
    .one_hot_code(grant),
209
    .bin_code(grant_bcd)
210
 
211
    );
212
 
213 54 alirezamon
    always @ (`pronoc_clk_reset_edge )begin
214
        if(`pronoc_reset) begin
215 48 alirezamon
            low_pr    <=    {ARBITER_BIN_WIDTH{1'b0}};
216
        end else begin
217
            if(any_grant) low_pr <= grant_bcd;
218
        end
219
    end
220
 
221
 
222
    assign any_grant = | request;
223
 
224
    generate
225
        if(ARBITER_WIDTH    ==2) begin: w2        arbiter_2_one_hot arb( .in(request) , .out(grant), .low_pr(low_pr)); end
226
        if(ARBITER_WIDTH    ==3) begin: w3        arbiter_3_one_hot arb( .in(request) , .out(grant), .low_pr(low_pr)); end
227
        if(ARBITER_WIDTH    ==4) begin: w4        arbiter_4_one_hot arb( .in(request) , .out(grant), .low_pr(low_pr)); end
228
    endgenerate
229
 
230
endmodule
231
 
232
 
233
module arbiter_2_one_hot(
234
     input      [1             :    0]    in,
235
     output    reg[1                :    0]    out,
236
     input                                low_pr
237
);
238
always @(*) begin
239
     out=2'b00;
240
      case(low_pr)
241
         1'd0:
242
             if(in[1])                 out=2'b10;
243
             else if(in[0])         out=2'b01;
244
         1'd1:
245
             if(in[0])                 out=2'b01;
246
             else if(in[1])         out=2'b10;
247
          default: out=2'b00;
248
     endcase
249
  end
250
 endmodule
251
 
252
 
253
 
254
 
255
module arbiter_3_one_hot(
256
     input      [2             :    0]    in,
257
     output    reg[2                :    0]    out,
258
     input        [1                :    0]    low_pr
259
);
260
always @(*) begin
261
  out=3'b000;
262
      case(low_pr)
263
         2'd0:
264
             if(in[1])                 out=3'b010;
265
             else if(in[2])         out=3'b100;
266
             else if(in[0])         out=3'b001;
267
         2'd1:
268
             if(in[2])                 out=3'b100;
269
             else if(in[0])         out=3'b001;
270
             else if(in[1])         out=3'b010;
271
         2'd2:
272
             if(in[0])                 out=3'b001;
273
             else if(in[1])         out=3'b010;
274
             else if(in[2])         out=3'b100;
275
         default: out=3'b000;
276
     endcase
277
  end
278
 endmodule
279
 
280
 
281
 module arbiter_4_one_hot(
282
     input      [3             :    0]    in,
283
     output    reg[3                :    0]    out,
284
     input        [1                :    0]    low_pr
285
);
286
always @(*) begin
287
  out=4'b0000;
288
      case(low_pr)
289
         2'd0:
290
             if(in[1])                 out=4'b0010;
291
             else if(in[2])         out=4'b0100;
292
             else if(in[3])         out=4'b1000;
293
             else if(in[0])         out=4'b0001;
294
         2'd1:
295
             if(in[2])                 out=4'b0100;
296
             else if(in[3])         out=4'b1000;
297
             else if(in[0])         out=4'b0001;
298
             else if(in[1])         out=4'b0010;
299
         2'd2:
300
             if(in[3])                 out=4'b1000;
301
             else if(in[0])         out=4'b0001;
302
             else if(in[1])         out=4'b0010;
303
             else if(in[2])         out=4'b0100;
304
         2'd3:
305
             if(in[0])                 out=4'b0001;
306
             else if(in[1])         out=4'b0010;
307
             else if(in[2])         out=4'b0100;
308
             else if(in[3])         out=4'b1000;
309
         default: out=4'b0000;
310
     endcase
311
  end
312
 endmodule
313
 
314
 
315
/******************************************************
316
*       my_one_hot_arbiter_priority_en
317
*
318
******************************************************/
319
 
320
 
321
 
322
module my_one_hot_arbiter_priority_en #(
323
    parameter ARBITER_WIDTH    =4
324
 
325
 
326
)
327
(
328
    input        [ARBITER_WIDTH-1             :    0]    request,
329
    output    [ARBITER_WIDTH-1            :    0]    grant,
330
    output                                            any_grant,
331
    input                                                clk,
332
    input                                                reset,
333
    input                                                priority_en
334
);
335
 
336
    function integer log2;
337
      input integer number; begin
338
         log2=(number <=1) ? 1: 0;
339
         while(2**log2<number) begin
340
            log2=log2+1;
341
         end
342
      end
343
    endfunction // log2 
344
 
345
    localparam ARBITER_BIN_WIDTH= log2(ARBITER_WIDTH);
346
    reg     [ARBITER_BIN_WIDTH-1        :    0]     low_pr;
347
    wire     [ARBITER_BIN_WIDTH-1        :    0]     grant_bcd;
348
 
349
    one_hot_to_bin #(
350
        .ONE_HOT_WIDTH    (ARBITER_WIDTH)
351
    )conv
352
    (
353
        .one_hot_code(grant),
354
        .bin_code(grant_bcd)
355
    );
356
 
357 54 alirezamon
    always @ (`pronoc_clk_reset_edge )begin
358
        if(`pronoc_reset) begin
359 48 alirezamon
            low_pr    <=    {ARBITER_BIN_WIDTH{1'b0}};
360
        end else begin
361
            if(priority_en) low_pr <= grant_bcd;
362
        end
363
    end
364
 
365
 
366
    assign any_grant = | request;
367
 
368
    generate
369
        if(ARBITER_WIDTH    ==2) begin :w2        arbiter_2_one_hot arb( .in(request) , .out(grant), .low_pr(low_pr)); end
370
        if(ARBITER_WIDTH    ==3) begin :w3        arbiter_3_one_hot arb( .in(request) , .out(grant), .low_pr(low_pr)); end
371
        if(ARBITER_WIDTH    ==4) begin :w4        arbiter_4_one_hot arb( .in(request) , .out(grant), .low_pr(low_pr)); end
372
    endgenerate
373
 
374
endmodule
375
 
376
 
377
 
378
/*******************
379
*
380
*    thermo_arbiter RRA
381
*
382
********************/
383
 
384
module thermo_gen #(
385
    parameter WIDTH=16
386
 
387
 
388
)(
389
    input  [WIDTH-1    :    0]in,
390
    output [WIDTH-1    :    0]out
391
);
392
    genvar i;
393
    generate
394
    for(i=0;i<WIDTH;i=i+1)begin :lp
395
        assign out[i]= | in[i    :0];
396
    end
397
    endgenerate
398
 
399
endmodule
400
 
401
 
402
 
403
 
404
module thermo_arbiter #(
405
 parameter    ARBITER_WIDTH    =4
406
 
407
)
408
(
409
   clk,
410
   reset,
411
   request,
412
   grant,
413
   any_grant
414
);
415
 
416
 
417
 
418
 
419
    input        [ARBITER_WIDTH-1             :    0]    request;
420
    output    [ARBITER_WIDTH-1            :    0]    grant;
421
    output                                            any_grant;
422
    input                                                reset,clk;
423
 
424
 
425
    wire        [ARBITER_WIDTH-1             :    0]    termo1,termo2,mux_out,masked_request,edge_mask;
426
    reg        [ARBITER_WIDTH-1             :    0]    pr;
427
 
428
 
429
    thermo_gen #(
430
        .WIDTH(ARBITER_WIDTH)
431
    ) tm1
432
    (
433
        .in(request),
434
        .out(termo1)
435
    );
436
 
437
 
438
 
439
 
440
    thermo_gen #(
441
        .WIDTH(ARBITER_WIDTH)
442
    ) tm2
443
    (
444
        .in(masked_request),
445
        .out(termo2)
446
    );
447
 
448
 
449 54 alirezamon
    assign mux_out=(termo2[ARBITER_WIDTH-1])? termo2 : termo1;
450
    assign masked_request= request & pr;
451
    assign any_grant=termo1[ARBITER_WIDTH-1];
452
 
453
    always @ (`pronoc_clk_reset_edge )begin
454
            if(`pronoc_reset) pr<= {ARBITER_WIDTH{1'b1}};
455
        else begin
456
            if(any_grant) pr<= edge_mask;
457
        end
458
 
459 48 alirezamon
    end
460 54 alirezamon
 
461
    assign edge_mask= {mux_out[ARBITER_WIDTH-2:0],1'b0};
462
    assign grant= mux_out ^ edge_mask;
463 48 alirezamon
 
464
 
465
 
466
endmodule
467
 
468
 
469
 
470
 
471
 
472
module thermo_arbiter_priority_en #(
473
 parameter    ARBITER_WIDTH    =4
474
 
475
)
476
(
477
   clk,
478
   reset,
479
   request,
480
   grant,
481
   any_grant,
482
   priority_en
483
);
484
 
485
 
486
 
487
 
488
    input        [ARBITER_WIDTH-1             :    0]    request;
489
    output    [ARBITER_WIDTH-1            :    0]    grant;
490
    output                                            any_grant;
491
    input                                                reset,clk;
492
    input priority_en;
493
 
494
    wire        [ARBITER_WIDTH-1             :    0]    termo1,termo2,mux_out,masked_request,edge_mask;
495
    reg        [ARBITER_WIDTH-1             :    0]    pr;
496
 
497
 
498
    thermo_gen #(
499
        .WIDTH(ARBITER_WIDTH)
500
    ) tm1
501
    (
502
        .in(request),
503
        .out(termo1)
504
    );
505
 
506
 
507
 
508
 
509
    thermo_gen #(
510
        .WIDTH(ARBITER_WIDTH)
511
    ) tm2
512
    (
513
        .in(masked_request),
514
        .out(termo2)
515
    );
516
 
517
 
518
    assign mux_out=(termo2[ARBITER_WIDTH-1])? termo2 : termo1;
519
    assign masked_request= request & pr;
520
    assign any_grant=termo1[ARBITER_WIDTH-1];
521
 
522 54 alirezamon
    always @ (`pronoc_clk_reset_edge )begin
523
            if(`pronoc_reset) pr<= {ARBITER_WIDTH{1'b1}};
524
        else begin
525
            if(priority_en) pr<= edge_mask;
526
        end
527
 
528 48 alirezamon
    end
529 54 alirezamon
 
530
    assign edge_mask= {mux_out[ARBITER_WIDTH-2:0],1'b0};
531
    assign grant= mux_out ^ edge_mask;
532 48 alirezamon
 
533
 
534
 
535
endmodule
536
 
537
 
538
 
539
 
540
 
541
 
542
 
543
 
544
module thermo_arbiter_ext_priority #(
545
 parameter    ARBITER_WIDTH    =4
546
 
547
)
548
(
549
 
550
   request,
551
   grant,
552
   any_grant,
553
   priority_in
554
 
555
);
556
 
557
 
558
 
559
 
560
    input        [ARBITER_WIDTH-1             :    0]    request;
561
    output    [ARBITER_WIDTH-1            :    0]    grant;
562
    output                                            any_grant;
563
    input   [ARBITER_WIDTH-1            :   0]  priority_in;
564
 
565
    wire        [ARBITER_WIDTH-1             :    0]    termo1,termo2,mux_out,masked_request,edge_mask;
566
    wire        [ARBITER_WIDTH-1             :    0]    pr;
567
 
568
 
569
    thermo_gen #(
570
        .WIDTH(ARBITER_WIDTH)
571
    ) tm1
572
    (
573
        .in(request),
574
        .out(termo1)
575
    );
576
 
577
 
578
 
579
 
580
    thermo_gen #(
581
        .WIDTH(ARBITER_WIDTH)
582
    ) tm2
583
    (
584
        .in(masked_request),
585
        .out(termo2)
586
    );
587
 
588
 
589
    thermo_gen #(
590
        .WIDTH(ARBITER_WIDTH)
591
    ) tm3
592
    (
593
        .in(priority_in),
594
        .out(pr)
595
    );
596
 
597
 
598
assign mux_out=(termo2[ARBITER_WIDTH-1])? termo2 : termo1;
599
assign masked_request= request & pr;
600
assign any_grant=termo1[ARBITER_WIDTH-1];
601
 
602
 
603
assign edge_mask= {mux_out[ARBITER_WIDTH-2:0],1'b0};
604
assign grant= mux_out ^ edge_mask;
605
 
606
 
607
 
608
endmodule
609
 
610
 
611
 
612
/********************************
613
*
614
*   Tree arbiter
615
*
616
*******************************/
617
 
618
module tree_arbiter #(
619
        parameter    GROUP_NUM        =4,
620
        parameter    ARBITER_WIDTH    =16
621
)
622
(
623
   clk,
624
   reset,
625
   request,
626
   grant,
627
   any_grant
628
);
629
 
630
 
631
    function integer log2;
632
      input integer number; begin
633
         log2=(number <=1) ? 1: 0;
634
         while(2**log2<number) begin
635
            log2=log2+1;
636
         end
637
      end
638
    endfunction // log2 
639
 
640
  localparam N = ARBITER_WIDTH;
641
  localparam S = log2(ARBITER_WIDTH); // ceil of log_2 of N - put manually
642
 
643
 
644
  // I/O interface
645
  input           clk;
646
  input           reset;
647
  input  [N-1:0]  request;
648
  output [N-1:0]  grant;
649
  output          any_grant;
650
 
651
 
652
    localparam GROUP_WIDTH    =    ARBITER_WIDTH/GROUP_NUM;
653
 
654
  wire [GROUP_WIDTH-1        :    0]    group_req    [GROUP_NUM-1        :    0];
655
  wire [GROUP_WIDTH-1        :    0]    group_grant [GROUP_NUM-1        :    0];
656
  wire [GROUP_WIDTH-1        :    0]    grant_masked[GROUP_NUM-1        :    0];
657
 
658
  wire [GROUP_NUM-1            :    0] any_group_member_req;
659
  wire [GROUP_NUM-1            :    0] any_group_member_grant;
660
 
661
 
662
    genvar i;
663
    generate
664
    for (i=0;i<GROUP_NUM;i=i+1) begin :group_lp
665
 
666
        //seprate inputs in group
667
        assign group_req[i]    =    request[(i+1)*GROUP_WIDTH-1        :    i*GROUP_WIDTH];
668
 
669
        //check if any member of qrup has request
670
        assign any_group_member_req[i]    =    | group_req[i];
671
 
672
        //arbiterate one request from each group
673
        arbiter #(
674
            .ARBITER_WIDTH    (GROUP_WIDTH)
675
        )group_member_arbiter
676
        (
677
            .clk            (clk),
678
            .reset        (reset),
679
            .request        (group_req[i]),
680
            .grant        (group_grant[i]),
681
            .any_grant    ()
682
        );
683
 
684
    // mask the non selected groups        
685
        assign grant_masked [i] = (any_group_member_grant[i])?    group_grant[i]: {GROUP_WIDTH{1'b0}};
686
 
687
    //assemble the grants
688
        assign grant [(i+1)*GROUP_WIDTH-1        :    i*GROUP_WIDTH] = grant_masked [i];
689
 
690
 
691
    end
692
    endgenerate
693
 
694
    //select one group which has atleast one active request
695
 
696
    //arbiterate one request from each group
697
        arbiter #(
698
            .ARBITER_WIDTH    (GROUP_NUM)
699
        )second_arbiter
700
        (
701
            .clk        (clk),
702
            .reset        (reset),
703
            .request    (any_group_member_req),
704
            .grant        (any_group_member_grant),
705
            .any_grant    (any_grant)
706
        );
707
 
708
 
709
 
710
 endmodule
711
 
712
 
713
 
714
 
715
 
716
 
717
/*******************************
718
 
719
    my_one_hot_arbiter_ext_priority
720
 
721
*******************************/
722
 
723
module my_one_hot_arbiter_ext_priority #(
724
    parameter ARBITER_WIDTH =4
725
 
726
 
727
)
728
(
729
    input   [ARBITER_WIDTH-1            :   0]  request,
730
    input   [ARBITER_WIDTH-1            :   0]  priority_in,
731
    output  [ARBITER_WIDTH-1            :   0]  grant,
732
    output                                      any_grant
733
);
734
 
735
    function integer log2;
736
      input integer number; begin
737
         log2=(number <=1) ? 1: 0;
738
         while(2**log2<number) begin
739
            log2=log2+1;
740
         end
741
      end
742
    endfunction // log2 
743
 
744
    localparam ARBITER_BIN_WIDTH= log2(ARBITER_WIDTH);
745
    wire    [ARBITER_BIN_WIDTH-1        :   0]  low_pr;
746
 
747
 
748
    wire [ARBITER_WIDTH-1            :   0] low_pr_one_hot = {priority_in[0],priority_in[ARBITER_BIN_WIDTH-1:1]};
749
 
750
    one_hot_to_bin #(
751
        .ONE_HOT_WIDTH    (ARBITER_WIDTH)
752
    )conv
753
    (
754
        .one_hot_code(low_pr_one_hot),
755
        .bin_code(low_pr)
756
    );
757
 
758
 
759
    assign any_grant = | request;
760
 
761
    generate
762
        if(ARBITER_WIDTH    ==2) begin: w2       arbiter_2_one_hot arb( .in(request) , .out(grant), .low_pr(low_pr)); end
763
        if(ARBITER_WIDTH    ==3) begin: w3       arbiter_3_one_hot arb( .in(request) , .out(grant), .low_pr(low_pr)); end
764
        if(ARBITER_WIDTH    ==4) begin: w4       arbiter_4_one_hot arb( .in(request) , .out(grant), .low_pr(low_pr)); end
765
    endgenerate
766
 
767
endmodule
768
 
769
 
770
/*********************************
771
*
772
*       arbiter_ext_priority
773
*
774
**********************************/
775
 
776
 
777
 module arbiter_ext_priority  #(
778
        parameter   ARBITER_WIDTH   =8
779
 
780
)
781
(
782
 
783
   request,
784
   grant,
785
   priority_in,
786
   any_grant
787
);
788
 
789
 
790
    input   [ARBITER_WIDTH-1            :   0]  request;
791
    input   [ARBITER_WIDTH-1            :   0]  priority_in;
792
    output  [ARBITER_WIDTH-1            :   0]  grant;
793
    output                                      any_grant;
794
 
795
   /*
796
    generate
797
 
798
    if(ARBITER_WIDTH<=4) begin :ws4
799
        //my own arbiter
800
        my_one_hot_arbiter_ext_priority #(
801
            .ARBITER_WIDTH  (ARBITER_WIDTH)
802
        )
803
        one_hot_arb
804
        (
805
 
806
            .request    (request),
807
            .priority_in(priority_in),
808
            .grant      (grant),
809
            .any_grant  (any_grant)
810
        );
811
 
812
    end else begin :wb4
813
    */
814
 
815
        thermo_arbiter_ext_priority #(
816
            .ARBITER_WIDTH  (ARBITER_WIDTH)
817
        )
818
        one_hot_arb
819
        (
820
 
821
            .request    (request),
822
            .priority_in(priority_in),
823
            .grant      (grant),
824
            .any_grant   (any_grant)
825
        );
826
   // end
827
   // endgenerate
828
 
829
 
830
 
831
 
832
endmodule
833
 
834
 
835
 
836
 
837
 
838
 
839
 
840
 
841
 
842
 
843
 module fixed_priority_arbiter #(
844
     parameter   ARBITER_WIDTH   =8,
845
     parameter   HIGH_PRORITY_BIT = "HSB"
846
 )
847
 (
848
 
849
   request,
850
   grant,
851
   any_grant
852
);
853
 
854
 
855
    input   [ARBITER_WIDTH-1            :   0]  request;
856
    output  [ARBITER_WIDTH-1            :   0]  grant;
857
    output                                      any_grant;
858 54 alirezamon
   /*
859 48 alirezamon
    wire    [ARBITER_WIDTH-1            :   0]  cout;
860
    reg     [ARBITER_WIDTH-1            :   0]  cin;
861
 
862
 
863 54 alirezamon
 
864 48 alirezamon
 
865
    assign grant    = cin & request;
866
    assign cout     = cin & ~request;
867
 
868
     always @(*) begin
869
        if( HIGH_PRORITY_BIT == "HSB")  cin      = {1'b1, cout[ARBITER_WIDTH-1 :1]}; // hsb has highest priority
870
        else                            cin      = {cout[ARBITER_WIDTH-2 :0] ,1'b1}; // lsb has highest priority
871
    end//always
872 54 alirezamon
 
873
    */
874
 
875
    assign  any_grant= | request;
876
    wire  [ARBITER_WIDTH-1            :   0] termo_code, edge_mask;
877
 
878
 
879
    genvar i;
880
    generate
881
    if( HIGH_PRORITY_BIT == "LSB") begin :hsb
882
        for(i=0;i<ARBITER_WIDTH;i=i+1)begin :lp
883
            assign termo_code[i]= | request[i    :0];
884
        end
885
        assign edge_mask=  {termo_code[ARBITER_WIDTH-2:0],1'b0};
886
 
887
    end else begin :hsb
888
        for(i=0;i<ARBITER_WIDTH;i=i+1)begin :lp
889
            assign termo_code[i]= | request[ARBITER_WIDTH-1    :i];
890
        end
891
        assign edge_mask=  {1'b0, termo_code[ARBITER_WIDTH-1:1]};
892
 
893
    end
894
    endgenerate
895
 
896
    assign grant= termo_code ^ edge_mask;
897
 
898
 
899
 
900 48 alirezamon
endmodule
901
 
902
 
903
 
904
 
905
 
906
 

powered by: WebSVN 2.1.0

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