in my verification environment I have 3 different registers with the same fields: load_0
, load_1
and load_2
.
Now I have the same function duplicated 3 times for every register and differs only in one line:
duplicated_func_0() {
value = timer_regs.load_0; //This is the only different line (in duplicated_func_1 - load_1 is substituted
...
};
Is there a better way to access variable name (that differs only by its index) than duplicate the same function 3 times? Something like this:
not_duplicated_func(index : uint) {
value = timer_regs.load_%x; //Is there a way to put the input index in the variable name instead of %x?
};
I will appreciate any help you can provide.