diff --git a/src/verilog.y b/src/verilog.y index 6d6efea6b..5af60e591 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -7341,6 +7341,21 @@ cross_itemList: // IEEE: part of list_of_cross_items cross_item: // ==IEEE: cross_item id/*cover_point_identifier*/ { $$ = new AstCoverpointRef{$1, *$1}; } + // // Verilator extension beyond strict IEEE (cross_item is a simple + // // identifier): some tools accept a hierarchical/dotted reference + // // here. A dotted reference can never name a coverpoint (coverpoint + // // identifiers are flat, local names), so it is necessarily a plain + // // data reference, i.e. an implicit coverpoint over a variable. + // // Verilator does not support implicit coverpoints, so V3Covergroup + // // drops the whole cross with a COVERIGN warning; accept it here so + // // the file parses instead of erroring on the '.'. + | id/*variable*/ crossItemHier + { $$ = new AstCoverpointRef{$1, *$1 + *$2}; } + ; + +crossItemHier: // Verilator extension: dotted suffix of a hierarchical cross_item + '.' idAny { $$ = PARSEP->newString("." + *$2); } + | crossItemHier '.' idAny { $$ = PARSEP->newString(*$1 + "." + *$3); } ; cross_body: // ==IEEE: cross_body diff --git a/test_regress/t/t_covergroup_cross_opt_unsup.out b/test_regress/t/t_covergroup_cross_opt_unsup.out index d07db1513..7297641fd 100644 --- a/test_regress/t/t_covergroup_cross_opt_unsup.out +++ b/test_regress/t/t_covergroup_cross_opt_unsup.out @@ -7,4 +7,8 @@ : ... note: In instance 't' 15 | cross_implicit: cross cp_a, var_x; | ^~~~~ +%Warning-COVERIGN: t/t_covergroup_cross_opt_unsup.v:18:29: Unsupported: cross of 's_cfg.m_p' which is not a coverpoint (implicit coverpoint) + : ... note: In instance 't' + 18 | cross_hier: cross cp_a, s_cfg.m_p; + | ^~~~~ %Error: Exiting due to diff --git a/test_regress/t/t_covergroup_cross_opt_unsup.v b/test_regress/t/t_covergroup_cross_opt_unsup.v index bb63a86be..6cf9452cf 100644 --- a/test_regress/t/t_covergroup_cross_opt_unsup.v +++ b/test_regress/t/t_covergroup_cross_opt_unsup.v @@ -13,7 +13,12 @@ module t; option.per_instance = 1; // unsupported for cross; triggers COVERIGN } cross_implicit: cross cp_a, var_x; + // Hierarchical/dotted cross item: can only be a data reference (implicit + // coverpoint), never a coverpoint; treated as unsupported (COVERIGN) + cross_hier: cross cp_a, s_cfg.m_p; endgroup + typedef struct packed {logic m_p; logic h_mode;} cfg_t; + cfg_t s_cfg = '0; logic var_x = 1'b0; cg cg_i = new; initial begin