Regarding ' with ' clause for Transition bins

According to LRM Syntax 19-3 : with_clause is Illegal for transition bins .

Is there a logical reason why it’s considered illegal ?

One reason I could think of is generally we mention ’ item ’ within the with_clause ,
so using simply ’ item ’ one couldn’t differentiate between LHS and RHS of the transition .


 coverpoint b 
 {
    bins  trans[]  =  ( [0:6]  =>  [10:15]  ) with ( item ... ) ;  // item  wouldn't  help  to  differentiate  between  LHS  [0:6]  and  RHS [10:15]
 }

Using wildcard bins for transitions is helpful in certain cases but provides limited control .

It still lacks the finer control that integral expression within with_clause provides .

Is there a possibility it could be added in the Open Item list for future versions of System Verilog ?

In reply to MICRO_91:

The bin syntax can only go so far before it becomes too complicated to manage. Transitions can be more than just pairs of values, You are better of writing functions to look for the transitions you need to cover.

In reply to dave_59:

The bin syntax can only go so far before it becomes too complicated to manage.

I understand .

You are better of writing functions to look for the transitions you need to cover.

Could you provide a small example if possible .
Maybe as an alternate possible solution for following requirement.

I believe you mean to call a function as part of coverpoint expression .

Usage of set_covergroup_expression would have been great but Syntax 19-3 doesn’t allow it for transition bins unfortunately :(

In reply to MICRO_91:

I can give you some pseudo code. Instead of using transition bins, you can concatenate the previous value with the current value

typedef struct packed { bit [6:0] pValue, cValue} transition_t;

function bit select_transition(transition_t t);
  // code that returns true for transitions you want covered
endfunction

cp: coverpoint transition_t'{PrevValue, CurrentValue} {
  bins tr = cp with select_transition(item);
}

In reply to dave_59:

Thanks Dave .


So  the  limitations  of  transitions bins can be overcome by  treating  the  coverpoint  expression  as  concatenation  of  present_state and  next_state . 

This approach allows usage of with clause , set_covergroup_expression

One last question regarding the function call


 typedef  enum  int  { STATE0 , ... ,  STATE10 }  fsm_state ; 

 fsm_state  ps_state , ns_state ;

 typedef struct packed { fsm_state  pValue, cValue} transition_t;
   
 transition_t  array_q[$] ;  
   
 function bit select_transition( transition_t t); 
  //  Accessing  array_q  here  
 endfunction

 covergroup  gc ;

  cp: coverpoint ( { ps_state , ns_state} )
  {
   bins tr = cp with select_transition(item);
  }
 endgroup

 gc  gc1 ;

 initial  begin
  
  //  Procedural  Logic  to  Populate  Array  array_q  here  before  constructing  the  covergroup 
  
   gc1 = new() ;

 end

From a strict LRM’s perspective the above access is Illegal


 LRM  19.5  ::  "Functions shall not reference non-constant variables outside the local scope of the function"

A valid solution would be to move the array populating logic within the function ,
however there are effects on simulation time as the same array gets assigned the same values for each possible value of the coverpoint expression .

How could I make the array as a constant variable ( so it’s legal to access within function ) such that it gets assigned only once before constructing the covergroup ?