enchanter Posted May 29, 2014 Report Share Posted May 29, 2014 I have a dynamic array in sequence item as below: rand int array_size; rand int a []; constraint c_order {solve array_size before a;}; constraint c_size { a.size() == array_size;}; In some tests, I hope to only create the array according to the randomized value of array_size but not do randomize on the value of it. Is there any way I can do that? Quote Link to comment Share on other sites More sharing options...
dave_59 Posted May 29, 2014 Report Share Posted May 29, 2014 Why is it you don't want the elements of array a to be randomized? If it is because you want the array values to be 0, then just add that constraint - foreach(a) a == 0; Quote Link to comment Share on other sites More sharing options...
enchanter Posted June 2, 2014 Author Report Share Posted June 2, 2014 Why is it you don't want the elements of array a to be randomized? If it is because you want the array values to be 0, then just add that constraint - foreach(a) a == 0; Most time, I expect random value to test DUT. But sometimes I hope to get some simple patterns to test my verification environment, for example I expect the size is random but the value are constant or in/decreasing etc. If I use foreach, could I turn it off when I expect random value? Quote Link to comment Share on other sites More sharing options...
tudor.timi Posted June 2, 2014 Report Share Posted June 2, 2014 You can put the foreach constraint that dave_59 suggested in a separate constraint block and disable that using constraint_mode(0). Ex; // somewhere in your class constraint fixed_vals_c { foreach (a[i]) a[i] == 0; } // somewhere where you randomize some_obj.fixed_vals_c.constraint_mode(0); some_obj.randomize(); // will gen random vals for array Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.