File tree 1 file changed +45
-0
lines changed
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ `timescale 1ns / 1ps
2
+ // ////////////////////////////////////////////////////////////////////////////////
3
+ // Company:
4
+ // Engineer: weirong dong
5
+ //
6
+ // Create Date: 2023/06/25 11:09:35
7
+ // Design Name:
8
+ // Module Name: round_robin_arbiter
9
+
10
+ // Description:
11
+ //
12
+ // Dependencies:
13
+ //
14
+ // Revision:
15
+ // Revision 0.01 - File Created
16
+ // Additional Comments:
17
+ //
18
+ // ////////////////////////////////////////////////////////////////////////////////
19
+ `include "defines.vh"
20
+ // `define N 8
21
+ module round_robin_arbiter (
22
+ input clk,
23
+ input rstn,
24
+ input [`N- 1 :0 ] req,
25
+ output [`N- 1 :0 ] grant // priority is 0010 => 1230, 3 enjoy the most priority
26
+ );
27
+ reg [`N- 1 :0 ] pre_grant;// previous grant
28
+ wire [`N- 1 :0 ] priority;
29
+ wire [2 * `N- 1 :0 ] double_req;
30
+ wire [2 * `N- 1 :0 ] double_grant;
31
+ assign double_req = {req[`N- 1 :0 ],req[`N- 1 :0 ]};
32
+ always @(posedge clk, negedge rstn)begin // asynchronous reset
33
+ if (! rstn)begin
34
+ pre_grant<= {1'b1 ,{`N- 1 {1'b0 }}};
35
+ end
36
+ else if (| req)begin
37
+ pre_grant<= grant;
38
+ end
39
+ end
40
+ assign priority= {pre_grant[`N- 2 :0 ],pre_grant[`N- 1 ]};
41
+ assign double_grant= double_req&~ (double_req- priority);
42
+ assign grant= (double_grant[`N- 1 :0 ]| double_grant[2 * `N- 1 :`N]);
43
+
44
+
45
+ endmodule
You can’t perform that action at this time.
0 commit comments