Override parameters in SV package

In reply to dave_59:

Hi Dave, please find the problem (hopefully better explained)

I have a class cg_wrap which has parameters A1-A4 as defined below which are used in the covergroup cg_wrap_1. The task sample() for the covergroup cg_wrap_1 is called in the coverage_collector class.

My intention is to override the parameters A1 and A2 such that when the task sample() is called, the coverpoints should check the signal with parameter value A1=11, A2=12 and not A1=10 and A1=20.

package my_pkg;

import uvm_pkg::*;

`include "uvm_macros.svh"

class cg_wrap #(
  parameter A1 = 10,
  parameter A2 = 20,
   parameter A3 = 30,
   parameter A4 = 40
) extends uvm_sequence_item;

  `uvm_object_param_utils(cg_wrap))
 
  function new(string name="cg_wrap");
    super.new(name);       
      endfunction
 
  covergroup cg_wrap_1 with function sample();
    cp_xyz : coverpoint xyz {
            bins min = {0};
            bins min_p1 = {1};
            bins max_m1 = { A1 - 1};
            bins max = { A1 };
            }
         
    cp_abc : coverpoint abc {
            bins min = {0};
            bins min_p1 = {1};
            bins max_m1 = { A2 - 1};
            bins max = { A2 };
            }
     endgroup

      function new(string name="cg_wrap_1");
         super.new();
         cg_wrap_1 = new();          
         cg_wrap_1.set_inst_name($sformatf("%s", name)); 
      endfunction

      function void sample();
         cg_wrap_1.sample();
      endfunction

endclass


class coverage_collector extends uvm_subscriber#(uvm_sequence_item);

   `uvm_component_utils(coverage_collector)
  uvm_analysis_port #(uvm_sequence_item) to_receiver;
  cg_wrap pkt_cov;
 
   function new(string name, uvm_component parent);
      super.new(name,parent);
      to_receiver   = new ("to_receiver", this);  
      pkt_cov = cg_wrap::type_id::create("cg_wrap");
   endfunction : new
  
   task run_phase (uvm_phase phase);
      `uvm_info("UVC","run_phase: Executing.   coverage_collector run_phase<<<",UVM_LOW) 
    endtask : run_phase
  
  task sample_and_transmit();
         pkt_cov.sample();
         to_receiver.write(pkt_cov); 
      endtask

  function void write(uvm_sequence_item t);
   //placeholder 
  endfunction

endclass : coverage_collector

endpackage : my_pkg