Conditional Statement in 'repeat loop'

Hello!
Here is a sample code to verify the transitional bins. I’ve repeated the loop randomly for 100000 times for functional coverage to become 100%.
Now I want to add a condition in the repeat loop that at coverage = 100%, the block has to terminate. What changes should I make to the code?

module transition_bins;

	bit [3:0] data;
	
	covergroup cg;
	
		c1: coverpoint data { 
		
				      bins d1[]   =  (9 => 3);
								
		         	      bins d2[]   =  (4 => 8 => 12);
							  
				      bins d3[]   =  (2,3 => 4,5); 
							  
	 		              bins d4[]   =  (2,3,4 => 5,6,7); 
							  
				      bins d5[]   =  (4'hd[*2] => 5,6,7);
							  
				      bins d6[]   =  (7[*2:4]); 
				  
				      bins d7     =  (9 => 5[->3] => 11);

				      bins d8     =  (12 => 15[=3] => 10);
		
				      }
							
							
	endgroup: cg
	
	initial 
	
		begin
		
			cg c = new;
			
			repeat (100000) //what should I change so that when the coverage is 100%, the repeat block terminates?
			
				begin
				
					data = $random;
					
					$display("\ndata = %0h",data);
					
					c.sample();
					
				end
				
			$display("\nCoverage = %0.4f%%",c.get_inst_coverage());
			
		end
		
endmodule

Thankyou!

In reply to Shashank Gurijala:

See the break statement.

In reply to Shashank Gurijala:

you can do something like this:

   if (c.c1.get_coverage()==100.0)
   begin    
       $display("Total coverage = %6.2f", c.c1.get_coverage());
       $finish();
   end

In reply to Shashank Gurijala:



// Code your testbench here
// or browse Examples
module transition_bins;
 bit [3:0] data;
 covergroup cg;
 c1: coverpoint data { 
 
				      bins d1[]   =  (9 => 3);
 
		         	      bins d2[]   =  (4 => 8 => 12);
 
				      bins d3[]   =  (2,3 => 4,5); 
 
	 		              bins d4[]   =  (2,3,4 => 5,6,7); 
 
				      bins d5[]   =  (4'hd[*2] => 5,6,7);
 
				      bins d6[]   =  (7[*2:4]); 
 
				      bins d7     =  (9 => 5[->3] => 11);
 
				      bins d8     =  (12 => 15[=3] => 10);
 
				      }
 
 
	endgroup: cg
 
	initial 
 
		begin
 
			cg c = new;
 
          repeat (100000) //what should I change so that when the coverage is 100%, the repeat block terminates?
 
				begin
 
					data = $random;
 
					$display("\ndata = %0h",data);
 
					c.sample();
               if (c.get_inst_coverage==100.00) break;

                   
                  
				end
 
			$display("\nCoverage = %0.4f%%",c.get_inst_coverage());
          
          
     end
 
endmodule

In reply to rag123:

Yeah i did the same using if loop you tried. But I want to repeat the block exactly until coverage is 100% without mentioning any integer in the repeat block.

In reply to Shashank Gurijala:



// Code your testbench here
// or browse Examples
module transition_bins;
 bit [3:0] data;
 covergroup cg;
 c1: coverpoint data { 
 
				      bins d1[]   =  (9 => 3);
 
		         	      bins d2[]   =  (4 => 8 => 12);
 
				      bins d3[]   =  (2,3 => 4,5); 
 
	 		              bins d4[]   =  (2,3,4 => 5,6,7); 
 
				      bins d5[]   =  (4'hd[*2] => 5,6,7);
 
				      bins d6[]   =  (7[*2:4]); 
 
				      bins d7     =  (9 => 5[->3] => 11);
 
				      bins d8     =  (12 => 15[=3] => 10);
 
				      }
 
 
	endgroup: cg
 
	initial 
 
		begin
 
			cg c = new;
 
          while (c.get_inst_coverage!=100.00) //what should I change so that when the coverage is 100%, the repeat block terminates?
 
				begin
 
					data = $random;
 
					$display("\ndata = %0h",data);
 
					c.sample();
             
 
 
 
				end
 
			$display("\nCoverage = %0.4f%%",c.get_inst_coverage());
 
 
     end
 
endmodule


In reply to rag123:

I tried using the forever loop and if loop inside and then break it. But I want to know if its possible to do it in repeat loop.

And using while is another idea, too. Thanks!