What is a coverage collector?

A coverage collector is a component responsible for gathering and aggregating functional coverage data from various parts of the testbench during the verification process. Its primary role is to collect coverage information from different coverage models and components, such as monitors, scoreboards, and custom coverage classes, and combine them to provide a comprehensive view of the design's verification progress.

Features of a coverage collector:

Coverage Aggregation: Gathers coverage data from different parts of the testbench, including coverage models and custom coverage points.
Coverage Metrics: Calculates and maintains various coverage metrics, such as statement coverage, branch coverage, toggle coverage, and functional coverage.
Data Collection: Accumulates data from different sources and organizes it into a unified coverage database.
Coverage Reporting: Generates coverage reports and summaries to track the verification progress and identify areas that require further testing.
Cross-coverage Analysis: Checks interactions between different coverage items and identifies coverage gaps.
Hierarchical Coverage: Supports hierarchical coverage collection for complex testbenches.
Configurability: Allows users to customize which coverage items are collected and the format of the reports.
Runtime Efficiency: Optimizes storage and processing of coverage data to avoid excessive impact on simulation performance.
Code
// Filename : basic_coverage.sv

class basic_coverage  extends uvm_component;
	`uvm_component_utils(basic_coverage)

	extern         function      new(string name, uvm_component parent);
	extern virtual function void build_phase(uvm_phase phase);
	extern virtual function void extract_phase(uvm_phase phase);

endclass: basic_coverage

//------------------------------------------------------------------//

function basic_coverage::new(string name, uvm_component parent);
	super.new(name, parent);

endfunction: new

//------------------------------------------------------------------//

function void basic_coverage::build_phase(uvm_phase phase);
	super.build_phase(phase);

endfunction: build_phase

//---------------------------------------------------------------------------------------------------

function void basic_coverage::extract_phase(uvm_phase phase);
	super.extract_phase(phase);

endfunction: extract_phase
Theory Questions
    No, it is not a mandatory requirement. Depending on the complexity of the monitoring logic and the DUT, one can implement the coverage collection part inside the monitor or scoreboard itself.
    Yes, in an agent which contains multiple monitors can choose to have a simple coverage collector for all instances of the monitor in the same agent.
    A coverage collector is typically connected via an analysis port, which allows it to receive transactions from the monitor and sample them for coverage data collection.
    A coverage collector often extends the uvm_subscriber class, using its analysis export to receive and process transactions from the monitor, which are then sampled for coverage.