# How to constrain 2 dynamic arrays to related to each other?

**URL:** <https://verificationacademy.com/forums/t/how-to-constrain-2-dynamic-arrays-to-related-to-each-other/34841>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, constraint-array\
**Created:** [August 9, 2018, 9:51pm UTC](https://verificationacademy.com/forums/t/how-to-constrain-2-dynamic-arrays-to-related-to-each-other/34841 "2018-08-09T21:51:29Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![javatea](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/j/3d9bf3/32.png) [@javatea](https://verificationacademy.com/forums/u/javatea)\
**Post date:** [August 26, 2018, 12:08pm UTC](https://verificationacademy.com/forums/t/how-to-constrain-2-dynamic-arrays-to-related-to-each-other/34841/6 "2018-08-26T12:08:35Z")

</div>

_In reply to [mlsxdx](https://verificationacademy.com/forums/t/how-to-constrain-2-dynamic-arrays-to-related-to-each-other/34841/5):_

your requirement is still not very clear to me.  
btw, try this idea

rand c\_typ\_e Cs;  
rand shortint arr\_sz;  
rand e\_typ\_e E\_set; // e\_typ\_e distribution set in C0 and C1  
e\_typ\_e Es;

1. constraint block to solve Cs (size is 8) and E\_set (size is 4) first

2. post\_randomize() for final Es (size 8)  
based on Cs and E\_set constrainted results

---

_[View the full topic](https://verificationacademy.com/forums/t/how-to-constrain-2-dynamic-arrays-to-related-to-each-other/34841)._
