-
Notifications
You must be signed in to change notification settings - Fork 186
add round-robin distributor #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
micprog
wants to merge
6
commits into
master
Choose a base branch
from
rr_distributor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+97
−1
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c4f62d7
Add rr_distributor
micprog f0edaf8
Add description for round-robin distributor
micprog 061cc72
Fix lint error
micprog ebe83fe
Add comments from reviewer
micprog 5635be9
rr_distributor: add StrictRR parameter, clarify distribution
micprog 3e433be
rr_distributor: default to compliant behavior
micprog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ package: | |
| - "Manuel Eggimann <[email protected]>" | ||
| - "Stefan Mach <[email protected]>" | ||
| - "Wolfgang Roenninger <[email protected]>" | ||
| - "Thomas Benz <[email protected]>" | ||
|
|
||
| dependencies: | ||
| common_verification: { git: "https://github.com/pulp-platform/common_verification.git", version: 0.2.0 } | ||
|
|
@@ -44,6 +45,7 @@ sources: | |
| - src/plru_tree.sv | ||
| - src/popcount.sv | ||
| - src/rr_arb_tree.sv | ||
| - src/rr_distributor.sv | ||
| - src/rstgen_bypass.sv | ||
| - src/serial_deglitch.sv | ||
| - src/shift_reg.sv | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| // Copyright 2019 ETH Zurich and University of Bologna. | ||
| // Copyright and related rights are licensed under the Solderpad Hardware | ||
| // License, Version 0.51 (the "License"); you may not use this file except in | ||
| // compliance with the License. You may obtain a copy of the License at | ||
| // http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law | ||
| // or agreed to in writing, software, hardware and materials distributed under | ||
| // this License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
| // CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations under the License. | ||
| // | ||
| // Author: Thomas Benz <[email protected]>, ETH Zurich | ||
| // Date: 12.01.2021 | ||
| // Description: round robin distributor | ||
|
|
||
| /// The rr_distributor forwards requests to individual outputs in a round robin fashion. | ||
| module rr_distributor # ( | ||
| /// Number of outputs to distribute to. | ||
| parameter int unsigned NumOut = 1, | ||
| /// Data width of the payload in bits. Not needed if `data_t` is overwritten. | ||
| parameter int unsigned Width = 1, | ||
| /// Data type of the payload, can be overwritten with a custom type. Only use of `Width`. | ||
| parameter type data_t = logic [Width-1:0], | ||
| /// Setting StrictRR enforces a strict round-robin distribution | ||
| /// If set to 1'b1, the rr_distributor will distribute the requests to the next output | ||
| /// in line, irrespective if this output is ready or not, irrespective if another | ||
| /// output could accept the request. The transaction will wait until the next one in | ||
| /// line accepts the handshake. | ||
| /// If set to 1'b0, the rr_distributor will step through the outputs if one is ready | ||
| /// but the current one is not. This can reduce wait time for the input. | ||
| /// **THIS IS NOT COMPLIANT AS IT MAY DE-ASSERT VALID WITHOUT A PROPER HANDSHAKE** | ||
| parameter bit StrictRR = 1'b1, | ||
| /// Dependent parameter, do **not** overwrite. | ||
| /// Width of the selected index | ||
| parameter int unsigned IdxWidth = cf_math_pkg::idx_width(NumOut), | ||
| /// Dependent parameter, do **not** overwrite. | ||
| /// type of the selected index | ||
| parameter type idx_t = logic [IdxWidth-1:0] | ||
| ) ( | ||
| input logic clk_i, | ||
| input logic rst_ni, | ||
| // input stream | ||
| input logic valid_i, | ||
| output logic ready_o, | ||
| input data_t payload_i, | ||
| // output stream | ||
| output logic [NumOut-1:0] valid_o, | ||
| input logic [NumOut-1:0] ready_i, | ||
| output data_t [NumOut-1:0] payload_o, | ||
| output idx_t sel_o | ||
| ); | ||
|
|
||
| if (NumOut == 1) begin : gen_bypass | ||
| assign valid_o[0] = valid_i; | ||
| assign ready_o = ready_i[0]; | ||
| assign sel_o = 1'b0; | ||
| end else begin : gen_arb | ||
|
|
||
| idx_t rr_d, rr_q; | ||
| logic one_ready; | ||
|
|
||
| always_comb begin : rr_next | ||
| rr_d = rr_q; | ||
| if (valid_i && ( ready_i[rr_q] || (one_ready && !StrictRR))) begin | ||
| if (rr_q == idx_t'(NumOut - 1)) begin | ||
| rr_d = '0; | ||
| end else begin | ||
| rr_d = rr_q + 1'b1; | ||
| end | ||
| end | ||
| end | ||
|
|
||
| assign one_ready = |ready_i; | ||
|
|
||
| always_comb begin : proc_arbitration | ||
| valid_o = '0; | ||
| valid_o[rr_q] = valid_i; | ||
| end | ||
| assign ready_o = ready_i[rr_q]; | ||
|
|
||
| always_ff @(posedge clk_i or negedge rst_ni) begin : proc_prio_regs | ||
| if(~rst_ni) begin | ||
| rr_q <= 0; | ||
| end else begin | ||
| rr_q <= rr_d; | ||
| end | ||
| end | ||
|
|
||
| assign sel_o = rr_q; | ||
| end | ||
|
|
||
| assign payload_o = {{NumOut}{payload_i}}; | ||
|
|
||
| endmodule : rr_distributor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.