Trying to write a simple N bit priority arbiter (which will prioritize req[0]>req[1]>req[2] ... req[N].Thanks much.
Working code:
assign grant_simple[0] = req_in[0];
generate
for (i=1; i<N; i++)
assign grant_simple[i] = req_in[i] & (!(|req_in[i-1:0]));
endgenerate
But i tried without generate and using always_comb block like this.
assign grant_simple[0] = req_in[0];
always_comb begin
for (int i=1; i<N; i++)
grant_simple[i] = req_in[i] & (!(|req_in[i-1:0]));
end //always
This is giving me an error.
Error-[IRIPS] Illegal range in part select design.sv, 18 The range of the part select is illegal: req_in[(i - 1):0]
Error-[TCF-CETE] Cannot evaluate the expression design.sv, 18 "(i - 1)" Cannot evaluate the expression in left slicing expression. The expression must be compile time constant.
I tried replacing [i-1:0] with i-:1 but i dont think it does the same thing. Looking for a clear explanation on why generate is ok with the [i-1:0] and not the for loop without generate. How to use the bit slicing in this case for system verilog.
Your solution for adding an extra line in the for loop works fine. Thank you.
I have a similar question as well.
Say if i am using a generate statement in the always_ff.
generate
for (i ...)
always_ff @(posedge clock, negedge reset)
<reset condition>
else
<actual code>
My question is how to deal with /seperate the reset condition from the always_ff block in the for loop? Its not very intuitive. You will get the multi driver error with the above code.
Thanks.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 113 |
Nodes: | 8 (1 / 7) |
Uptime: | 56:30:23 |
Calls: | 2,471 |
Files: | 8,638 |
Messages: | 1,898,016 |