Othertypesofconstraints //Setmembershipconstraints randintegerx,y,z;
constraintc1{xinside{3,5,[9:15],[y:2*y],z};}
integerfives[0:3]={5,10,15,20};
randintegerv;
constraintc2{vinsidefives;}
//Distributionconstraints randintegerw; //makew1001/8oftime,2002/8,3005/8 constraintc3{wdist{100:=1,200:=2,300:=5};} //Implicationconstraints bit[3:0]a,b; //forcebto1whenais0 constraintc4{(a==0)->(b==1);}
Many,manymorefeatures Variablesthatstepthroughrandompermutations(randc)
If-then-elseconstraints
Algorithmicconstraintsoverarrayentries(foreach)
Constraintsamongmultipleobjects
Variableorderingconstraints(solve..before)
Staticconstraintscontrolledbyoneconstraint
mode()call
Functionsinconstraints
Guardedconstraints
pre-andpost-randomizefunctions
Randomvariabledisabling
Explicitrandomizationofarbitraryvariables
Randomsequencegenerationfromagrammar
CoverageChecks Oncewehavegeneratedourtests,howgoodarethey?
Currentbestpractice:monitoringandimprovingcoverage
Coverage:howmanycases,statements,values,or
combinationshavethetestcasesexercised?
Covergroup Denessomethingwhosecoverageistobechecked.
Createsbinsandtrackswhethervalueseverappeared.
//color:athree-valuedvariablewhosecoverageistobechecked enum{red,green,blue}
color
;
covergroup
g1@(posedgeclk);
//Sampleatposedgeclk
c:
coverpoint
color;
endgroup
g1g1_inst=new;
//Createthecoverageobject
Attheendofsimulation,reportswhethercolortookall
threeofitsvalues.
CrossCoverage Maywanttomonitorcombinationsofvariables. enum{red,green,blue}color;
bit[3:0]pixel_adr,pixel_offset;
covergroupg2@(posedgeclk);
Hue:coverpointpixel_hue;
Offset:coverpointpixel_offset;
//Consider(color,pixel
adr)pairs,e.g.,
//(red,3'b000),(red,3'b001),...,(blue,3'b111)
AxC:
cross
color,pixel_adr;
//Consider(color,pixel
hue,pixel
offset)triplets
//Creates3*16*16=768bins
all:
cross
color,Hue,Offset;
endgroup
g2g2_inst=new;
//Createawatcher
Covergroupinclasses Individualcoverageofeachobjectofaclass. classxyz;
bit[3:0]x;
inty;
bitz;
covergroupcov1@z;
//Ateverychangeofz,
coverpointx;
//samplex
coverpointy;
//andsampley.
endgroup
functionnew();
cov1=new;
//Createawatcher;variablecov1implicit
endfunction
endclass
Predicatedcoverage Maywanttoselectivelydisablecoverage: covergroupg4@(posedgeclk);
//checks0onlyifresetistrue coverpoints0iff(!reset);
endgroup
User-denedbins Mayonlywanttotrackcertainvaluesofavariable. bit[9:0]a;
//Takesvalues0±1023
covergroupcg@(posedgeclk);
coverpointa{
//placevalues0±63and65inbina binsa={[0:63],65}; //create65bins,onefor127,128,...,191 binsb[]={[127:150],[148:191]}; //createthreebins:200,201,and202 binsc[]={200,201,202}; //placevalues1000±1023inbind binsd={[1000:$]}; //placeallothervalues(e.g.,64,66,..,126,192,...)intheirownbin binsothers[]=default;
}
endgroup
CoveringTransitions Maywanttochecktransitions,notjustavariable'svalues. bit[3:0]a;
covergroupcg@(posedgeclk);
coverpointa{
//Placeanyofthesequences4!5!6,7!11,8!11,9!11,10!11,
//7!12,8!12,9!12,and10!12intobinsa.
binssa=(4=>5=>6),([7:9],10=>11,12); //Createseparatebinsfor4!5!6,7!10,8!10,and9!10 binssb[]=(4=>5=>6),([7:9]=>10); //Lookforthesequence3!3!3!3 binssc=3[*4]; //Lookforanyofthesequences5!5,5!5!5,or5!5!5!5 binssd=5[*2:4]; //Lookforanysequenceoftheform6!!6!!6
//whereªºrepresentsanysequencethatexcludes6
binsse=6[->3];
}
endgroup