# Conditional Statement in 'repeat loop'

**URL:** <https://verificationacademy.com/forums/t/conditional-statement-in-repeat-loop/40342>\
**Category:** SystemVerilog\
**Tags:** transition-coverage-cross-bins-ignore\_bins, Coverage-bins, SystemVerilog, Coverage, systemverilog-Arrays-logics, uvm-packed-unpacked-array-SV\
**Created:** [May 2, 2022, 7:10pm UTC](https://verificationacademy.com/forums/t/conditional-statement-in-repeat-loop/40342 "2022-05-02T19:10:36Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![rag123](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/r/eada6e/32.png) [@rag123](https://verificationacademy.com/forums/u/rag123)\
**Post date:** [May 3, 2022, 1:53am UTC](https://verificationacademy.com/forums/t/conditional-statement-in-repeat-loop/40342/6 "2022-05-03T01:53:34Z")

</div>

_In reply to [Shashank Gurijala](https://verificationacademy.com/forums/t/conditional-statement-in-repeat-loop/40342/5):_

```verilog

// 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

```

---

_[View the full topic](https://verificationacademy.com/forums/t/conditional-statement-in-repeat-loop/40342)._
