Sparsh Gupta
Sparsh Gupta

Reputation: 51

Creating transition coverage bins using a queue or dynamically

I want to write a transition coverage on an enumeration. One of the parts of that transition is a queue of the enum. I construct this queue in my constructor. Considering the example below, how would one go about it.

In my coverage bin I can create a range like this A => [queue1Enum[0]:queue1Enum[$]] => [queue2Enum[0]:queue2Enum[$]]. But I only get first and last element then.

typedef enum { red, d_green, d_blue, e_yellow, e_white, e_black } Colors;
 Colors dColors[$];
 Colors eColors[$];
 Lcolors = Colors.first();
 do begin
  if (Lcolors[0].name=='d') begin
   dColors.push_back(Lcolors);
  end
  if (Lcolors[0].name=='e') begin
   eColors.push_back(Lcolors);
  end
 end while(Lcolors != Lcolors.first())

 covergroup cgTest with function sample(Colors c);
   cpTran : coverpoint c{
      bins t[] = (red => dColors =>eColors);   
   }
 endgroup

bins t[] should come out like this(red=>d_blue,d_green=>e_yellow,e_white)

Upvotes: 0

Views: 693

Answers (1)

Tudor Timi
Tudor Timi

Reputation: 7573

The following worked for me:

bins t[] = (
    red =>
    [dColors[0] : dColors[$]] =>
    [eColors[0] : eColors[$]]);

I got the bins you were expecting:

t[red=>d_green=>e_yellow]
t[red=>d_green=>e_white]
t[red=>d_green=>e_black]
t[red=>d_blue=>e_yellow]
t[red=>d_blue=>e_white]
t[red=>d_blue=>e_black]

I see that you tried this as well, but didn't get what you were expecting. Maybe this is because your tool doesn't support this properly.

One more thing you should check is that you created the dColors and eColors queues properly. The sample code you showed in your question isn't correct and won't put the proper elements in the queues.

Upvotes: 0

Related Questions