随机化是 SystemVerilog 中的内置函数吗?

Is randomize an inbuilt function in SystemVerilog?

class sample;
  randc bit[2:0]count;
endclass

module top;
  sample sample_test;
  initial begin
    sample_inst=new();
    repeat(20) begin
      sample_inst.randomize();
      sample.print();// this is assumed to be written in class
    end
  end
endmodule 

我明白 randrandc 是什么,但我不明白我们如何在不在 SystemVerilog class 中编写函数的情况下使用 randomize()。我认为这是一个内置函数。我在网上看到很多代码在class.

中没有写randomize函数

是的,randomize 是一个内置函数,如 IEEE Std 1800-2017,第 18.6.1 节中所定义 Randomize():

Variables in an object are randomized using the randomize() class method. Every class has a built-in randomize() virtual method, declared as follows:

virtual function int randomize();

这意味着您在网上看到的所有代码示例都没有声明 randomize 函数。

IEEE Std 的免费副本可用。这应该是您获取所有信息的第一个来源。