High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2:...
Transcript of High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2:...
![Page 1: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/1.jpg)
www.verifsudha.com 1
High-levelspecificationmodelbasedFunctionalcoveragegeneration
(WithcasestudyofUSBPowerdeliveryprotocollayercoverage)
Author:AnandShirahatti([email protected])
Intentistheseedofmanifestation
![Page 2: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/2.jpg)
www.verifsudha.com 2
1 Introduction.................................................................................................................32 Howisthisapproachdifferent?.............................................................................4
3 Makingintentexecutable........................................................................................4
4 Benefits..........................................................................................................................55 Architecture..................................................................................................................65.1 Executablecoverageplan.............................................................................................75.2 High-levelspecificationmodeling.............................................................................75.3 Informationsource.........................................................................................................85.4 SystemVerilogCoverageAPIinPython....................................................................85.4.1 LimitationsofSystemVerilogCovergroup....................................................................85.4.2 CoverageAPILayering..........................................................................................................95.4.3 Implementation......................................................................................................................105.4.4 Structureofuserinterface.................................................................................................11
5.5 Sourceinformation.......................................................................................................126 Summary:...................................................................................................................137 USBPowerdeliveryprotocollayer–Casestudy...........................................147.1 Refresher..........................................................................................................................147.2 Protocollayerfunctionalcoveragechallenges...................................................167.3 Functionalcoverageitemsforcasestudy.............................................................167.4 USBpowerdeliveryspecificationinformationmodeling................................177.4.1 Messagemodeling.................................................................................................................187.4.2 Eventmodeling.......................................................................................................................197.4.3 Protocolsequencemodeling.............................................................................................20
7.5 Executablecoverageplan...........................................................................................247.5.1 Globalconfiguration.............................................................................................................247.5.2 Item1:Coveralltransmittedprotocolmessages....................................................257.5.3 Item2:Allreceivedprotocolmessages........................................................................267.5.4 Item3:Somekeyeventsduringmessagetransmission.......................................277.5.5 Item4:Foralltransmittedmessagesgettingallpossiblevalidresponses..297.5.6 Item5:Foralltransmittedmessagesunexpectedacknowledgement...........307.5.7 Item6:Powernegotiationsequence.............................................................................327.5.8 Item7:Timeouterrorinjectionwithinpowernegotiationsequence...........33
8 Conclusion..................................................................................................................35
![Page 3: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/3.jpg)
www.verifsudha.com 3
1 IntroductionWewerepresentingourwhiteboxfunctionalandstatisticalcoveragegenerationsolution,oneoftheengineerasked,canittakestandardspecificationsasinputandgeneratethefunctionalcoveragefromit?
Figure1:Specificationtofunctionalcoveragemagicpossible?Ireplied“No”.Itcannot.Butthenafterthepresentation,questionedmyselfasto,whynot?No,nostillnotbraveenoughtoparsethestandardspecificationsusenaturallanguageprocessing(NLP)toextracttherequirementsandgeneratethefunctionalcoveragefromit.Butwehavetakenfirststepinthisdirection.It’sababystep.Maybesomeofyoumightlaughatit.Wearecallingitashighlevelspecificationmodelbasedfunctionalcoveragegeneration.Ithassomeremarkableadvantages.Aseverytime,Ifeltthisis“the”waytowritefunctionalcoveragefromnowonJIdeaisverysimple.Iamsuresomeofyoumighthavealreadydoingitaswell.Capturethespecificationinformofdatastructures.DefinebunchofAPIstofilter,transform,queryandtraversethedatastructures.CombinetheseexecutablespecificationswithourpythonAPIsforSystmVerilogfunctionalcoveragegeneration.Voila,poorman’sspecificationtofunctionalcoveragegenerationisready.Yes,youneedtolearnscriptinglanguage(pythoninthiscase)andre-implementsomeofthespecificationinformationinit.That’sbecauseSystemVerilogbyitselfdoesnothavenecessaryfirepowertogetitalldone.Scared?Turnedoff?Noproblem.Nothingmuchislost.Pleasestopreadingfromhereandsaveyourtime.Adventurersandexplorerssurvivingthishardfactpleasehopon.Iamsureyouwillfallinlovewithatleastonethingduringthisride.
![Page 4: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/4.jpg)
www.verifsudha.com 4
2 Howisthisapproachdifferent?Howisthisapproachdifferentfrommanuallywritingcoveragemodel?ThisisaveryimportantquestionandwasraisedbyFaisalHaque.Therearemultipleadvantages,whichwewilldiscusslaterinthearticle.Inmyviewsinglebiggestadvantageismakingthecoverageintentexecutablebytrulyconnectingthehigh-levelmodelofspecificationstofunctionalcoverage.Nowearenottalkingaboutjustputtingspecificationsectionnumbersincoverageplanwearetalkingaboutreallycapturingthespecificationandusingitforgenerationoffunctionalcoverage.Letmesettheexpectationsright,thisapproachwillnotfigureoutyourintent.Theideaisaboutcapturingandpreservinghumanthoughtprocessbehindthefunctionalcoveragecreationinexecutableform.Sothatitcanbeeasilyrepeatedwhenthingschange.That’sall.It’sastartandfirststeptowardsspecificationstofunctionalcoveragegeneration.Typicallyfunctionalcoverageisimplementedassetofdiscreteindependentitems.Theintentanditsconnectiontospecificationsareweaktonon-existentinthistypeofimplementation.Mostoftheintentgetseitherleftbehindinthewordofexcelplanwhereitwaswrittenorintheformofcommentsinthecode,whichcannotexecute.
3 MakingintentexecutableWhycapturingintentinexecutableformisimportant?Werespectandvaluethehumanintelligence.Why?Isitonlyforthisemotionreason?No.Makinghumanintelligenceexecutableisfirststeptoartificialintelligence.Abilitytotranslatetherequirementsspecificationintocoverageplanishighlydependentontheexperiencesanddepthofspecificationunderstandingoftheengineeratthemomentofwritingit.Ifitsnotcapturedinthecoverageplanit’slost.Eventheengineerwhowrotethefunctionalcoverageplanmayfinditdifficulttorememberwhyexactlycertaincrosswasdefinedafter6months.Nowthiscanbecomerealchallengeduringtheevolutionandmaintenanceofthefunctionalcoverageplanastherequirementsspecificationsevolve.Engineerdoingincrementalupdatesmaynothaveluxuryofthetimeastheearlieronehad.Unlesstheintentisexecutablethequalityofthefunctionalcoveragewilldegradeoverperiodoftime.NowifyouaredoingthisdesignIPforonlyonechipandafterthatifyouarethrowingitawaythisfunctionalcoveragequalitydegradationmaynotbesuchabigconcern.
![Page 5: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/5.jpg)
www.verifsudha.com 5
Let’sunderstandthislittlefurtherwithexample.IntheUSBPowerdeliverycasestudyyouwillbeabletofindmoredetailsaboutthisexample.USBpowerdeliverysupportsmultiplespecificationrevisions.Let’ssay,wewanttocoveralltransmittedpacketsforrevisionx.Inmanualapproachwewilldiscretelylistprotocoldataunitsvalidforrevisionx.Forthislistingyouscanthespecifications,identifythemandlistthem.Onlywaytoidentifythemincodeasbelongingtorevisionxiseitherthroughcovergroupnameorcommentinthecode.InthenewapproachyouwillbeabletooperateonalltheprotocoldataunitssupportedbyrevisionxasaunitthroughAPIs.Thisismuchmoremeaningfultoreadersandmakesyourintentexecutable.Aswecalledout,ourideaistomakecoverageintentexecutabletomakeitadaptable.Let’scontrastbothapproacheswithanotherexample.Forexample,let’ssayyouwanttocovertwoitems:
• Allpackettransmittedbydevicesupportingrevision2.0• Intermediateresetwhileallpackettransmittedbydevicesupporting
revision2.0
Ifyouweretowritediscretecoverage,youwouldhavesampledpackettypeandlistedallthevalidpackettypesofrevision2.0asbins.SincebinsarenotreusableinSystemVerilogyouwoulddocopyandpastethemacrossthesetwocovergorups.Nowimagine,ifyoumissedapackettypeduringinitialspecificationscanorerratacontainingonemorepackettypecameoutlater,youneedtogobackandaddthisnewtypeattwodifferentplaces.Butwiththisnewapproach,assoonasyouupdatethespecificationdatastructurewithnewtypeyouaredone.Allthequeriesrequestingrevisionxwillautomaticallygetupdatedinformation.Henceallthefunctionalcoveragetargetedtorevisionxwillbeautomaticallyupdated.Rememberinitiallyitmaybeeasytospottwoplaceswherethechangeisrequired.Butwhenyouhavehundredsofcovergroupsitwillbedifficulttoreflecttheincrementalchangestoallthediscretecovergroups.Itwillbeevenmoredifficultwhennewengineerhastodotheupdatewithoutsufficientbackgroundontheinitialimplementation.
4 BenefitsWhatarethebenefitsofthisapproach?Withhigh-levelspecificationmodelbasedfunctionalcoveragetheabstractionofthoughtprocessofwritingcoveragemovesupanditfreesupbrainbandwidthto
![Page 6: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/6.jpg)
www.verifsudha.com 6
identifymoreitems.Thisadditionalbrainbandwidthcansignificantlyhelpimprovethequalityoffunctionalcoverageplanandhencetheoverallqualityoffunctionalverification.Benefitsofhigh-levelmodelbasedfunctionalcoveragegeneration:
• Intentgetscapturedinexecutableform.Makesiteasytomaintain,updateandreviewthefunctionalcoverage
• Executableintentmakesyourcoveragetrulytraceabletospecification.Itsmuchbetterthanjustincludingthespecificationsectionnumberswhichleadstomoreoverheadthanbenefit
• Itseasytomapthecoveragefromsinglespecificationfromdifferentcomponentspointsofview(Ex:USBdeviceorhostpointofvieworPCIerootcomplexorendpointorUSBPowerdeliverysourceorsinkpointofview)fromsinglespecificationmodel
• Easytodefineandcontrolthequalityofcoveragecontrolledbythelevelofdetailsinthecoveragerequiredforeachfeature(Ex:Coveranycategory,coverallcategoriesorcoverallitemsineachcategory)
• Easytosupportandmaintainmultipleversionsofthespecifications• Dynamicallyswitchtheviewofthecoverageimplementedbasedonthe
parameterstoeasetheanalysis(Ex:Perspeed,perrevisionorforspecificmode)
5 ArchitectureHowtogoaboutbuildinghigh-levelspecificationmodelbasedfunctionalcoverage?Firstlet’sunderstandthemajorcomponents.Followingistheblockdiagramofthehigh-levelspecificationmodelbasedfunctionalcoverage.Wewillbrieflydescriberoleandfunctionalityofeachoftheseblocks.Thisdiagramonlyshowsbasicbuildingblocks.Laterwewilllookatthecasestudieswherewewillseetheseblocksinactionmakingtheirexplanationsmoreclear.Itwillalsoguidehowtoimplementtheseblocksforyourprojectaswell.
![Page 7: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/7.jpg)
www.verifsudha.com 7
Figure2:Blockdiagramofhigh-levelspecificationmodelbasedfunctionalcoveragegeneration
5.1 ExecutablecoverageplanExecutablecoverageplanistheblockthatactuallyhostsallthefunctionalcoverageitems.It’scoverageplananditsimplementationtogether.Itdoestheimplementationoffunctionalcoverageitemsbyconnectingthehigh-levelspecificationmodel,sourceofinformationandSVcoverageAPIs.TheAPIsutilized,specificationinformationaccessedandrelationsofvariousitemsutilizedpreservestheintentinexecutableform.Userstillspecifiestheintentofwhattocover.Itwon’treadyourmindbutyouwillbeabletoexpressyourthoughtsathigherlevelofabstractionsandmorecloserorspecificationsandinhighlyprogrammableenvironmentthatismuchmorepowerfulthatSystemVerilogalone.
5.2 High-levelspecificationmodelingThisblockiscombinationofsetofdatastructuresandAPIs.Datastructurescapturehigh-levelinformationfromthespecifications.Thesedatastructurescanbecapturinginformationaboutpropertiesofdifferentoperations,statetransitiontablesrepresentingthestatemachines,information
![Page 8: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/8.jpg)
www.verifsudha.com 8
abouttimersastowhentheystart,stop,timeoutorgraphscapturingvariousformsofsequences.Ideahereiscapturetherelevantinformationaboutthespecificationthatisrequiredforthedefinitionandimplementationofthefunctionalcoverage.Choosetherightformofdatastructuresthatfitthepurpose.Thesedatastructureswillvaryfromdomaintodomain.APIsontheotherhandprocessthedatastructurestogeneratedifferentviewsoftheinformation.APIscanbedoingfiltering,combinations,permutationsorjusteaseaccesstotheinformationbyhidingthecomplexityofdatastructures.ThereissomelevelofreusepossiblefortheseAPIsacrossvariousdomains.UsingthesesetofdatastructuresandAPIsnowwearereadytotranslatethecoverageplantoimplementation.
5.3 InformationsourceSpecificationdatastructuresmaydefinethestructureofoperationsbuttocoverit,weneedtoknowhowtoidentifythecompletionofoperation,whatisthetypeoperationofoperationcompletedandcurrentvaluesofitspropertiesetc.InformationsourceprovidestheabstractiontobindthespecificationinformationtoeithertestbenchordesignRTLtoextracttheactualvaluesofthesespecificationstructures.Thisabstractionprovidestheflexibilitytoeasilyswitchthesourceofcoverageinformation.Bottomlinestoresinformationaboutsourcesthatareeithersampledforinformationorprovidestriggerstohelpdecidewhentosample.
5.4 SystemVerilogCoverageAPIinPythonWhydoweneedtheseAPIs,whycan’twejustdirectlywriteitinSystemVerilogitself?That’sbecauseSystemVerilogcovergrouphassomelimitations,whichpreventtheeaseofreuse.
5.4.1 LimitationsofSystemVerilogCovergroupSystemVerilog functional covergroup construct has some limitations, whichpreventsitseffectivereuse.Someofthekeylimitationsarefollowing:• Covergroupconstruct isnotcompletelyobjectoriented. Itdoesnotsupport
inheritance.Whatitmeansisyoucannotwriteacovergroupinbaseclassandadd,updateormodifyitsbehaviorthroughderivedclass.Thistypeoffeatureis very important when you want to share common functional coveragemodels across multiple configurations of DUT verified in different testbenchesandtosharethecommonfunctionalcoverageknowledge
![Page 9: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/9.jpg)
www.verifsudha.com 9
• Withoutrightbinsdefinitionsthecoverpointsdon’tdomuchusefuljob.Thebins part of the coverpoint construct cannot be reused across multiplecoverpointseitherwithinthesamecovergrouporindifferentcovergroup
• Key configurations aredefined as crosses. In some cases youwould like toseedifferentscenariostakingplaceinallkeyconfigurations.Butthereisnocleanwaytoreusethecrossesacrosscovergroups
• Transition bin of coverpoints to get hit are expected to complete definedsequence on successive sampling events. There is no [!:$] type of supportwhere the transition at any point is considered as acceptable. This makestransitionbinimplementationdifficultonrelaxedsequences
5.4.2 CoverageAPILayering
At VerifSudha, we have implemented a Python layer that makes theSystemVerilog covergroup construct object oriented and addresses all of theabove limitations tomake the coveragewriting processmore productive. Alsothe power of python language itself opens up lot more configurability andprogrammability.Based on this reusable coverage foundationwe have also builtmany reusablehighlevelcoveragemodelsbundledwhichmakethecoveragewritingeasierandfaster.Greatpartisyoucanbuildlibraryofhigh-levelcoveragemodelsbasedonbest-knownverificationpracticesofyourorganization.These APIs allows highly programmable and configurable SystemVerilogfunctionalcoveragecodegeneration.FundamentalideabehindalltheseAPIsisverysimple.
Figure3:SVCoverageAPIlayering
WehaveimplementedtheseAPIsasmultiplelayersinpython.
![Page 10: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/10.jpg)
www.verifsudha.com 10
Bottommostlayerisbasicpythonwrappersthroughwhichyoucangeneratethefunctionalcoveragealongwiththesupportforobjectorientation.Thisprovidesthefoundationforbuildingeasytoreuseandcustomizehigh-levelfunctionalcoveragemodels.Thisissufficientforthecurrentcasestudy.RTLelementscoveragemodelscovervariousstandardRTLlogicelementsfromsimpleexpressions,CDC,interruptstoAPPsforthestandardRTLelementsuchasFIFOs,arbiters,registerinterfaces,lowpowerlogic,clocks,sidebands.Genericfunctionalitycoveragemodelsarestructuredaroundsomeofthestandardhigh-levellogicstructures.Forexampledidinterrupttriggerwhenitwasmaskedforallpossibleinterruptsbeforeaggregation.Sometimesthistypeofcoveragemaynotbeclearfromthecodecoverage.Someofthesearealsobasedonthetypicalbugsfoundindifferentstandardlogicstructures.Athighest-levelaredomainspecificoveragemodel.Forexamplemanyhigh-speedserialIOshavesomecommonproblemsbeingsolvedespeciallyatphysicalandlinklayers.Thesecoveragemodelsattempttomodelthosecommonfeatures.Allthesecoveragemodelsareeasytoextendandcustomizeastheyarebuiltonobjectorientedparadigm.That’stheonlyreasontheyareuseful.Iftheywerenoteasytoextendandcustomizetheywouldhavebeenalmostuseless.
5.4.3 Implementation• BackboneoftheseAPIsisdatastructurefortheSystemVerilogcovergroups
modeledaslistofdictionaries.Eachofthecovergroupbeingadictionarymadeupoflistofcoverpointdictionariesandlistofcrossdictionaries.Eachofthecoverpointandcrossdictionariescontainlistofbindictionaries
• Thesedatastructuresarecombinedwithsimpletemplatedesignpatterntogeneratethefinalcoveragecode
• UsinglayerofAPIsonthesedatastructureadditionalfeaturesandlimitationsofSystemVerilogcovergroupareaddressed
• SetofAPIsprovidedtogeneratethereusablebintypes.ForexampleifyouwanttodivideanaddressrangebetweenNequalparts,youcandoitthroughtheseAPIsbyjustprovidingthestartaddress,endaddressandnumberofranges
• Therearealsobunchofobjecttypesrepresentinggenericcoveragemodels.Bydefiningtherequiredpropertiesfortheseobjecttypescovergroupscanbegenerated
• Usingpythoncontextmanagersthecovegroupmodelingiseasedofffortheuser
AnyuserdefinedSystemVerilogcodecanco-existwiththeseAPIs.ThisenableseasymixofgeneratedandmanuallywrittencodewhereAPIsfallshort.
![Page 11: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/11.jpg)
www.verifsudha.com 11
Figure4:WhattoexpectfromAPIs
5.4.4 StructureofuserinterfaceAlltheAPIsessentiallyworkontheobject.Globalattributescanbethoughtofasapplicabletoentirecovergroup.Forexampleifyouspecifiedbinsatthegloballevelitwouldapplytoallthecoverpointsofthecovergroup.Notonlytheinformationrequiredforcoveragegenerationbutalsodescriptionandtrackinginformationcanbestoredinthecorrespondingobject.Thisadditionalinformationcanbebackannotatedtosimulatorgeneratedcoverageresultshelpingyoucorrelateyourhigh-levelpythondescriptionstofinalcoverageresultsfromregressionseasily.AlsotheAPIssupportmindmapsandExcelfilegenerationstomakeiteasytovisualizethecoverageplanforreviews.
![Page 12: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/12.jpg)
www.verifsudha.com 12
Figure5:Structureofuserinterfaceforobjects
5.5 SourceinformationCovergroupsrequirewhattosampleandwhentosample.Thisistheblockwhereyoucapturethesourcesofinformationforwhattosampleandwhentosample.It’sbasedonverysimpleconceptlikeVerilogmacros.Allthecoverageimplementationwillusethesemacros,sothatitabstractsthecoveragefromstaticallybindingtosourceoftheinformation.Laterthesemacroscanbeinitializedwiththeappropriatesourceinformation.
Snippet1:SpecifyingsourceinformationThisflexibilityallowsusinginformationsourcefromeitherbetweentheRTLandtestbench.Easilybeabletoswitchbetweenthembasedonneed.Followingcodesnippetsshowcasehowcovergroupimplementationforsimpleread/writeandaddresscanbedoneusingeitherRTLdesignortestbenchtransactions.
![Page 13: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/13.jpg)
www.verifsudha.com 13
Snippet2:CoveragegeneratedusingtestbenchtransactionCoverpointsinsnippet2aresamplingtheregisterreadwritetransactionobject(reg_rd_wr_tr_obj).Samplingiscalledoneverynewtransaction
Snippet3:CoveragegeneratedusingDUTsignalsCoverpointsinsnippet3aresamplingtheRTLsignalstoextracttheread/writeoperationandaddress.Samplingiscalledoneverynewclockqualifiedbyappropriatesignals.
6 Summary:Functional coverage is one of the last lines of defense for verification quality.Being able to repeatedly do a good job and do it productively will havesignificantimpactonyourqualityofverification.Initiallyitmayseemlikelotofwork,youneedtolearnascriptinglanguageandlearndifferenttechniquesofmodeling.Butpayoffwillnotonlyforthecurrentproject but throughout the lifetime of your project by easing themaintenanceandallowingyoutodeliverthehigherqualityconsistently.
![Page 14: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/14.jpg)
www.verifsudha.com 14
7 USBPowerdeliveryprotocollayer–CasestudyBeforewejumpintoimplementationdetails,hereisaveryshortrefresherwithonlylimitedthedetailsrelevantforthiscasestudy.
7.1 RefresherDynamicnegotiablepowerisbasicideabehindtheUSB–powerdelivery.Obviouslyfornegotiationtotakeplaceweneedtwoentities.Theyaresourceandsink.
Provider(SOURCE)suppliespowerandConsumer(SINK),usesthesuppliedpower.Asimpleprovidercouldbewalloutletorlaptopandsimplesinkcouldbemobileortablet.Powernegotiatedcanbeupto100Watts.Thecableshavetobedesignedtosupportthat.Cablesareelectronicallymarkedaswelltospecifytheircapabilities.RefinedUSBconnectorcalledtype-cisgainingpopularity,usedfortheUSBpowerdeliverysupport.Theretwoadditionalwiresaddedintheconnectortosupporttheprotocol.OnthesetwoadditionalwiresUSBpowerdeliveryrunsaprotocolstackmadeupoffollowingthreelayers:
• Physicallayer• Protocollayer• Policyengine.
Wewilllookintobrieflyprotocollayeronly.
![Page 15: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/15.jpg)
www.verifsudha.com 15
Nowprotocolitselfisverysimple.It’shalfduplex.Half,yes,that’sright.It’smadeupofbunchofmessages.Therecanbeonlyoneoutstandingmessagebetweenthepairofcommunicatingdevices.Everymessagehastobeacknowledgedforsuccessfulreception.Onlyafterthatnextmessageistransmitted.Therearethreecategoriesofmessages.TheyareCONTROL,DATAandEXTENDED.
Let’slookatthesimpleprotocolsequence.Inverysimpleterms,transmittersendsrequest,waitforacknowledgement.Receiversendsacknowledgement.Followedbythatreceiversendstheresponseandwaitsfortheacknowledgementfromrequesttransmitter.That’sit.
Differenttimersgovernmaximumwaittimeforthevariousacknowledgementandresponses.
![Page 16: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/16.jpg)
www.verifsudha.com 16
7.2 ProtocollayerfunctionalcoveragechallengesTherearethreechallengeshere:
• Multiplespecificationrevisionsupport(Rev2.0andRev3.0)• Protocolhasmultipleparticipants:Source,Sink,Cableplug,Source/Sink
(DRP)Therearesignificantdifferencesbetweenrevision2.0and3.0.EXTENDEDcategoryofmessagesisaddedonlyinrevision3.0.WhenyouwritecoveragemodelSOURCEandSINKarelikemirrorimages.Whatiscoveredastransmitforoneneedstocoveredasreceivefortheother.
7.3 FunctionalcoverageitemsforcasestudyNowlet’spicksomeitemstocoverandseehowtheywouldlooklikeinhigh-levelmodelingbasedfunctionalcoverage.Pickingrainbowofsimpleatomicitems,simplesequenceandcomplexsequences:Sl.No. Coverageitemdescription1 Alltransmittedprotocolmessages2 Allreceivedprotocolmessages3 Somekeyeventsduringmessagetransmission4 Foralltransmittedmessagesgettingallpossiblevalidresponses5 Foralltransmittedmessagesunexpectedacknowledgementreceived6 Powernegotiationsequence7 Timeouterrorinjectionwithinpowernegotiationsequence
Table1:SelectedfunctionalcoverageitemsforcasestudyForalltheseitemslet’sdemonstratehowallthebenefitsofhigh-levelmodelbasedfunctionalcoveragepromisedcanbeachieved.Nowlet’sjumpintodetailsofimplementationstartingwiththespecificationmodelingoftheUSBpowerdeliveryfirst.
![Page 17: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/17.jpg)
www.verifsudha.com 17
7.4 USBpowerdeliveryspecificationinformationmodelingFirstthingweneedtodoismodelthespecificationdetails.Weareshowcasinglimiteditemsmodelingheretobalancebetweenthedetailsandeaseofdemonstratingconcepts.Wewillfocusonlyonthedetailsofthespecificationrequiredforimplementingtheitemswehavepickedinsection7.3.Hereishowwewillgoaboutdescribingtheimplementationofspecificationmodeling.Wewillfirstshowsomemindmapsforhigh-levelviewofinformationcapturedandthenshowthecorrespondingimplementationinpythonforreference.High-levelspecificationinformationmodeledlooksasfollowing.
Mindmap1:Toplevelviewofhigh-levelspecificationinformationitemscapturedWehavecapturedtheallthethreecategoriesofmessages,someimportantevents,informationabouttimersandprotocolsequencesarecapturedasgraphs.Wewillkeepgoingdeeperineachofthesenodestoseehowtheyareimplemented.
![Page 18: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/18.jpg)
www.verifsudha.com 18
7.4.1 MessagemodelingLet’sgofirstleveldeepintothemessagemodeling.Therearethreecategoriesofmessagesmodeled:control,dataandextended.Eachcategoryismodeledseparatelytomaintaintheclassificationseveninthegeneratedcode.Forexamplewhenweneedtocoverallthemessagetypeswecanhaveeithersinglecoverpointforallmessagesorthreecoverpointcoveringeachcategoryofmessages.Lateriseasywhenweanalyzetheresults.Althoughitmaybeadditionalefforttowriteitbutlet’snotforgetwewriteoncebutanalyzeresultsmultipletimes.
Mindmap2:AllthreetypesofmessagetypesandControlmessagestypesexpandedLetsexpandonelevelfurtherintooneofcontrolmessagetypecalledGotoMin.Notalltheinformationshownbelowismanuallyfilled.Someofitismanuallyfilledandsomeofitisautomaticallygenerated.
Mindmap3:GotoMinmessagestypesexpandedwithdifferentfields
![Page 19: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/19.jpg)
www.verifsudha.com 19
Forexample,foreachmessagetypesdecodinginformationismanuallyfilledin“DECODE”buttheTX_SIGNAL_EXPRandRX_SIGNAL_EXPR,whichindicatehowtodecodetheeachmessagetype,arecreatedautomaticallyforallthemessagetypes.Sinceit’susedacrossmultiplecoverageitemsinsteadofcreatingeverytime,it’screatedoncestoredinthedatastructure.Nowlet’sgetintodetailsofhowtoimplementinpython.It’sasimpledictionary.Everymessagetypeiskey.It’spointingtoanotherdictionarycontainingfollowingkey-valuepairs.Thisinformationhastobefilledmanuallyreferringtothespecifications.Key DescriptionaboutvaluestoredDECODE ShowtohowtodecodethismessagetypeTX ListofwhichDUTtypescantransmitthistypeofmessageRX ListofwhichDUTtypescanreceivethistypeofmessageRESPONSE Ifitsrequesttype,listofallpossiblelegalresponsesREVISION ListofspecificationrevisionswhichsupportthismessagetypeTable2:Fieldsofthebasicmessagefieldmodeling
Snippet4:Pythonmodelingforthemessages
7.4.2 EventmodelingAllspecificationsidentifysetofkeyevents.It’sinterestingtocover,thesekeyeventstakingplaceatdifferentstates.Let’slookattheevents.Hereishigh-levelviewofsomeoftheeventscaptured.
![Page 20: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/20.jpg)
www.verifsudha.com 20
Mindmap4:EventsimplementationexpandedIt’sanothersimpledictionary.Keysbeinguserdefinedeventnames.Itpointstoanotherdictionarycontainingtheinformationaboutevents.Key DescriptionaboutvaluestoredORIGIN LayerfromwhicheventisemittedEVENT Actualevent.Thinkofthoseweirdlookingstringnamesstarting
andendingwithdoubleunderscoreslikeVerilogmacroTable3:Fieldsofthebasiceventfieldmodeling
Snippet5:PythonmodelingfortheeventsThoseevents(EVENTfield)canbepointedtoRTLdesignsignalsortestbenchevents.
7.4.3 ProtocolsequencemodelingHerecomesajuicypart.Simpletreedatastructureisusedtorepresenttheprotocolsequenceasagraph.Beforewecangettothat,let’sbrieflyfamiliarizeourselveswiththepowernegotiationsequence.
![Page 21: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/21.jpg)
www.verifsudha.com 21
Followingdiagramfromspecificationshowsthestepsofpowernegotiationsequence.Step1:SOURCEsendsitscapabilitiestoSINK
Step2:SINKselectsthepowerofferingthatsuitsit
Step3:SOURCEacceptstheSINKrequestforspecificofferingifitlikesit
Step4:SOURCEsendsnewpowerofferingisready.Dealisdone
![Page 22: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/22.jpg)
www.verifsudha.com 22
Figure:4stepssuccessfulpowernegotiationsequenceAtStep3aboveshowsAcceptscenario,therearemultiplepossibleresponses.Ifwegobacktoourspecification-modelingtable,wecansee,RESPONSEindicatesmultiplepossibilitiestothissequence.Abovesequenceshowsonlyoneofthem.Buttocompletelymodelitweneedtocaptureallthepossibilitiesandgeneratethefunctionalcoverageforallpossiblesequences.
Snippet6:PythonmodelingforallpossibleRESPONSEtoRequestmessageLetslookathowthesimplepowernegotiationsequencewithallthesepossibilitiescanbecapturedinthetreedatastructure.ThisishowthetreeoftheprotocolsequenceswouldlooklikevisualizedinMindmap.LookattheorderingofMESSAGE_TYPEfieldsinthenodefirst.Theoneinmiddle(Mindmap6)isthecompletediagram.Theoneintop(Mindmap5)inzoomoffirsthalf(2/4steps)andoneinbottom(Mindmap7)isthezoomofsecondhalf(4/4steps)ofthegraph.
Mindmap5:Zoomoffirsthalfofpowernegotiationsequence(Seebelowforfullgraph)
Mindmap6:Graphofpowernegotiationprotocolpossibilities
Firsthalfzoom
Secondhalfzoom
![Page 23: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/23.jpg)
www.verifsudha.com 23
Mindmap7:Zoomofsecondhalfofpowernegotiationsequence(seeaboveforfullgraph)Completegraphmaynotbeclearlyvisible.Usethatonlyforgettingthebigpicture.Fordetails,Ihavezoomedthemintwoparts.Firstpartisfromstarttothenodewhereitbranchesintothreeparts(firsttwosteps).Secondonecontainsthedetailsaboutallthethreepossibleoptions.Nowifweexpandthisgraphintosequencesitwillresultsinthreeuniquesequenceswiththefirsttwosteps(Step1,Step2fromFigure4))beingcommon.Justcatchthevisualviewwiththefollowingpicture.Iwillexplainbitofdetailsbelow.
Mindmap8:Possible3sequencesfromthepowernegotiationgraphThreesequencespossibleare:
• Sequence1:SourceCapabilities=>GoodCRC=>Request=>GoodCRC=>Reject=>GoodCRC(6nodes)
• Sequence2:SourceCapabilities=>GoodCRC=>Request=>GoodCRC=>Wait=>GoodCRC(6nodes)
• Sequence3:SourceCapabilities=>GoodCRC=>Request=>GoodCRC=>Accept=>GoodCRC=>PS_RDY=>GoodCRC(8nodes)
ImplementationofthesesequencesrequiresDUTtype(SOURCE,SINK)tobedefined.BasedontheDUTtypethedirectionofeachofthesemessagesgetsdecided.UsingtheDUTtypeappropriateeventispickedfromthenodeinformation.Key DescriptionaboutvaluestoredNODE_TYPE Typeofnode:ItcanbeMESSAGE,EVENTMESSAGE_TYPE IfthenodetypeisMESSAGEwhatisthetypeofMESSAGESINK ForSINKtypeofdevice,theeventtobeusedSOURCE ForSOURCEtypeofdevice,theeventtobeusedTable4:Fieldsusedinthenodesofthegraphs
![Page 24: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/24.jpg)
www.verifsudha.com 24
Orderingofstepsofsequenceisextractedfromgraphsandeventinformationforimplementingeachstepisextractedfromthenodeinformationforfunctionalcoveragesequencesgeneration.Interestingpartofthesegraphsisnotjustabovesequencegeneration,butexpandingthesegraphstocovermanymorecasesalgorithmically.ForexamplewesawthateverymessagetransmittedrequiresaconfirmationmessagecalledGoodCRC.Nowweknowwhereverthereiswaitthereisgenerallyatimerassociatedtopreventinfinitewaiting.ForGoodCRCthereisCRCReceiveTimer.ForimportantsequenceswecanautomaticallyaddatimeoutnodewhereverthereisGoodCRCmessageisinvolved.Thisallowscontrollingthequalityofverificationonspecificsequencesbycontrollingtheverbosityofcoveragegenerated.Itsdemonstratedinsection7.5.8.
7.5 ExecutablecoverageplanNowthatwehavecapturedallthespecificationinformation,let’sjumpintothehowtousethespecificationmodelforfunctionalcoveragegeneration.Wewillimplementallthe7coverageitemsselectedinSection7.3.Inearlyitems,wewillputinlittlebitmoreexplanation.Butaswegoalong,wewillreduceitasyoustartgettingfamiliar.Foreachitemwewillbrieflyexplainwhattheitemissupposetocover,thenshowtheinputpythoncodesnippetforcoverageitemimplementationandgeneratedfunctionalcoverage.WewillbrieflyexplaintheAPIsusedintheinputandpointtoanythingspecifictobeobservedinthecovergroups.Ideahereisnottoexplaineverythingdetailofthecodebutatthesametimestaygroundedtogiveaflavorofcodetomakeconceptsconcretebyshowinghowyoucangoaboutimplementations.Covergroupsandcoverpointsneedadditionallyneedwhattosampleandwhentosamplethatneedstobeprovidedasseparateinput.ThiscaneitherbetappedfromtestbenchvariablesorfromRTL.Thispartisskippedaswehavealreadyexplaineditinsection5.5.
7.5.1 GlobalconfigurationTokeepitsimplethecoveragemodelismadeconfigurableatgloballevelacrossallcovergroupsforsomeparametersbutitcanbedoneeasilyatperitemlevelaswell.Foralltheexampleitemsweareusingfollowingconfiguration.Whatitmeans?
![Page 25: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/25.jpg)
www.verifsudha.com 25
Covergroupswillbegeneratedfor• DUTsupportingonlyRevision2.0ofspecification(Selectedthisbecause
numberofmessagesarelesseranditseasyshowsnippets)• DUTTypeofSINK• Qualityofcoveragesettohighestlevel(Thisconceptwillbe
demonstratedinthesection7.5.4)
Snippet7:Globalconfiguration
7.5.2 Item1:CoveralltransmittedprotocolmessagesHerewewanttocoveralltransmittedmessagestypespossibleacrossallthreecategoriesforspecifiedDUT_TYPEandDUT_REV_SUPPORT.Input:Pythoncodeforcoverageitem
Snippet8:PythonimplementationtocoveralltransmittedprotocolmessagesSo,What’shappening?TheAPIget_bins_for_matching_msgsreturnsthebinspercategoryofmessageslisted(argument:[“CONTROL”,“DATA”,“EXTENDED”])thatcanbetransmitted(argument:“TX”)byDUTofthetypeSINK(Globalsetting:DUT_TYPE)andsupportingtheUSBpowerdeliveryrevision2.0(GlobalsettingDUT_REV_SUPPORT).TheAPIadd_cp_for_msg_typescratesandaddsthecoverpointsandbinstothecovergroup.Alongwithbinspercategory,ittakesinwhattobesampledandwhentobesampledinformationaswell.BothoftheseAPIsinternallyusetheobjectorientedfunctionalandstatisticalcoveragecodegenerationAPIsthatarepartofcuriosityframework.Ifyouseethegeneratedoutput,thereisonecovergroupwithtwocoverpoints.ThereiscoveporinteachforCONTROLandDATAmessagecategories.Encodings
![Page 26: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/26.jpg)
www.verifsudha.com 26
andnamesofbinsinthegeneratedoutputarederivedfromthespecificationinformationcapturedinthesnippet4.Output:Covergroupgenerated
Snippet9:GeneratedSystemVerilogCovergroupforalltransmittedprotocolmessagesDidyounotice?Messagecategoriespassedincludes“CONTROL”,“DATA”and“EXTENDED”.Butinthegeneratedoutputwedon’tseeEXTENDEDmessages–Why?That’sbecausetheUSBPowerdeliveryrevision2.0doesnotsupporttheEXTENDEDmessagetypes.Ifweswitchthesupportedrevisiontypeto3.0thentheEXTENDEDmessagetypeswillbeaddedasanothercoverpoint.BasedontheDUTtypeandsupportedrevisionsthecoverpointsandbinswillautomaticallychangeforeachmessagecategories.Isn’tthatsomething?
7.5.3 Item2:AllreceivedprotocolmessagesThisitemselectedtodemonstratehoweasyitistoswitchdirectioninthecoverageimplementationfromalltransmittedtoallreceivedmessagescoverage.Input:Pythoncodeforcoverageitem
Snippet10:Pythonimplementationtocoverallreceivedprotocolmessages
![Page 27: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/27.jpg)
www.verifsudha.com 27
Everythingissameascoveringalltransmittedmessagetypes,exceptdirectionsensitiveinformationchangedtoreceive.Whentosamplechangestoreceivemessageevent.ToAPIget_bins_for_matching_msgswechangethedirectionasRXTheAPIadd_cp_for_msg_typeschangestheinformationastobesampledtoqualifiedreceivedmessage.Output:Covergroupgenerated
Snippet11:GeneratedSystemVerilogCovergroupforallreceivedprotocolmessages
7.5.4 Item3:SomekeyeventsduringmessagetransmissionInthisitemwewanttocoversomekeyeventstakingplacewhiledifferentmessagestypesarebeingtransmitted.Manyoftheseeventsleadtosomeformabruptterminationofmessagebeingtransmittedfollowedbyrecovery.It’sinterestingtoseeifDUTcanrecovercorrectlyandoperatenormallyagain.Wewanttointroduceyoutoaninterestingconceptofqualityoffunctionalcoveragewiththisitem.Basicideaisdepthandwidthoffunctionalcoveragecanbeguidedbytheimportanceofparticularfeaturetocurrentproject.Nowyoucancoverthisitematthreelevelsofdetailsdependingonimportanceofthisfeatureforyourapplication:
• LEVEL3:Foreachofthemessageinallthreecategoriesofmessages.Resultsinverycomprehensivecoverage
![Page 28: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/28.jpg)
www.verifsudha.com 28
• LEVEL2:Anyonemessageineachcategory.Herewearerelaxingthecoveragebutstillcoveringeachofcategory
• LEVEL1:Anyonemessageacrossallcategories.Completelyrelaxed.Thistypeofconfigurabilitycanalsohelpeasilychangeyourmindwhileclosingcoverage.OnecouldcloseonLEVEL1forinitialmilestoneandthengraduallyreachLEVEL3basedonscheduleandpriorities.Input:Pythoncodeforcoverageitem
Snippet12:PythonimplementationtocoverkeyeventsduringmessagetransmissionOutput:WithqualityLEVEL3Highestquality.Coverallthemessagesinallthecategories.
Snippet13:GeneratedSystemVerilogCovergroupforqualityLEVEL3
![Page 29: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/29.jpg)
www.verifsudha.com 29
Mediumquality.Coveratleastonemessagepercategory.
Snippet14:GeneratedSystemVerilogCovergroupforqualityLEVEL2Lowestquality.Coveratleastonemessageacrossallthreecategories.
Snippet15:GeneratedSystemVerilogCovergroupforqualityLEVEL1
7.5.5 Item4:ForalltransmittedmessagesgettingallpossiblevalidresponsesInthespecificationtablewehadcapturedforallthemessageswhatarethepossiblevalidresponses.ForexamplechecktheSnippet6forinformationcapturedfortheRequestmessagetypeinfieldRESPONSE.ThisinformationisutilizedintheAPIsbelowtogeneratealltherequestandresponsepairs.Input:Pythoncodeforcoverageitem
Snippet16:Pythonimplementationtocoveralltransmittedmessagesgettingallpossiblevalidresponses
![Page 30: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/30.jpg)
www.verifsudha.com 30
Output:Covergroupgenerated
Snippet17:GeneratedSystemVerilogCovergroupforalltransmittedmessagesgettingallpossiblevalidresponses
7.5.6 Item5:ForalltransmittedmessagesunexpectedacknowledgementTheoutputcoverageshownhereisofLEVEL3quality.Meaning,allpossibleunexpectedresponsesareconsidered.Onecoulddebatethatcrosseswithsomecomplexexclusionbinscouldalsobeused.Rememberwewritecoverageoncebutanalyzeresultsmultipletimes.Sowritingcoveragewhichmightbeelaboratetowritebuteasiertoanalyzetheresultsthefasterwillbewellworththeeffort.Howeverpleasenoteelaborateworkifyouaremanuallywritingitbutifyouaregeneratingyoucanmakeiteasilysuityourpreferences.Alsoanyitemsmissedorspecificationsmisinterpretedareeasytofixinthespecificationtables.Itautomaticallyreflectsingeneratedcoderatherthanhavetopainfullyreanalyzetheintenttofixthebinsandexclusionbinsofthecrosses.Input:Pythoncodeforcoverageitem
Snippet18:Pythonimplementationtocoveralltransmittedmessagesgettingunexpectedacknowledgement
![Page 31: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/31.jpg)
www.verifsudha.com 31
Output:Covergroupgenerated
Snippet19:GeneratedSystemVerilogCovergroupforalltransmittedmessagesgettingunexpectedacknowledgement
(…)Line95to180:Binsofcp_CONTROL_msg_types
![Page 32: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/32.jpg)
www.verifsudha.com 32
7.5.7 Item6:PowernegotiationsequenceWehavealreadyseenthepowernegotiationprotocolsequenceanditsgraphintheSection7.4.3.Herewewilllookatitspythonimplementation.Weareusingsimpletreedatastructuretocapturethegraph.Input:GraphofpowernegotiationscenariosThisisthetreedatastructurerepresentationoftheprotocolsequencegraphshowninmindmap6.
Snippet20:PythonimplementationforgraphofpowernegotiationprotocolpossibilitiesOutput:CovergroupspersequenceSequencescanbecoveredwiththetransitionbinsbutit’sveryrestrictiveintermsofsampling.Wecoverthesequencewiththeadditionalstatemachinelikegluelogicin-ordertousethecovergroupconstruct.SystemVerilogassertionsdoprovidesomelevelflexibilityforsequencecoveragebuttaxingwhiledebugging.Asimplestatemachineisgeneratedasgluelogictotrackeachstepsofthesequence.Thispieceofgeneratedcodeisnotincludedtokeepfocusonthecoverage.Binperstepallowsveryclearideaofhowfarthesequencehadprogressedinregression.ThistypeofinformationisdifficulttofindoutwiththeSystemVerilogassertionbasedcoverage.AlsothestateofstepstrackingstatemachinegeneratedcanbeaddedtothewavesalongwiththeRTLmakingthecoverageholesdebugeasieraswell.Threesequencesgeneratedare:
• power_nego_protocol_SINK_0(binsfor8steps):SourceCapabilities=>GoodCRC=>Request=>GoodCRC=>Accept=>GoodCRC=>PS_RDY=>GoodCRC(8steps)
• power_nego_protocol_SINK_1(binsfor6steps):SourceCapabilities=>GoodCRC=>Request=>GoodCRC=>Wait=>GoodCRC(6steps)
• power_nego_protocol_SINK_2(binsfor6steps):SourceCapabilities=>GoodCRC=>Request=>GoodCRC=>Reject=>GoodCRC
![Page 33: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/33.jpg)
www.verifsudha.com 33
Snippet21:GeneratedSystemVerilogCovergroupfor3generatedsequenceofpowernegotiationprotocolpossibilities(observenumberofstepstocorrelate)
7.5.8 Item7:TimeouterrorinjectionwithinpowernegotiationsequenceAswehadseen,foreveryrequestorresponsemessagestheGoodCRCisexpectedtoconfirmitssuccessfulreceptionbypeer.ThereisCRCReceiveTimerdefinedbythespecificationswhichisstartedwhenrequestorresponsearetransmittedandstoppedwhenthecorrespondingGoodCRCacknowledgementisreceived.PowernegotiationsequenceisoneoftheveryimportantsequencesoftheUSBpowerdeliveryprotocol.Solet’ssaywedecidetocoverCRCReceiveTimertimeoutatallpossiblepointsinthissequencetoensurethissequenceisthoroughlyverified.Nowthistypeofcomprehensivecoveragemightbeveryeffortintensivetowritebutwithgraphsitcanbecreatedalgorithmicallywiththefollowingapproach.
![Page 34: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/34.jpg)
www.verifsudha.com 34
Input:AlgorithmInthefollowingsnippetwearetraversingthegraphofthepowernegotiationsequenceandwherevertheGoodCRCisnodeisfoundweareaddinganadditionaltimeoutnodetoparentnodeofGoodCRCnode.
Snippet22:PythonimplementationtoalgorithmicallyaddCRCReceiveTimeoutforallGoodCRCmessagewaitsOutput:MindmapofmodifiedgraphNowyoucanseewitheveryGoodCRCnode,aparallelnodeofCRCReceiveTimertimeoutnode(RED)hasbeenadded.
Mindmap9:AfteraddingCRCReceiveTimertimeoutnodetopowernegotiationgraphFromthisnewgraphautomaticallynewfunctionalcoveragesequencecanbegenerated.
Mindmap10:SequencesgeneratedafteraddingCRCReceiveTimertimeoutnodetopowernegotiationgraphWearejustshowingthemindmapsbutcodeonthesimilarlinesassimplepowernegotiationsequencewillgetgenerated.YoucanseeinthetimeoutsequencegraphstherearethreesequencesnotendinginREDblockarenormalpower
![Page 35: High-level specification model based Functional coverage generation · 2018-08-20 · 7 Figure 2: Block diagram of high-level specification model based functional coverage generation](https://reader034.fdocuments.us/reader034/viewer/2022042319/5f0920ef7e708231d4255d46/html5/thumbnails/35.jpg)
www.verifsudha.com 35
negotiationsequencescenarioswithouttimeout(whichwehadseenforpreviouslyforpowernegotiationsequenceitem).Theonesendingwiththeredblockarenewonesaddedalgorithmicallyforcoveringtimeoutateachstagesofthepowernegotiationsequence.Nowof-coursebasedonyourqualitygoalsyoucandecidetoaddtimeouttoonlycertainbranchesoraftercertaindepthintheprotocol.Possibilitiesareunlimited.Forcomplexprotocolsthisprovidesalotofflexibilitytodynamicallycontrolthequalityofcoveragegenerated.
8 ConclusionUSBpowerdeliveryprotocolprovidesatimecapsule.ItsoverallcomplexityislesserthanstandardUSB2.0butstillrelevantinthecurrenttimes.Wechooseitforitssimplicityandrelevance.USBpowerdeliverydoesexemplifytheproblemsofsimilarnaturefacedathighercomplexityinotherhigh-speedserialIOprotocols.Specificationtofunctionalcoveragepossibilityhasbeendemonstratedwiththiscasestudy.Forcomplexdesignsthisapproachcanmakewritingcomprehensiveandmaintainablefunctionalcoveragemodelseasierandfaster.Alsobeingabletodynamicallydefinelevelofqualityofcoveragecanhelptuneittoyourprojectpriorities.Ingeneralbymakingcoverageintentexecutable,itwillhelpyouchurnhigherqualityofdesignIPrevisionsthroughoutitslifecycle.
Formoreinformation,questionsordemowriteto:[email protected]
Wecanpartnerandhelpyourealizethebenefitsof
high-levelspecificationmodelbasedfunctionalcoveragegeneration
foryourdesigns.
www.verifsudha.com
©Copyright2018VerifSudhaTechnologiesPvt.Ltd.