# Percentage weighted distribution of SV Constraints

**URL:** <https://verificationacademy.com/forums/t/percentage-weighted-distribution-of-sv-constraints/40139>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, constraint-dist, constraints, weighted-distribution\
**Created:** [March 10, 2022, 1:59am UTC](https://verificationacademy.com/forums/t/percentage-weighted-distribution-of-sv-constraints/40139 "2022-03-10T01:59:24Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![yourcheers](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/y/5f9b8f/32.png) [@yourcheers](https://verificationacademy.com/forums/u/yourcheers)\
**Post date:** [March 10, 2022, 3:51am UTC](https://verificationacademy.com/forums/t/percentage-weighted-distribution-of-sv-constraints/40139/2 "2022-03-10T03:51:08Z")

</div>

_In reply to [natasv](https://verificationacademy.com/forums/t/percentage-weighted-distribution-of-sv-constraints/40139):_

```auto
class disttest;
    rand bit [2:0] addr;
    constraint c1 { addr dist {[0:5] :/ 6, [6:7] :/ 4}; }
    covergroup cg (); //@(posedge clk);
        coverpoint addr;
    endgroup
endclass

module top();
  bit clk;
  int addrq[$], addr1q[$], res1[$], res2[$];
  always #10 clk = ~clk;

  initial begin
	disttest tc;
	tc = new();
        for(int ii=0; ii<1000; ii++) begin
		tc.randomize();
		addrq.push_back(tc.addr);
	end
	res1 = addrq.find(x) with (x>5);
	res2 = addrq.find(x) with (x<6);
        $display("%p, %p",res1.size(), res2.size());	
end

endmodule

```

---

_[View the full topic](https://verificationacademy.com/forums/t/percentage-weighted-distribution-of-sv-constraints/40139)._
