Transition coverpoint sampling issue!

Hello all,
I have an issue with transition coverpoint, it is not getting sampled, whenever the “.sample” method is called. But it is getting sampled when there is a sampling event with covergroup!!

  1. With sample method(not working)

module test();

logic [7:0] addr;
reg ce;

covergroup address_cov (); // @ (posedge ce);
  ADDRESS : coverpoint addr {
    // simple transition bin
    bins adr_0_to_1          = (0=>1);
    bins adr_1_to_0          = (1=>0);
    bins adr_1_to_2          = (1=>2);
    bins adr_2_to_1          = (1=>0);
    bins adr_0_1_2_3         = (0=>1=>2=>3);
    bins adr_1_4_7           = (1=>4=>7);
  }
endgroup

address_cov my_cov = new();

initial begin
  ce   <= 0;
  addr <= 0;
  $monitor("ce %b addr 8'h%x",ce,addr);
  repeat (10) begin
    ce <= 1;
    my_cov.sample(); // Calling the sample method
    #10;
    ce <= 0;
    addr ++;
    #10;
  end
end

endmodule

  1. Working code

module test();

logic [7:0] addr;
reg ce;

covergroup address_cov () @ (posedge ce);
  ADDRESS : coverpoint addr {
    // simple transition bin
    bins adr_0_to_1          = (0=>1);
    bins adr_1_to_0          = (1=>0);
    bins adr_1_to_2          = (1=>2);
    bins adr_2_to_1          = (1=>0);
    bins adr_0_1_2_3         = (0=>1=>2=>3);
    bins adr_1_4_7           = (1=>4=>7);
  }
endgroup

address_cov my_cov = new();

initial begin
  ce   <= 0;
  addr <= 0;
  $monitor("ce %b addr 8'h%x",ce,addr);
  repeat (10) begin
    ce <= 1;
    #10;
    ce <= 0;
    addr ++;
    #10;
  end
end

endmodule

why it is not working with “<covergroup_ins>.sample” method? why it is working for the sampling event (i.e:- “posedge ce”)?

In reply to Malai_21:
You need to be more explicit about what it means to be working versus not working.

The two examples of code are not the same because 1) never samples the value addr == 0. It is still 8’bx on the first sample, and on the next sample it is addr == 2.

  1. only gets 50% coverage.

In reply to dave_59:

Hi Dave
For 1) I’m getting 0% coverage(not working)
2) As you said, I’m getting 50%(working)

but why 1) will not sample addr == 0, I’m assigning addr = 0 at beginning of the initial block!!

In reply to Malai_21:

On 4 different simulators on www.EDAPlayground.com I get 16.6666 (1 of 6) when adding

  $display($get_coverage());

to the end of the initial block. Only the 1=>2 transitions should get hit. Your example shows non-blocking assignment addr <=0 at time 0, not a blocking assignment.

In reply to dave_59:

Thanks, Dave. I didn’t notice the non-blocking assignment.