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 pre/post randomize()

Every class contains built-in pre_randomize() and post_randomize() tasks, that are automatically called by randomize() before and after it computes new random values.

   

space.gif

When obj.randomize() is invoked, it first invokes pre_randomize() on obj and also all of its random object members that are enabled. Pre_randomize() then recursively calls super.pre_randomize().

   

space.gif

Post_randomize() then recursively calls super.post_randomize(). You may overload the pre_randomize() in any class to perform initialization and set pre-conditions before the object is randomized.

   

space.gif

You may overload the post_randomize() in any class to perform cleanup, print diagnostics, and check post-conditions after the object is randomized.

   

space.gif

   

space.gif

  ../images/main/4blue_dots_bullets.gif Example : pre/post randomize()
   

space.gif


  1 class frame_t {
  2   rand bit [7:0] data;
  3   bit  parity;
  4   constraint c {
  5      data >  0;
  6   }
  7   task pre_randomize() {
  8     printf("Value of data %b and parity %b\n",data,parity);
  9   }
 10   task post_randomize() {
 11    parity = ^data;
 12   }
 13 }
 14 
 15 program pre_post_randomize {
 16    frame_t frame = new();
 17    integer i = 0;
 18    printf("-------------------------------\n");
 19    printf("Randomize Value\n");
 20    i = frame.randomize();
 21    printf("-------------------------------\n");
 22    frame.object_print();
 23    printf("-------------------------------\n");
 24 }
You could download file pre_post_randomize.vr here
   

space.gif

  ../images/main/4blue_dots_bullets.gif Simulation Output : pre/post randomize()
   

space.gif

 -------------------------------
 Randomize Value
 value of data xxxxxxxx and parity x
 -------------------------------
 
 "CALLING object_print":
 
     data                : hex: 06
     parity              : hex: 0
 -------------------------------
   

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