How to cover latency between request and response
<p>Let's say we have a protocol where request <code>req</code> is asserted with <code>req_id</code> and corresponding <code>rsp</code> will be asserted with <code>rsp_id</code>. These can be out of order. I want to cover the number of clks or latency between <code>req</code> with particular <code>req_id</code> and <code>rsp</code> with the same id. I tried something like this. Is this correct way of doing? Is there any other efficient way?</p>

<pre><code>covergroup cg with function sample(int a);
  coverpoint a {
  a1: bins short_latency = {[0:10]};
  a2: bins med_latency = {[11:100]};
  a3: bins long_latency = {[101:1000]};
  }
endgroup
// Somewhere in code
cg cg_inst = new();

sequence s;
  int lat;
  int id;
  @(posedge clk) disable iff (~rst)
    (req, id = req_id, lat = 0) |-&gt; ##[1:$] ((1'b1, lat++) and (rsp &amp;&amp; rsp_id == id, cg_inst.sample(lat)));
endsequence
</code></pre>