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 ?
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.
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 ?