# Constraint of address in higher limit and lower limit and some of the adress in between

**URL:** <https://verificationacademy.com/forums/t/constraint-of-address-in-higher-limit-and-lower-limit-and-some-of-the-adress-in-between/34504>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, constrained-random-generation\
**Created:** [May 28, 2018, 1:32pm UTC](https://verificationacademy.com/forums/t/constraint-of-address-in-higher-limit-and-lower-limit-and-some-of-the-adress-in-between/34504 "2018-05-28T13:32:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![syedtaahirahmed](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@syedtaahirahmed](https://verificationacademy.com/forums/u/syedtaahirahmed)\
**Post date:** [May 28, 2018, 1:32pm UTC](https://verificationacademy.com/forums/t/constraint-of-address-in-higher-limit-and-lower-limit-and-some-of-the-adress-in-between/34504/1 "2018-05-28T13:32:38Z")

</div>

Hi

I have a scenario which includes following Constraint to be taken care :: Please help on the logic

1)There is a 2MB memory address, i have to constraint the address in such a way that every time the test executes it hits the higher limit  
and the lower limit and some of the address in between the space.

1. I have to covert the byte variable in to Dword size, is there a inbuilt SV function to do it? or easy way ?

Thanks

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [May 29, 2018, 6:40am UTC](https://verificationacademy.com/forums/t/constraint-of-address-in-higher-limit-and-lower-limit-and-some-of-the-adress-in-between/34504/2 "2018-05-29T06:40:50Z")

</div>

_In reply to [syed taahir ahmed](https://verificationacademy.com/forums/t/constraint-of-address-in-higher-limit-and-lower-limit-and-some-of-the-adress-in-between/34504):_

There are many ways to do this if you give more details. For example, you could write a directed test

```verilog
randomize () with {address == low_limit};
...
randomize () with {address inside ([low_limit+1:high_limit-1]};
...
randomize () with {address == high_limit};

```

You could also use the ‘list’ constraint if you call randomize enough time to have a high probability of hitting the limits.

```verilog
randomize() with {address dist {low_limit:=1, high_limit :=1, [low_limit+1:high_limit-1] :=1};}

```

You second question needs an example and should be a separate post

---

<div class="post-metadata">

**Author:** ![syedtaahirahmed](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@syedtaahirahmed](https://verificationacademy.com/forums/u/syedtaahirahmed)\
**Post date:** [May 29, 2018, 7:17am UTC](https://verificationacademy.com/forums/t/constraint-of-address-in-higher-limit-and-lower-limit-and-some-of-the-adress-in-between/34504/3 "2018-05-29T07:17:46Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/constraint-of-address-in-higher-limit-and-lower-limit-and-some-of-the-adress-in-between/34504/2):_

> _In reply to [syed taahir ahmed](https://verificationacademy.com/forums/t/constraint-of-address-in-higher-limit-and-lower-limit-and-some-of-the-adress-in-between/34504/2):_  
> There are many ways to do this if you give more details. For example, you could write a directed test

```verilog
randomize () with {address == low_limit};
...
randomize () with {address inside ([low_limit+1:high_limit-1]};
...
randomize () with {address == high_limit};

```

You could also use the ‘list’ constraint if you call randomize enough time to have a high probability of hitting the limits.

```verilog
randomize() with {address dist {low_limit:=1, high_limit :=1, [low_limit+1:high_limit-1] :=1};}

```

You second question needs an example and should be a separate post

Ok Dave, I will use another post for second question .

But for your question-1, the solution works.
