In reply to dave_59:
ooh ok i was trying to explore as i was learning SV
the coverage i was tryn to do was :
class packet;
event cov_ev;
rand bit [31:0] addr;
rand int data [];
rand enum {idle,busy,write,read,resp} mode;
rand bit [3:0] xfer_id;
//-----------------------------------------------
constraint c1 {unique{addr};addr[3:0] == 0;unique{xfer_id};};
//-----------------------------------------------
constraint c2 {!(addr inside {[32'hf000:32'h1_0000]}); addr dist {['h0000:'h8000]:/ 2,['h1000_00:'hffff_fff0] :/ 2};}//constraints doubt i wanted to get it cleared
//-----------------------------------------------
constraint c3 {unique{mode};soft (mode == busy || mode == read) -> (data.size() == 0);soft data.size() <= 300;}
//-----------------------------------------------
//constraint c4 {soft data.size() > 0;soft data.size() < 128;}
//-----------------------------------------------
constraint c5 {foreach(data[i]) data[i] inside {'h00,'hAA,'hBB,'hCC,'hDD,'h44,'d88,'hFF,'h11,'h22};}
//-----------------------------------------------
function void display();
$display("The properties values are addr %0h data %0p enum %0s xfer_id %0d", addr, data, mode,xfer_id);
endfunction
//-----------------------------------------------
function void event_gen();
->cov_ev;
$display("the event cov_ev has been generated");
endfunction
//-----------------------------------------------
covergroup fun_cvrg@(cov_ev);
option.per_instance = 1;
c1 : coverpoint addr {
bins min = {['h0000_0000 :'h0000_EFFFF] };
bins mid = {['h1_0004 :'h1000_FFFF] };
bins max = {['hF000_0000 :'hFFFF_FFF0] };
bins def = default;
}
c2 : coverpoint xfer_id{bins id = {[0:7]};
bins def = default;}
c3 : coverpoint mode{ignore_bins b1 = {idle};
bins def = default;}
c4 : coverpoint data;//shows error for this coverage
c1Xc2 : cross c1,c2{bins inte = binsof(c1.min) intersect{xfer_id};
bins be = binsof(c1.min)||binsof(c2);
bins ve = binsof(c1.min)&&binsof(c2);
}
c2Xc3 : cross c2,c3{bins inter = binsof(c2.id) intersect{mode};
bins be = binsof(c2.id)||binsof(c3);
bins ve = binsof(c2.id)&&binsof(c3);}
endgroup
//-----------------------------------------------
function new();
fun_cvrg = new;
data = new[10];
endfunction
//-----------------------------------------------
endclass
//-------------------------------------------------
module test;
int i, k;
initial begin
packet covg;
covg = new();
for(i = 0;i < 60;i = i + 1) begin
covg.event_gen();
k = covg.randomize();//randomising
covg.fun_cvrg.sample();
covg.display();
end
$display("coverage = %0.2f %%",covg.fun_cvrg.get_inst_coverage());
end
endmodule
and was stuck at 87% coverage without data, dave sir.