I wrote code in verilog that cycles through active channels. The idea is to skip channels that are marked by 0 in the activity vector.
I tested the code in a simulator screen shot from simulatior, it works and performs as expected.
When I try to synthesize the code using Synplify Pro, I get an error: "E CS162 Loop iteration limit 4000 exceeded - add '// synthesis loop_limit 8000' before the loop construct test1.v (11)"
The error points to the condition of the loop (i < 6'b100000
).
Searching for the error in google I found a common mistake in a similar code of having i
the same length as channel
which makes the loop to run indefinetly because 11111 + 1 = 00000
.
Also, there is some bug in Xilinx software but i'm not using it.
Any idea why i'm getting this error or why it differs from simulation? Is there a way to implement this function without a loop?
This is the code:
module test1 (
input wire [31:0] activity,
input wire RESET,
input wire CLK);
reg [4:0] channel, next_channel;
reg [5:0] i,j;
always @(activity, channel) begin
next_channel = 5'b0;
for (i = 6'b0; i < 6'b100000 ; i = i + 6'b1) begin
j = i + {1'b0, channel} + 6'b1;
if (j>6'b011111)
j = j - 6'b100000;
if (activity[j[4:0]]) begin
next_channel = j[4:0];
i = 6'b101111;
end
end
end
always @(posedge CLK, negedge RESET) begin
if (RESET == 1'b0)
channel = 5'b0;
else
channel = next_channel;
end
endmodule
i = 47
line meant to do? Are you trying to exit the loop early? I think you're confusing the compiler, which thinks (correctly) that you've now got a variable iteration count. I don't think Synplify is smart enough to handle a variable limit. Think hardware - a functioning simulation is no guarantee that you can synthesise. - EML