Skip to content

Commit 5221fb9

Browse files
committed
Add rr_distributor
1 parent dc55564 commit 5221fb9

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

Bender.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package:
88
- "Manuel Eggimann <[email protected]>"
99
- "Stefan Mach <[email protected]>"
1010
- "Wolfgang Roenninger <[email protected]>"
11+
- "Thomas Benz <[email protected]>"
1112

1213
dependencies:
1314
common_verification: { git: "https://github.com/pulp-platform/common_verification.git", version: 0.2.0 }
@@ -43,6 +44,7 @@ sources:
4344
- src/plru_tree.sv
4445
- src/popcount.sv
4546
- src/rr_arb_tree.sv
47+
- src/rr_distributor.sv
4648
- src/rstgen_bypass.sv
4749
- src/serial_deglitch.sv
4850
- src/shift_reg.sv

ci/install-verilator.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -e
3-
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
3+
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}")/.." && pwd)
44
cd $ROOT/tmp
55

66
if [ -z ${NUM_JOBS} ]; then

src/rr_distributor.sv

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright 2019 ETH Zurich and University of Bologna.
2+
// Copyright and related rights are licensed under the Solderpad Hardware
3+
// License, Version 0.51 (the "License"); you may not use this file except in
4+
// compliance with the License. You may obtain a copy of the License at
5+
// http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
6+
// or agreed to in writing, software, hardware and materials distributed under
7+
// this License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8+
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
9+
// specific language governing permissions and limitations under the License.
10+
//
11+
// Author: Thomas Benz <[email protected]>, ETH Zurich
12+
// Date: 12.01.2021
13+
// Description: round robin distributor
14+
15+
module rr_distributor # (
16+
parameter int unsigned NumOut = 1,
17+
parameter int unsigned Width = 1,
18+
parameter type payload_t = logic [Width-1:0],
19+
parameter int unsigned IdxWidth = (NumOut > 32'd1) ? unsigned'($clog2(NumOut)) : 32'd1,
20+
parameter type idx_t = logic [IdxWidth-1:0]
21+
) (
22+
// input stream
23+
input logic clk_i,
24+
input logic rst_ni,
25+
input logic valid_i,
26+
output logic ready_o,
27+
input payload_t payload_i,
28+
// output stream
29+
output logic [NumOut-1:0] valid_o,
30+
input logic [NumOut-1:0] ready_i,
31+
output payload_t [NumOut-1:0] payload_o,
32+
output idx_t sel_o
33+
);
34+
35+
if (NumOut == 1) begin : gen_bypass
36+
assign valid_o[0] = valid_i;
37+
assign ready_o = ready_i[0];
38+
assign sel_o = 1'b0;
39+
end else begin : gen_arb
40+
41+
idx_t rr_d, rr_q;
42+
logic one_ready;
43+
44+
assign rr_d = (valid_i & one_ready) ? ((rr_q == idx_t'(NumOut-1)) ? '0 : rr_q + 1'b1) : rr_q;
45+
46+
assign one_ready = |ready_i;
47+
48+
always_comb begin : proc_arbitration
49+
valid_o = '0;
50+
ready_o = 1'b0;
51+
if (ready_i[rr_q]) begin
52+
valid_o[rr_q] = valid_i;
53+
ready_o = 1'b1;
54+
end
55+
end
56+
57+
always_ff @(posedge clk_i or negedge rst_ni) begin : proc_prio_regs
58+
if(~rst_ni) begin
59+
rr_q <= 0;
60+
end else begin
61+
rr_q <= rr_d;
62+
end
63+
end
64+
65+
assign sel_o = rr_q;
66+
end
67+
68+
assign payload_o = {{NumOut}{payload_i}};
69+
70+
endmodule : rr_distributor

0 commit comments

Comments
 (0)