qwerty Posted April 29, 2014 Report Posted April 29, 2014 Hi, I want to randomize a variable defined in a function. The function is inside a package. I tried declaring a class inside the package and taking the instance of that class in the function. But that didnt work out as the object needs to be static. I tried randomization() function, but the problem is the variable "k" can only have 2 value ie (5,9). function foo() int k; void'(randomize(k)) with {k==5;k==9;}); // I am getting randomization failure in this case. endfunction Let me know how can this be resolved. Thanks. Quote
tudor.timi Posted April 29, 2014 Report Posted April 29, 2014 You have to do std::randomize(k) to randomize variables declared in the global scope. With respect to k's value, you just constrained it to be both '5' and '9' at the same time. You have to say "k inside { 5, 9 }". Quote
dave_59 Posted April 29, 2014 Report Posted April 29, 2014 The reason for the failure is because of the bad constraint. Since the call to randomize is outside of a class declaration, std::randomize() gets called implicitly. tudor.timi 1 Quote
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.