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

inline_constraint _declaration ::=
class_variable_identifier . randomize [
   ( [ variable_identifier_list | null ] ) ]
with constraint_block
   

space.gif

Where

   

space.gif

  • class_variable_identifier : Is the name of the instantiated object.
  • The unnamed constraint_block contains additional in-line 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 program randomize_with;
  2   class frame_t;
  3     rand bit [7:0] src_addr;
  4     rand bit [7:0] dst_addr;
  5     constraint c {
  6       src_addr <=  127;
  7       dst_addr >=  128;
  8     }
  9     task print();
 10       begin 
 11         $write("Source      address %2x\n",src_addr);
 12         $write("Destination address %2x\n",dst_addr);
 13       end
 14     endtask  
 15   endclass
 16 
 17 
 18   initial begin
 19     frame_t frame = new();
 20     integer i = 0;
 21     $write("-------------------------------\n");
 22     $write("Randomize Value\n");
 23     i = frame.randomize();
 24     frame.print();
 25     $write("-------------------------------\n");
 26     $write("Randomize with Value\n");
 27     i = frame.randomize() with {
 28       src_addr > 100;
 29       dst_addr < 130;
 30       dst_addr > 128;
 31     };
 32     frame.print();
 33     $write("-------------------------------\n");
 34   end
 35 endprogram
You could download file randomize_with.sv here
   

space.gif

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

space.gif

 -------------------------------
 Randomize Value
 Source      address 02
 Destination address ab
 -------------------------------
 Randomize with Value
 Source      address 79
 Destination address 81
 -------------------------------
   

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