如何在某个序列出现时对covergroup进行采样?

How to sample covergroup at the occurence of a certain sequence?

module testbench;
  
  bit [2:0] A;
  bit [2:0] data[];
  int i;
  bit [2:0] b;
  
  covergroup cov_grp;
    c1 : coverpoint A {
      bins b1 = {0,1,2};
      bins b2 = {3,4,5};
      bins b3 = {6,7};}
  endgroup
  
  sequence seq;
    (b == 'd7);
  endsequence
  
  initial 
    begin
      cov_grp cov_ins = new();
      data = new[10];
      for(i=0;i<8;i++)
        begin
          
          data[i] = $random;
          A = data[i];
          assert property @(seq) cov_ins.sample();
        end
    end
  
endmodule

我想在序列 seq 发生时对覆盖组实例 cov_ins 进行采样。 当 b = 'd7 它应该采样 ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ..................................................... ...

正如您的 covergroup 需要一个事件来触发采样一样,sequence 需要一个事件来知道何时采样和计算表达式 b = 'd7(顺便说一句,您的测试台永远不会设置b).

而且从您的测试用例中还不清楚为什么您甚至需要使用一个简单的布尔表达式序列。你可以只写:

if (b == 'd7) cov_ins.sample();

但假设您的序列更复杂,那么您的序列中需要一个时钟,并且需要编写类似

的内容
sequence seq;
  @(posedge clk) (b == 'd7)[->1]; // when b transitions to 'b7
endsequence

covergroup cov_grp @seq; // instead of calling sample()
    c1 : coverpoint A {
      bins b1 = {0,1,2};
      bins b2 = {3,4,5};
      bins b3 = {6,7};}
  endgroup