Skip to content

Commit

Permalink
Add intermediate signal when making 'token_lookahead'
Browse files Browse the repository at this point in the history
By assigning token_lookahead directly from the the token replicate there
will always be an over assignment on the RHS. The LSB will get assigned
to the token_lookahead signal and the unused upper bits will be
discarded. This is valid verilog and the desired behaviour, however,
many tools will throw a warning because the width of the LHS and RHS do
not match.

Using an intermediate 'token_wrap' signal allows for only a slice of a
signal to be assigned to the token_lookahead, thus removing the width
discrepancy and warning.
  • Loading branch information
bmartini committed Jul 12, 2014
1 parent 1c234cc commit 4d7be0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/arbiter.v
Expand Up @@ -39,6 +39,8 @@ module arbiter
* Local parameters
*/

localparam WRAP_LENGTH = 2*NUM_PORTS;

`ifdef VERBOSE
initial $display("Bus arbiter with %d units", NUM_PORTS);
`endif
Expand All @@ -55,13 +57,16 @@ module arbiter

reg [NUM_PORTS-1:0] token;
wire [NUM_PORTS-1:0] token_lookahead [NUM_PORTS-1:0];
wire [WRAP_LENGTH-1:0] token_wrap;


/**
* Implementation
*/

assign next = ~|(token & request);
assign token_wrap = {token, token};

assign next = ~|(token & request);


always @(posedge clk)
Expand Down Expand Up @@ -89,7 +94,7 @@ module arbiter
generate
for (xx = 0; xx < NUM_PORTS; xx = xx + 1) begin : ORDER_

assign token_lookahead[xx] = {token, token[NUM_PORTS-1:xx]};
assign token_lookahead[xx] = token_wrap[xx +: NUM_PORTS];

assign order[xx] = |(token_lookahead[xx] & request);

Expand Down
7 changes: 6 additions & 1 deletion src/arbiter_ormux.v
Expand Up @@ -39,6 +39,8 @@ module arbiter
* Local parameters
*/

localparam WRAP_LENGTH = 2*NUM_PORTS;

`ifdef VERBOSE
initial $display("Bus arbiter with %d units", NUM_PORTS);
`endif
Expand All @@ -56,6 +58,7 @@ module arbiter
reg [NUM_PORTS-1:0] token;
wire [NUM_PORTS-1:0] token_nx;
wire [NUM_PORTS-1:0] token_lookahead [NUM_PORTS-1:0];
wire [WRAP_LENGTH-1:0] token_wrap;

wire [NUM_PORTS-1:0] token_gated [0:NUM_PORTS-1];
wire [NUM_PORTS-1:0] invert [0:NUM_PORTS-1];
Expand All @@ -64,6 +67,8 @@ module arbiter
* Implementation
*/

assign token_wrap = {token, token};

assign next = ~|(token & request);

assign order_right = (order_right>>1) | order;
Expand All @@ -89,7 +94,7 @@ module arbiter
generate
for (xx = 0; xx < NUM_PORTS; xx = xx + 1) begin : ORDER_

assign token_lookahead[xx] = {token, token[NUM_PORTS-1:xx]};
assign token_lookahead[xx] = token_wrap[xx +: NUM_PORTS];

assign order[xx] = |(token_lookahead[xx] & request);

Expand Down

0 comments on commit 4d7be0f

Please sign in to comment.