Is it possible to pass a function as an argument in SystemVerilog?
This code hopefully demonstrates though it doesn’t work. Any help? Thanks.
module funcparam;
int result;
function int xxx(int x, ref fun);
return fun(x);
endfunction
function int yyy(int y);
return y * (y + y);
endfunction
initial begin
result = xxx(5, yyy);
$display("result: %d", result);
end
endmodule
You’re limited as to what can be passed by reference:
You might be able to pass in a handle of a base class, though I doubt this would work.