quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif rand_mode()

Vera provides the predefined rand_mode() method to control whether a random variable is active or inactive. When a random variable is inactive, it is treated the same as if it had not been declared rand or randc. All random variables are initially active.

   

space.gif

Syntax

   

space.gif

function integer object_name.rand_mode( ON | OFF | REPORT [, string
variable_name [,integer index]]);
   

space.gif

Where

   

space.gif

  • object_name: Is the name of the object in which the random variables are defined.
  • ON: Sets the specified variables to active so that they are randomized on subsequent calls to the randomize() method.
  • OFF: Sets the specified variables to inactive so that they are not randomized on subsequent calls to the randomize() method.
  • REPORT: Returns the current ON/OFF value for the specified variable.
  • variable_name : Is a string with the name of the variable to be made active or inactive. It can be the name of any variable in the class hierarchy. If it is not specified, the action is applied to all variables within the specified object.
  • index : Is an optional array index. If the variable is an array, omitting the index results in all the elements of the array being affected by the call. An index value of -1 is treated the same as index omission.
   

space.gif

   

space.gif

  ../images/main/4blue_dots_bullets.gif Example : rand_mode()
   

space.gif


  1 class frame_t {
  2   rand bit [7:0] src_addr;
  3   rand bit [7:0] dst_addr;
  4   task print() {
  5     integer i =0;
  6     printf("Source      address %2x\n",src_addr);
  7     printf("Destination address %2x\n",dst_addr);
  8   }  
  9 }
 10 
 11 program rand_ex {
 12    frame_t frame = new();
 13    integer j = 0;
 14    printf("-------------------------------\n");
 15    printf("Without Randomize Value\n");
 16    frame.print();
 17    printf("-------------------------------\n");
 18    printf("With Randomize Value\n");
 19    j = frame.randomize();
 20    frame.print();
 21    printf("-------------------------------\n");
 22    printf("With Randomize OFF and Randomize\n");
 23    j = frame.rand_mode(OFF);
 24    j = frame.randomize();
 25    frame.print();
 26    printf("-------------------------------\n");
 27    printf("With Randomize ON and Randomize\n");
 28    j = frame.rand_mode(ON);
 29    j = frame.randomize();
 30    frame.print();
 31    printf("-------------------------------\n");
 32    printf("With Randomize OFF on dest addr and Randomize\n");
 33    j = frame.rand_mode(OFF,"dst_addr");
 34    j = frame.randomize();
 35    frame.print();
 36    printf("-------------------------------\n");
 37 }
You could download file rand_mode_ex.vr here
   

space.gif

  ../images/main/4blue_dots_bullets.gif Simulation Output : rand_mode()
   

space.gif

 -------------------------------
 Without Randomize Value
 Source      address xx
 Destination address xx
 -------------------------------
 With Randomize Value
 Source      address 36
 Destination address 3c
 -------------------------------
 With Randomize OFF and Randomize
 Source      address 36
 Destination address 3c
 -------------------------------
 With Randomize ON and Randomize
 Source      address 7d
 Destination address e2
 -------------------------------
 With Randomize OFF on dest addr and Randomize
 Source      address 0b
 Destination address e2
 -------------------------------
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com