Functional Coverage: Sampling RTL signals in a hierarchy (gives error)

Hello,

I am creating a functional coverage model. I am binding my coverage model with the design using the “bind” statement.
I need to access some internal signals of a design instance inside the top level design module for using in my functional coverage model. However I get an error. Below is what I am trying =>

In the RTL design module “dut_berc”, there is a instance “dut_berc_cmd”. I need to access the signal “pct_err_status_vec” in this “dut_berc_cmd” module.

So in design =>

module dut_berc #(....)
  (clk, reset, ....
);

   dut_berc_cmd #(...) u_dut_berc_cmd (..);
module dut_berc_cmd #(....)
(.....
);

  logic [PCT_DEPTH-1:0] pct_err_status_vec;    <----- This is the signal I need to sample inside my functional coverage model

In the top level TB file, the bind happens =>

bind dut_berc
     dut_cov_berc #()
   FUNC_COVERAGE          (.*);

In “dut_cov_berc” =>

module dut_cov_berc #(...)
(
input [PCT_DEPTH-1:0] u_dut_berc_cmd.pct_err_status_vec,
........
)

However I get the following error when I try this =>

** Error: /view/…/src/dut_cov_berc.sv(36): near “.”: syntax error, unexpected ‘.’, expecting ‘)’

I tried directly accessing the signal in my functional coverage module but it gave an error that it is unable to find this signal.
Please let me known what is the correct way to access design signals present in a hierarcy in the functional coverage model?

Thanks.

When you use the bind construct, the syntax of bind instance should look exactly like it would if you had written it inside the target module. And the syntax of the module being bound uses normal Verilog syntax rules as well; you cannot have a port defined as a hierarchical reference. So change it to

module dut_cov_berc #(...)
(
input [PCT_DEPTH-1:0] pct_err_status_vec,
........
)

Then change your bind statement to

bind dut_berc
     dut_cov_berc #()
   FUNC_COVERAGE          (.pct_err_status_vec(u_dut_berc_cmd.pct_err_status_vec),.*);

I suspect you may be trying to access signals from many different levels of your DUT hierarchy. so instead of having a single dut_cov_berc module, you should break it up into several modules with separate bind statements that bind deeper into the hierarchy of your DUT. For example, you could change the bind statement above to

bind u_dut_berc.u_dut_berc_cmd
     dut_cov_berc #()
   FUNC_COVERAGE          (.*);

In reply to dave_59:

Thanks Dave. This worked well for me :-)
I am creating separate functional coverage modules for the different modules in the DUT as you suggested.
However this signal was in a sub-module which was inside the sub-module I was binding to.