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 randomize() with

This construct allows the declaration of inline constraints at the point where the randomize() class method is called. These additional constraints are of the same constraint types and forms as would otherwise be declared in the randomized class. The inline constraints are applied along with the object constraints. The original constraints in the class definition does not have to be changed.

   

space.gif

Syntax

   

space.gif

result = class_object_name.randomize([integer mode]) with
constraint_block;
   

space.gif

Where

   

space.gif

  • class_object_name : Is the name of the instantiated object.
  • mode : Can be either CHECK or SOLVE. If mode is not specified, the default behavior is that of SOLVE.
  • constraint_block : Is an anonymous constraint block, which contains the additional inline constraints to be applied along with the object constraints declared in the class.
   

space.gif

   

space.gif

  ../images/main/4blue_dots_bullets.gif Example : randomize with
   

space.gif


  1 class frame_t {
  2   rand bit [7:0] src_addr;
  3   rand bit [7:0] dst_addr;
  4   constraint c {
  5      src_addr <=  127;
  6      dst_addr >=  128;
  7   }
  8   task print() {
  9     integer i =0;
 10     printf("Source      address %3d\n",src_addr);
 11     printf("Destination address %3d\n",dst_addr);
 12   }  
 13 }
 14 
 15 program randomize_with {
 16    frame_t frame = new();
 17    integer i = 0;
 18    printf("-------------------------------\n");
 19    printf("Randomize Value\n");
 20    i = frame.randomize();
 21    frame.print();
 22    printf("-------------------------------\n");
 23    printf("Randomize with Value\n");
 24    i = frame.randomize() with {
 25      src_addr > 100;
 26      dst_addr < 130;
 27      dst_addr > 128;
 28    };
 29    frame.print();
 30    printf("-------------------------------\n");
 31 }
You could download file randomize_with.vr here
   

space.gif

  ../images/main/4blue_dots_bullets.gif Simulation Output : randomize with
   

space.gif

 -------------------------------
 Randomize Value
 Source      address   2
 Destination address 171
 -------------------------------
 Randomize with Value
 Source      address 121
 Destination address 129
 -------------------------------
   

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