omara007
Advanced Member level 4
- Joined
- Jan 6, 2003
- Messages
- 1,237
- Helped
- 50
- Reputation
- 102
- Reaction score
- 16
- Trophy points
- 1,318
- Location
- Cairo/Egypt
- Activity points
- 9,716
verilog for loop
As in the topic.
As in the topic.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
FvM said:To be synthesizable, the iteration count must be finite and it has to be unequivocally determined at compile time.
reg [2:0] index;
always @ (*) begin
if (&y) begin
for (index=0; index<=`N-1; index=index+1) begin
if (y[index]) begin
z = index;
end //if
end //for
end //if
end //always
loop iteration 2000 exceeded - add '//synthesize loop_limit 4000' before the loop construct.
FvM said:You presented an example, where the iteration count apparently can't be unequivocally determined at compile time. It's not a matter of using a particular type with a range for loop variable. A loop variable is of integer type and has a 2^32 range compiler internally. I don't know, why the compilers iteration limit of 4000 is reached in this case. Either N is undefined or the compiler don't like a 3 bit variable in this place.
With a well defined N, a for loop should work without any problems.
dcreddy1980 said:Hi Omara007,
The logic is very strange to me :
U have condition : if(&y) --> it means if all the bits in y-register are one then only the condition will be true and u have a for loop in which u try to store bit position in to a register called "z" and for this u use if(y[index]) condition.
if(y[index]) condition can be removed, its redundant unless otherwise if you want to use only a slice of the register "y" width.
Regards,
dcreddy1980
swapnil_vlsi said:the 'while loop' is more convenient but I know from at least one
synthesis tool that it does not support the while,(i tried) therefor use insted for loop