Jump to content

Cross coverage of two covergroups

Recommended Posts

Hi Everyone,

I am using the UVM env, in that I have two agents lets say agent1 and agen2, I want to get the cross coverage of input stimulus generated by both agents.


What I did till now , I have a shared seq_item.svh for both agents , so I did placed the

static cnt = 0;
class seq_item extends uvm_sequence_item;
typedef {x,y,z} lmn_t;
typedef {m,n,o} pqr_t;

rand lmn_t lmn;
rand pqr_t pqr;

covergroup cg_for_agent1:
coverpoint a: lmn;
coverpoint b: pqr;
end covergroup

covergroup cg_for_agent2:
coverpoint a: lmn;
coverpoint b: pqr;
end covergroup

covergroup cg_for_cross_ab;
CROSS_cov: cg_for_agent1.a;cg_for_agent1.b;cg_for_agent2.a;cg_for_agent2.b
end covergroup

function post_randomise();
if (this.get_name == pkt_for_agent1)begin

if (this.get_name == pkt_for_agent2)begin

if (cnt %2 == 0)begin

Now what I achieved cg_for_agent1 & cg_for_agent2 has bins covered but cg_for_cross_ab received zero bin covered.

Strange how static covergroups lost their value.


Apart from this, the seq_item object is created in both the agents at same time and randomized at the same time.

Please help me where I lost.




P.S: I am also wondering for functional coverage best technique, as per Mentor's guidelines i am doing this to achieve input test stimulus coverage , that i have sent all the vectors, please help me with any example to get it done in some other good way


Thanks again :)

Link to comment
Share on other sites

I had no idea that it's possible to cross points from two different covergroups. I've looked in the LRM and it says that in a cross, coverpoints or variables are allowed. The simulator seems to be treating the value of the coverpoint from an outer covergroup as a variable. Seeing as how you probably have 2 instances of you sequence item with different names, they cannot at the same time sample both cg_for_agent1 and cg_for_agent2 (due to the if statement). You will effectively cross the one coverpoint that does get sampled with nothing from the other one. You are probably analyzing per_type coverage and wondering, but these crosses happen on a per instance basis, so don't get tricked into thinking that the cross actually happens.


If you want to do such a cross you have to do it somewhere outside the sequence item, where you can get both instances.

Link to comment
Share on other sites

  • 2 weeks later...

Hi Tudor,


Still stucking in the same .


Let me try to clear what I am doing so that you may help better.


I have Seq_item1 which is 8xn bits , which contains rand type def {LONG,SHORT,ZERO} packet. This packet is created and randomized in sequences, which parse it and depending on the fields of the seq_item1 generate seq_item2 which is 8 bit data sent to driver. So the enum data type visibility is for sequence only.


Now this seq_item1 is used in two agents , which creates the instance in their respective sequences and randomized from there.


As I want to see the cross of two agent what can only help is that : yes


Agent1 LONG Agent2 SHORT,

Agent 2 SHORT Agent1 ZERO


and so on.


So to get this I have placed the sampling event in post_randomized() function, and keep the covergroup as:

 covergroup input_coverage;
           BUS_PKT_SIZE:  coverpoint pkt_size_cov iff (this.get_name()== "TX_PACKET_BUS");
           CARD_PKT_SIZE:  coverpoint pkt_size_cov iff(this.get_name()== "CARD_PACKET");

    function void post_randomize();

But this cross also dissappoint me as well.


Please help me what wrong has happend




Link to comment
Share on other sites

First of all what I do is only cover transactions that I have monitored and not transactions that I have randomized. The reason is that you may create an item, randomize it, but just not send it as traffic. You could connect the monitors of both your agents to a coverage collector object and do the cross there. This way you have all info available in one place.


As Dave already mentioned on Verification Academy what you have to be careful with is what you cross. Is there any special relationship between the traffic coming from agent1 and agent2 (say, agent1 and agent2 both send transactions that are processed at the same time)? In this case it makes sense to do a cross because you know when to do the sampling, when both transactions come in. If you don't have any such relationship, then you don't really need a cross and it probably makes more sense to just have a separate covergroup per agent.

Link to comment
Share on other sites

Well Thanks for the reply, I really appreciate the efforts.


Regarding the issue that only monitor those transactions which has ran, but the transactions I am talking about, randomized in the context to be used as configuring the sequence in particular as instruction to sequence.


About the Cross coverage sampling time for two agents: So what does INPUT STIMULUS COVERAGE means, if someone is not able to cross cover the coverage from two agent in case both generated at different times , but run in the single go transaction cycle. 


I really think the term INPUT STIMULUS COVERAGE is not usable as per the maturity of SV.


Please correct me if I am expecting anything strange.




Link to comment
Share on other sites

  • 1 year later...



I am trying to code a covergroup which looks at bins having a range between base addr and final addr.

I have a function which calculates the range of address which i want to use in my covergroup.

Basically i want to do this

memory_range : coverpoint range {bins addr[] = {[base_addr, final_addr]};}

which will be dependant on the size of the memory for which i have defined a function. The size and base_addr are read from registers inside the function.

function void calc();

bit [3:0] size;

register read to get size;
register read to get base_addr;
4’b0000: begin
Max_addr = ‘h10000;
Final_addr= base_addr+max_addr;

4’b0001: …….


Presently when i execute this, i see only one bin getting created. The range is not taking effect.

Can anyone please suggest on how I can access the base addr and final addr from the function in my covergroup?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...