Hi,
I am trying to write a get_set function which will return the value of the variable or set the variable to a value.
For example :
class test;
int var1;
bit [3:0]var2;
function int get_var1();
return var1;
endfunction
function bit get_var2();
return var2;
endfunction
function void set_var1(int var1_value);
var1 = var1_value;
endfunction
function void set_var2(bit [3:0] var2_value);
var2 = var2_value;
endfunction
endclass
and so on
I want to generalize the get and set functions as the number of functions keep increasing , the number of get and set functions would keep increasing.
But the problem in that case would be the return type and type of the arguments being passed to the function, as the return type and type of arguments would vary with the variables.
Can anyone suggest a workaround for this, how get and set can be achieved in a generic way for different variables of a class?
Thanks in advance!