Hi All ,
I saw a thread recently on the forum which invoked an interest in usage of cover_point_identifier aka coverpoint label
If I were to write following code :
// CODE1
bit [7:0] a ;
covergroup cg_exp ;
a_cp : coverpoint a // cover_point_identifier / coverpoint label is ' a_cp '
{
bins mod3[] = a_cp with ( a_cp % 3 == 0 ) ; // ' label ' used instead of ' item ' within with_clause
}
endgroup
LRM Syntax 19-2 says :
[ cover_point_identifier : ] coverpoint expression [ iff ( expression ) ]
{
[ wildcard ] bins_keyword bin_identifier [ [ [ covergroup_expression ] ] ] = cover_point_identifier with ( with_covergroup_expression ) [ iff ( expression ) ]
}
Hence I observe a compilation error for the CODE1 as cover_point_identifier is illegal within with_clause
The legal way to write it would be ::
a_cp : coverpoint a // cover_point_identifier / coverpoint label is ' a_cp '
{
bins mod3[] = a_cp with ( item % 3 == 0 ) ;
}
endgroup
LRM Syntax 19-4 says :
[ cross_identifier : ] cross cross_item , cross_item { , cross_item } [ iff ( expression ) ] cross_body
{
bins_keyword bin_identifier = cross_identifier with ( with_covergroup_expression )
}
where cross_item ::= cover_point_identifier | variable_identifier
with_covergroup_expression ::= covergroup_expression
Note that cover_point_identifier as part of with_covergroup_expression isn't shown as a possibility ( but it does work as per the link )
[Q1] Why is it considered legal ? Am I missing on something ?
LRM further says :
A coverpoint name has limited visibility. An identifier can only refer to a coverpoint in the following contexts:
— In the coverpoint list of a cross declaration (see 19.6),
— In a hierarchical name where the prefix specifies the name of a covergroup variable. For example,
cov1.cp.option.weight where cov1 is the name of a covergroup variable and cp is the name of a coverpoint declared within the covergroup.
— Following :: , where the left operand of the scope resolution operator refers to a covergroup.
For example, covtype :: cp :: type_option.weight.
Another legal syntax is to write the following within cross_body :: .. = binsof( cover_point_identifier [ .bin_identifier ] ) [ intersect { covergroup_range_list } ]
[Q2] From a strict coverpoint_body and cross_body perspective , what are the other legal places to write cover_point_identifier ?