|
|
|

|
|
|
|
|
|

|
|
 |
Default Argument
|
|
|
To handle common cases or allow for unused arguments, Vera allows you to define default values for each scalar argument. |
|
|

|
|
|
When the subroutine is called, you can omit an argument that has a default defined for it. Use an asterisk (*) as a placeholder in the subroutine call. If an asterisk is used for a variable that does not have a default value, a compilation error occurs. |
|
|

|
|
|
|
|
|

|
|
 |
Example : Default Argument
|
|
|

|
|
|
1 program default_value {
2 bit [7:0] no = 100;
3 print(*,no,*);
4 print(21,no,10);
5 }
6
7 task print (integer m = 0, var bit [7:0] port_no,
8 integer flow_no = 0) {
9
10 printf("Inside m %0d\n",m);
11 printf("Inside Port Number %0d\n",port_no);
12 printf("Inside Flow Number %0d\n",flow_no);
13 }
You could download file default_value.vr here
|
|
|

|
|
 |
Simulation : Default Argument
|
|
|

|
|
|
Inside m 0
Inside Port Number 100
Inside Flow Number 0
Inside m 21
Inside Port Number 100
Inside Flow Number 10
|
|
|

|
|
|

|
|
|

|
|
|
|
|
|

|
|
|
|
|
|

|
|
Copyright © 1998-2025 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|