阅读背景:

SystemVerilog中类的内部类对象的随机化

来源:互联网 
class c2;
  rand bit[1:0] a;
  rand bit[1:0] b;

  function void my_print();
    $display("a = %b", a);
    $display("b = %b", b);
  endfunction   
endclass

class c1;
  rand bit[1:0] i;
  rand bit[1:0] j;
  rand c2 o2;

  function new();
    o2 = new();
  endfunction

  function void my_print();
    $display("i = %b", i);
    $display("j = %b", j);
  endfunction
endclass

program p1;   
  c1 o1 = new;
  c2 o2_local = new;

  initial begin
  if (o1.randomize() with {o2 == o2_local;}) begin
    o1.my_print();
    o2.my_print();
  end
endprogram
class c2;
  rand bit[1:0] a;
  rand bit[1:0] b;



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: