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 randcase

The randcase statement specifies a block of statements, one of which is executed randomly. The keyword randcase introduces a case statement that randomly selects one of its branches. The randcase item expressions are non-negative integral values that constitute the branch weights. An item's weight divided by the sum of all weights gives the probability of taking that branch.

   

space.gif

Syntax : randcase

   

space.gif

statement_item ::=
...
| randcase_statement
randcase_statement ::=
randcase randcase_item { randcase_item } endcase
randcase_item ::= expression : statement_or_null
   

space.gif

   

space.gif

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

space.gif


  1 module randcase_statement;
  2 
  3  task do_randcase();
  4    begin
  5      randcase
  6        20 : begin
  7               $write ("What should I do ? \n");
  8             end
  9        20 : begin
 10               $write ("Should I work\n");
 11             end
 12        20 : begin
 13               $write ("Should I watch Movie\n");
 14             end
 15        40 : begin
 16               $write ("Should I complete tutorial\n");
 17             end
 18      endcase 
 19    end
 20  endtask
 21 
 22  initial begin
 23    repeat(10) begin
 24      // You need to run for more iteration to
 25      // get proper distribution
 26      do_randcase();
 27    end  
 28    $finish;
 29  end
 30 endmodule
You could download file randcase_statement.sv here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation : randcase
   

space.gif

 Should I watch Movie
 Should I complete tutorial
 Should I watch Movie
 What should I do ? 
 Should I complete tutorial
 Should I watch Movie
 Should I complete tutorial
 Should I complete tutorial
 Should I work
 Should I watch Movie
   

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