I learn XST manual and meet some questions about While LOOPS
I found this in that manual
1.To prevent endless loops, use the "–loop_iteration_limit" switch.
2.While loops can have Disable statements. The Disable statement must be use inside a labeled block, since the syntax is "disable<blockname>."
who can give me some example for 2 and told how to set the "–loop_iteration_limit" switch:|
module test();
integer i;
initial i=0;
// Print 0 to 100
initial begin
begin : my_block // <-- this is the my_block we will disable
while(1) begin // infinite while loop
if (i>100)
disable my_block;
else
$display("%d",i);
i=i+1;
end
end
end
endmodule // test
This is the code for count leading zero's in input byte!!
Code:
module test(din, cnt);
input [7:0] din;
output [3:0] cnt;
reg [3:0] cnt;
always @(/-*AS*-/din) begin
cnt = 0;
begin : my_block // <-- this is the my_block we will disable
integer i;
i=7;
while(i >= 0) begin // infinite while loop
if (din[i] == 1'b1)
disable my_block;
else
cnt = cnt + 1;
i=i-1;
end
end
end
endmodule // test
You can use it in synthesizable code but not recomended!!!