|
|
|
|
|
|
|
|
|
|
|
|
Subroutine Arguments
|
|
|
In VERA, values can be passed to a task or function in following ways. |
|
|
|
|
|
- Pass By Position
- Pass By Reference
|
|
|
|
|
|
|
|
|
|
|
|
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. |
|
|
|
|
|
Example : Pass By Value
|
|
|
|
|
|
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
|
|
|
|
|
|
Simulation : Pass By Value
|
|
|
|
|
|
Inside Port Number 100
Insize Number 10
New Flow Number 11
New Port Number 101
After - Port Number 100
After - Flow Number 10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|