Quantcast
Channel: UVM Forums RSS Feed
Viewing all articles
Browse latest Browse all 756

Rnadomize a variable inside a function

$
0
0

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.


Viewing all articles
Browse latest Browse all 756

Trending Articles