How to pass transaction from monitor to coverage?

I have a coverage instantiated in my monitor. I tried to pass a transaction from the monitor to the coverage but I’m having this error:

assignment operator type check failed (expecting datatype compatible with ‘class uvm_pkg::uvm_analysis_export#(.T(class sent_agent_pkg::packet))’ but found ‘class uvm_pkg::uvm_analysis_imp#(.T(class sent_agent_pkg::packet),.IMP(class uvm_pkg::uvm_subscriber#(.T(class sent_agent_pkg::packet))))’ instead).

This is what I did in the monitor:


// I instantiate an item
packet tr;

// I declare a uvm_analysis_export and the coverage
uvm_analysis_export #(packet) to_cvg_export;  // Use to send transactions to the sent_spi_coverage
sent_spi_coverage sent_spi_cvg;               // Coverage for SENT and SPI

// In build_phase I create the coverage and then connect the to_cvg_export with the analysis_export of the coverage
sent_spi_cvg = sent_spi_coverage::type_id::create("sent_spi_cvg", this);
to_cvg_export = sent_spi_cvg.analysis_export;
tr = packet::type_id::create("tr", this);

// I pass the transaction
to_cvg_export.write(tr);

Note that the only instantiation of the coverage I have is in the monitor. I did not instantiate it in the agent or environment.

In reply to Reuben:

Oh wait. I think I should use an analysis_port and not an analysis_export.

I think this is now okay. I moved the coverage to the agent and then I use analysis_port from the monitor to pass the transactions to the analysis_import of the coverage.