OpenCores
URL https://opencores.org/ocsvn/round_robin_arbiter/round_robin_arbiter/trunk

Subversion Repositories round_robin_arbiter

[/] [round_robin_arbiter/] [trunk/] [round_robin_arbiter2.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 rainrhythm
//Using Two Simple Priority Arbiters with a Mask
2
//author: dongjun_luo@hotmail.com
3
module round_robin_arbiter (
4
        rst_an,
5
        clk,
6
        req,
7
        grant
8
);
9
 
10
 
11
input           rst_an;
12
input           clk;
13
input   [3:0]    req;
14
output  [3:0]    grant;
15
 
16
reg     [3:0]    rotate_ptr;
17
wire    [3:0]    mask_req;
18
reg     [3:0]    mask_grant;
19
wire    [3:0]    grant_comb;
20
reg     [3:0]    grant;
21
wire            no_mask_req;
22
reg     [3:0]    nomask_grant;
23
 
24
always @ (posedge clk or negedge rst_an)
25
begin
26
        if (!rst_an)
27
                rotate_ptr[3:0] <= 4'b1111;
28
        else
29
                case (1'b1) // synthesis parallel_case
30
                        grant[0]: rotate_ptr[3:0] <= 4'b1110;
31
                        grant[1]: rotate_ptr[3:0] <= 4'b1100;
32
                        grant[2]: rotate_ptr[3:0] <= 4'b1000;
33
                        grant[3]: rotate_ptr[3:0] <= 4'b1111;
34
                endcase
35
end
36
 
37
assign mask_req[3:0] = req[3:0] & rotate_ptr[3:0];
38
 
39
// simple priority arbiter for mask req
40
always @ (*)
41
begin
42
        mask_grant[3:0] = 4'b0;
43
        if (mask_req[0]) mask_grant[0] = 1'b1;
44
        else if (mask_req[1])   mask_grant[1] = 1'b1;
45
        else if (mask_req[2])   mask_grant[2] = 1'b1;
46
        else if (mask_req[3])   mask_grant[3] = 1'b1;
47
end
48
 
49
// simple priority arbiter for no mask req
50
always @ (*)
51
begin
52
        nomask_grant[3:0] = 4'b0;
53
        if (req[0])              nomask_grant[0] = 1'b1;
54
        else if (req[1])        nomask_grant[1] = 1'b1;
55
        else if (req[2])        nomask_grant[2] = 1'b1;
56
        else if (req[3])        nomask_grant[3] = 1'b1;
57
end
58
 
59
assign no_mask_req = ~|mask_req[3:0];
60
//assign grant_comb[3:0] = no_mask_req ? nomask_grant[3:0] : mask_grant[3:0];
61
assign grant_comb[3:0] = (nomask_grant[3:0] & {4{no_mask_req}}) | mask_grant[3:0];
62
 
63
always @ (posedge clk or negedge rst_an)
64
begin
65
        if (!rst_an)    grant[3:0] <= 4'b0;
66
        else            grant[3:0] <= grant_comb[3:0] & ~grant[3:0];
67
end
68
endmodule

powered by: WebSVN 2.1.0

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