# Constraint for address to be inside 4k boundary

**URL:** <https://verificationacademy.com/forums/t/constraint-for-address-to-be-inside-4k-boundary/37655>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, constraints\
**Created:** [June 1, 2020, 11:00am UTC](https://verificationacademy.com/forums/t/constraint-for-address-to-be-inside-4k-boundary/37655 "2020-06-01T11:00:23Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![s-smrkic](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/e274bd/32.png) [@s-smrkic](https://verificationacademy.com/forums/u/s-smrkic)\
**Post date:** [June 1, 2020, 4:02pm UTC](https://verificationacademy.com/forums/t/constraint-for-address-to-be-inside-4k-boundary/37655/4 "2020-06-01T16:02:22Z")

</div>

How about something along the lines of:

```verilog
rand bit [17:0] mtestAddr;
rand bit [17:0] mtestEndAddr;

// I'm not sure exactly the formula to calculate ending address of the burst, but that shouldn't be too hard to figure out with the AXI spec, I'll just guess:
constraint end_addr { mtestEndAddr == mtestADDR + 2^Awsize * Awlen -1; }

// Then the constraint will just make sure that starting and ending address of the burst have bits [17:12] equal which means they are both inside the 4K boundary
constraint addr_in_4k { (mtestADDR[17:12] == mtestEndAddr[17:12];}

```

---

_[View the full topic](https://verificationacademy.com/forums/t/constraint-for-address-to-be-inside-4k-boundary/37655)._
