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 Subroutine Arguments

In VERA, values can be passed to a task or function in following ways.

   

space.gif

  • Pass By Position
  • Pass By Reference
   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Pass By Value

Pass by value is the default method through which arguments are passed into functions and tasks. Each subroutine retains a local copy of the argument. If the arguments are changed within the subroutine declaration, the changes do not affect the caller.

   

space.gif

  ../images/main/4blue_dots_bullets.gif Example : Pass By Value
   

space.gif


  1 program pass_by_value {
  2   integer flow = 10;
  3   bit [7:0]  no = 100;
  4   print(no, flow);
  5   printf("After - Port Number %0d\n",no);
  6   printf("After - Flow Number %0d\n",flow);
  7 }
  8 
  9 task print (bit [7:0] port_no, integer flow_no) {
 10   printf("Inside Port Number %0d\n",port_no);
 11   printf("Insize  Number %0d\n",flow_no);
 12   flow_no ++;
 13   port_no ++;
 14   printf("New Flow Number %0d\n",flow_no);
 15   printf("New Port Number %0d\n",port_no);
 16 }
You could download file pass_by_value.vr here
   

space.gif

  ../images/main/4blue_dots_bullets.gif Simulation : Pass By Value
   

space.gif

 Inside Port Number 100
 Insize  Number 10
 New Flow Number 11
 New Port Number 101
 After - Port Number 100
 After - Flow Number 10
   

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