How to randomize realtime values in SV/UVM

Hi,

Clk is 260 Mhz. Time period is 3.8. I have to use multiples of clk period and give it from testcase and randomize .
How should I randomize realtime values in UVM/SV?

In reply to poonamnlwd:

Dou want to use a randomized frequency? Or what is your intention?
BTW you cannot randomize real data types directly. You have to convert them to an integer and reconvert to real.

In reply to chr_sue:

Hi,

I want use randomized time for giving delay. and I am giving in like 3.8 ,15.2, time from testcase.

In reply to poonamnlwd:

can I do like before randomize use integer and after randomize convert it into real?
But will get values which I want like 3.8,15.2 in driver?

In reply to poonamnlwd:

Is it multiples of 3.8 you want to use? Then simply randomize the factor like this:
rand int mult;
Then you can do the following in the driver:

delay = req.mult*3.8;
Or you do prior to randomizing: multiply with 10 and after randomizaion you are dividing by 10.
But I believ you want to select values from a given list in random order. Right?

In reply to chr_sue:

In reply to poonamnlwd:
Is it multiples of 3.8 you want to use? Then simply randomize the factor like this:
rand int mult;
Then you can do the following in the driver:
delay = req.mult*3.8;
Or you do prior to randomizing: multiply with 10 and after randomizaion you are dividing by 10.
But I believ you want to select values from a given list in random order. Right?

Sorry for late reply.


  in testcase,
  int delay;
  delay = 15.2 * 10;

  in driver,

  int delay;
  real real_delay;
  
  real_delay = real'(delay/10);

when I am printing value of real_delay, I am getting value 15. 
what can I do so that I will get 15.2 value?




 

In reply to poonamnlwd:

In reply to chr_sue:
Sorry for late reply.


in testcase,
int delay;
delay = 15.2 * 10;
in driver,
int delay;
real real_delay;
real_delay = real'(delay/10);
when I am printing value of real_delay, I am getting value 15. 
what can I do so that I will get 15.2 value?

with your solution I am able to give real delay.

In reply to poonamnlwd:

You should check what your time scale and resolution is.

In reply to chr_sue:

In reply to poonamnlwd:
You should check what your time scale and resolution is.



  in testcase,
  int delay;
  delay = 15.2 * 10;
 
  in driver,
 
  int delay;
  real real_delay;
 
  real_delay = real/10.0 ;

Its working in above way.