quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Conditional Constraints

There are two types of conditional constraints.

   

space.gif

  • Implication =>
  • if-else
   

space.gif

Implication is similar to when in e language. It works like, if condition is true then apply constraint. If-else is similar to Implication => constraint, both can be used.

   

space.gif

   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example : conditional
   

space.gif


  1 class frame_t {
  2   enum size_t = RUNT,NORMAL,OVERSIZE;
  3   rand bit [15:0] length;
  4   rand size_t size;
  5 
  6   constraint frame_sizes {
  7     size == NORMAL => {
  8       length dist {
  9         64  :  127  := 10,
 10         128 :  511  := 10,
 11         512 :  1500 := 10
 12       };
 13     }
 14     if (size == RUNT)  {
 15       length >= 0;
 16       length <= 63;
 17     } else if (size == OVERSIZE) {
 18       length >= 1501;
 19       length <= 5000;
 20     }
 21   }
 22 }
 23 
 24 program distribution {
 25    frame_t frame = new();
 26    integer i,j = 0;
 27    for (j=0;j < 4; j++) {
 28      printf("-------------------------------\n");
 29      printf("Randomize Value\n");
 30      i = frame.randomize();
 31      frame.object_print();
 32    }
 33    printf("-------------------------------\n");
 34 }
You could download file conditional_con.vr here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation Output : conditional
   

space.gif

 -------------------------------
 Randomize Value
     length              : hex: 05fe
     size                : ENUM: frame_t::OVERSIZE
 -------------------------------
 Randomize Value
     length              : hex: 0878
     size                : ENUM: frame_t::OVERSIZE
 -------------------------------
 Randomize Value
     length              : hex: 001e
     size                : ENUM: frame_t::RUNT
 -------------------------------
 Randomize Value
     length              : hex: 0032
     size                : ENUM: frame_t::RUNT
 -------------------------------
   

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