System verilog SystemVerilog传递函数作为参数

System verilog SystemVerilog传递函数作为参数,system-verilog,System Verilog,是否可以在SystemVerilog中将函数作为参数传递 虽然这段代码不起作用,但希望它能够演示。有什么帮助吗?谢谢 module funcparam; int result; function int xxx(int x, ref fun); return fun(x); endfunction function int yyy(int y);

是否可以在SystemVerilog中将函数作为参数传递

虽然这段代码不起作用,但希望它能够演示。有什么帮助吗?谢谢

    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
没有


任务和函数只能接受数据类型作为参数,而函数不是数据类型。此外,也无法将函数转换为数据类型。

对于通过引用传递的内容,您受到限制:

  • 一个变量
  • 类属性
  • 未包装结构的构件,或
  • 未打包数组的元素
您可能能够传入基类的句柄,尽管我怀疑这是否有效

class base;
  function yyy(int x);
  endfunction
endclass

class class1 extends base;
  function yyy(int x);
  endfunction
endclass

class class2 extends base;
  function yyy(int x);
  endfunction
endclass


module funcparam;
   result;

   function int xxx(int x,input base fun);
     return fun.yyy(x);
   endfunction

   class1 cls = new;
   //class2 cls = new;


    initial begin
       result = xxx(5, cls);
      $display("result: %d", result);
    end
endmodule

似乎真的没有人支持这种语言。