Address constraint randomization

Hi, I am trying to solve randomization questions online.
I came across a question: For 4GB memory constraint 5% upper boundary and 5% lower boundary.

Looking at the question, dist is what came to my mind.
But I’m not able to understand the upper and lower boundaries.

Thanks,
Sruthi.

In reply to sk7799:

5% of 4GB is 200MB. It is unclear if they mean the first 200MB address and the last 200MB addresses, or the addresses in-between. Also unclear what they want to do with those addresses.

In reply to dave_59:
Hi Dave,

The question is that there’s a 4GB memory space. Write a constraint so that the addresses are populated 5% in the upper 1GB boundary and 5% in the lower 1GB boundary.

Also here as per my understanding from your previous discussions on dist in the forum, I should be using :=
Please advice.

Thanks.

In reply to sk7799:

5% of 4Gb is 200Mb. But if you mean you want to randomly generate addresses within a set of bounds

class transaction;
  rand bit [31:0] address;
       bit [31:0] boundary = 32'h4000_0000; // 1GB
  constraint bounds { address dist {[0:boundary-1]:/ 5,
                                    [boundary:'1-boundary] :/ 90,
                                    ['1-boundary+1:'1] :/5 };
  }
endclass

In reply to dave_59:

Hi Dave,

In the above code, is it mandatory to have 100% distributed while using the dist operator.
Also, I couldn’t understand why 1 is being subtracted from the boundary.

Please let me know.

Thanks in advance.

In reply to sk7799:

The weight values are arbitrary. If they add up to 100 then it is easy to put them in terms of percentages.

The -1, +1 is to prevent overlapping values so they are not disproportionately weighted.