I am trying to learn System Verilog classes. I created a parameterized class, where one of the parameters is affecting the data type of one of the fields.
class Node #(parameter type T = int, parameter BASIC_TYPE = 1);
T data;
I wanted to create a copy function inside this Node class, so that data is copied. Data could be any type, so it could be a bit for example or an object of class. If data was an object, it should have copy implemented on it, so doing something like data.copy()
should be expected to work;
however I am thinking about scenario where a bit is used, that would result in an error. I thought of adding a parameter to the class BASIC_TYPE
, which would be used like this:
void function copy(node target);
if(BASIC_TYPE==0)
data.copy(target.data);
else
target.data = node.data;
endfunction
I wonder if there is some built-in function that could be used to check if the variable is object or have copy implemented on it, instead of relying on the passed parameter.