在System Verilog中将类句柄声明为rand类型

问题描述 投票:-1回答:1

Please See this for better clarification of of my code 当我们将类句柄声明为rand类型时会发生什么?会影响随机化吗?我正在尝试使用约束防护进行排序。

class Sorting;
    rand int unsigned n;
    rand Sorting next;
    constraint C0 { n inside {[2:20]};}

    constraint sort {if( next != null ) n < next.n;}

endclass

module random;
  Sorting s;
  initial
    begin
      s=new;
      repeat(10)
        begin
          assert(s.randomize());
          $write("%0d\t",s.n);
        end
    end
endmodule

我正在像这样在VCS中得到警告->警告-[CNST-PPRW]约束随机化NULL对象警告

相同的代码在约束保护部分的LRM中。我很好奇我们是否可以使用约束保护技术对随机数据进行排序?我已经使用约束内的foreach循环对随机数据进行了排序。我只是尝试这种方式。帮帮我。谢谢!

class sorting random constraints system-verilog
1个回答
0
投票

您是正确的。根据LRM,这不应产生任何警告。

VCS会产生警告,不应发出警告。至少这不是一个错误,您可以放心地忽略它。如果您愿意,可能有一种关闭警告的方法。检查命令行开关。

顺便说一句,NC不发出任何警告。

© www.soinside.com 2019 - 2024. All rights reserved.