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 case

The case statement compares an expression to a series of cases and executes the statement or statement group associated with the first matching case:

   

space.gif

  • case statement supports single or multiple statements.
  • Group multiple statements using begin and end keywords.
   

space.gif

Syntax:

   

space.gif

case (primary_expression)
 {
    case1_expression : statement
    case2_expression : statement
    ...
    caseN_expression : statement
    default          : statement
 }
   

space.gif

   

space.gif

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

space.gif


  1 program case_statement {
  2   do_case(0);
  3   do_case(1);
  4   do_case(2);
  5 }
  6 
  7 task do_case(bit [1:0] sel) {
  8   case(sel) {
  9      0  : printf("Nothing is selected\n");
 10      1  : {
 11             printf("something is selected\n");
 12             printf("This is multi statment example\n");
 13           }
 14      default : { 
 15             printf("Default is selected\n");
 16                }
 17   } // case (sel)
 18 }
You could download file case_statement.vr here
   

space.gif

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

space.gif

 Nothing is selected
 something is selected
 This is multi statment example
 Default is selected
   

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