How to enable code and functional coverage for selected modules

Hi

I want to enable code coverage for the dut top alone in my TB. I was able to achieve this by passing the below options in my script

-coverage -voptargs=“+cover=bcfst” -do "coverage save -du DUT_TOP -onexit gpex.ucdb;

I have functional coverage as a standalone uvm component which is included inside test_lib_pkg.sv. I dont know how to include this file for coverage. Can you please help me out on this ?

Thanks & Regards
B Saravana

Not sure what you mean by standalone uvm component Normally you write a coverage class that gets instantiated by your env and connected by analysis ports from your monitor. See our new Coverage Cookbook for more details.

Is “DUT_TOP” always the only portion of the design you care about code coverage on? Do you have other functional coverage components elsewhere in the design which you do not want to include in the UCDB file?

Depending on the answers to those questions, you could change your command in your script a bit, to read:

-coverage -voptargs=“+cover=bcfst+/path/to/DUT_TOP” -do “coverage save -onexit gpex.ucdb”

You will have to replace “/path/to/DUT_TOP” which the actual design path of course, but this will then save code coverage for only this DU, as well as any functional coverage in the design (which would include whatever you have in “test_lib_pkg.sv”.