UVM randomization dilemma

In reply to Tudor Timi:

Hey Tudor,

Thanks for the response. Il try to shed some more light on the brackets example. Like I said, these objects (basically a collection of words) are interprated as instructions. These objects are read out from memory, the words are decoded and some action is done. So pretty much like a simple CPU. These instructions can also be looped over ( even nested). On an abstract Level, the open bracket represented the Loop start, and closed bracket Loop end. Hence the sequence of brackets must be balanced. An unbalanced sequenced would be illegal but also needs to be simulated for the error case.

So lets say there are two fields in TYPEB which control this:

TYPEB.loop_start
TYPEB.loop_end

Considering an Array size of 10 lets say this is the randomized Array:
AABBBAABBB

Now my main Problem is how to randomize the Loop_starts and Ends across the whole Array

for example lets consider a nested Loop of depth 2

for (x…) begin


for (z) begin


end
end

Heres an example of an Array corresponding to the above example.

INDEX_____TYPE______LOOP_START____LOOP_END
0__________A_________NA_____________NA
1__________A_________NA_____________NA
2__________B__________1______________0 // outer Loop opening
3__________B__________0______________0
4__________B__________1______________0 // inner Loop opening
5__________A_________NA____________ NA
6__________A_________NA_____________NA
7__________B__________0______________0
8__________B__________0______________1 // inner Loop closing
9__________B__________0______________1 // outer Loop closing

Like you already wrote its pretty easy to create an Array of size n with objects of TPYE A or B. The tough part for me is to write the constraints that properly sets the Loop_start/ end fields.

Im guessing i Need to add some helper variables ( higher layer) e.g int nested depth.
if nested depth is 0 that would mean (). The constraints for the Loop_start/end variables
should set Loop_start(1),Loop_end(0) for some TYPE B object and for a later TYPEB one the values should be Loop_start(0),Loop_end(1)

I hope the Problem im facing is clear now. Thanks again