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 Pass By Reference

In pass by reference, functions and tasks directly access the specified variables passed as arguments. In pass by reference, a subroutine operates on all arguments passed to it, but only changes made to arguments declared as var are seen outside the subroutine. Variables of any valid data type can be passed by reference.

   

space.gif

   

space.gif

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

space.gif


  1 program pass_by_ref {
  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 // var is added infront of each argument to make it
  9 // pass by reference
 10 task print (var bit [7:0] port_no, var integer flow_no) {
 11   printf("Inside Port Number %0d\n",port_no);
 12   printf("Insize  Number %0d\n",flow_no);
 13   flow_no ++;
 14   port_no ++;
 15   printf("New Flow Number %0d\n",flow_no);
 16   printf("New Port Number %0d\n",port_no);
 17 }
You could download file pass_by_ref.vr here
   

space.gif

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

space.gif

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

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