Question: How do I connect the signal with “ref” keyword (in my case [63:0] flag) in the class before invoking the constructor?
Sample code for checking coverage of individual bits of 64-bit bus “flag” being set to 1:
covergroup flag_cvg (input bit [63:0] one_hot_bit_position, ref logic [63:0] flag);
flag_cvp: coverpoint (one_hot_bit_position & flag) != 0;
option.per_instance = 1;
endgroup : flag_cvg
class flag_cov;
g3_vif if_g3;
logic [63:0] flag;
flag_cvg flag_bits[64];
bit cov_en = 1;
string msg_label = "flag_cov";
function new( string name = "flag_cov", uvm_component parent = null );
super.new( name, parent );
**flag = if_g3.flag; // Is this allowed? I want to connect the signal from interface before invoking the constructor with new() keyword.**
foreach(flag_bits[i])
flag_bits[i] = new(1'b1<<i, flag);
endfunction : new
task main_phase(uvm_phase phase);
forever begin
if(cov_en) begin
`uvm_info(msg_label,"NOW SAMPLING COVERAGE", UVM_DEBUG)
sample_flag_cvg();
end
end
endtask : main_phase
task sample_flag_cvg();
forever begin
@(negedge if_g3.clkb);
foreach(flag_bits[i])
flag_bits[i].sample();
end
endtask : sample_flag_cvg
endclass : flag_cov
The interface looks like this:
interface if_g3;
logic [63:0] flag = `FLAG_within.dout_sampled[63:0]; // DUT circuit signal connected to a logic type in interface for accessing inside the class
endinterface // if_g3