In reply to ben@SystemVerilog.us:
Errata and clarification
A colleague pointed out ot me why the use of sequence_name.triggered is
incorrect in triggering a covergroup.
covergroup BAD_frame @(Detect_EOP.triggered); // BAD USE for the trigger
coverpoint framelength; // Generated 16 Auto bins !!
endgroup
covergroup GOOD_frame @(Detect_EOP); // GOOD use of sequence_name for the trigger
coverpoint framelength; // Generated 16 Auto bins !!
endgroup
- @(sequence.triggered) is not correct even though the compiler might accept it. It is a boolean briefly tru in the observed region. That is, it should trigger twice in the observed region, one on posedge and the other on negedge.
The method seq.triggered is a Boolean, used either in the body of a sequence or w.g., wait statement. see e.g. 15.5.5.2 for an event E1.
As Boolean it becomes true when the sequence matches and then becomes false at the end of the Observed region (or Reactive region, need to check 1800). In other words @(seq.triggered) should see two events due to the change from false to true and for true to false. Using it as an event is incorrect and @(seq) should be used, i.e. sensitive to the event of the match. - @(sequence) triggers by the event corresponding to the match of sequence.
function void trigger_cg (input int length);
framelength = length;
-> cg_trig; // Trigger Covergroup Sampling
endfunction
- The reason why triggering the covergroup by the sequence samples framelength of 0 is that the natch of the sequence occurs in the observed region which triggers the covergroup in the next round of active region execution or in the reactive region (not sure which but it does not matter. The task evaluation is scheduled in the reactive region - see clause 16.11.
This means that it executes after the covergroup does its sampling. Therefore, framelength is still 0.
If you use trigger an event in the function (or task) which then causes the cg to sample, it executes after framelength is assigned, hence cg sees the expected value.