integer i;always@(posedge clk)beginfor(i=0; i<61; i = i+1)beginif(data[i+3:i]==4'b0000)begin
occurrences[i]=1'b1;endelse
occurrences[i]=0;endend
It keeps giving me an error in line if(data[i+3:i]==4'b0000) begin
saying 'i' is not a constant.
But when I compare just one bit with
if(data==0)
it synthesizes successfully.
Why is this?
I am just curious why is that comparing for a single bit with i as index is not a problem while I do it for multiple bits i+3:i, its not synthesizable?
The problem is the width of the slice must be a constant. The slice width is defined as follows:
[some_starting_index +: slice_width_constant]
Therefore in your case you should have written:
Code Verilog - [expand]
1
2
3
4
5
6
// use this...if(data[i +:4]==4'b0000)begin// +:4 is the width of the slice starting at i so i==0 => 3:0// the [i+3 -:4] would be // i==0 starts at 3 and goes down to 0 (-:4) => 3:0// instead of...if(data[i+3:i]==4'b0000)begin