6-1SynopsysProfessionalServicesHTCWorkshop.Confidential©2002SynopsysProprietaryAgenda:Day2DAY2TopicLabUnitDebuggingSimulationMismatches5UsingPLIRoutineswithVCS6FastRTLLevelVerification7FastGateLevelVerification8Appendix:VCS/VCM96-2SynopsysProfessionalServicesHTCWorkshop.Confidential©2002SynopsysProprietaryUnitObjectivesAftercompletingthisunit,youshouldbeableto:CompileanPLICprogramCreateaPLI.tabfileforthePLICprogramCallthePLICprograminVerilogcodeCompileVerilogcodeandlinkinPLICprogramRunSimulationwiththePLICprogramenabledVerilogcode6-3SynopsysProfessionalServicesHTCWorkshop.Confidential©2002SynopsysProprietaryWhatisPLI?ProgrammingLanguageInterface:zInterfacebetweenCprogramsandVerilogsimulatorszPartoftheVerilogstandardIEEE1364zEnablesdevelopmentofuserdefinedsystemtaskorfunctionExamplesofPLIusage:zTestbenchApplystimulusandcaptureresultszCmodelsEmulatefunctionalblockszExtendingtheVeriloglanguageDynamicmemorymanagement,fileI/oroutines,etc.6-4SynopsysProfessionalServicesHTCWorkshop.Confidential©2002SynopsysProprietaryLinkingCProgramstoVerilogCodeForthePLICprogram:zWritePLICprogramwithPLIlibraryroutinesInclude“vcsuser.h”and“acc_user.h”headerfileszCompileintoobjectcodeFortheVerilogcodezWriteVerilogwhichcallstheuserdefinedCPLIprogramInVCS:zCreatePLItable(.tabfile)MapsCprogram“task”tomatching“$task”inVerilogcodeControls“$task”accessintoVCSdatastructurezCompileVerilogcodeandlinkinPLICobjectcodeandlinkinPLItablwith-Pswitch6-5SynopsysProfessionalServicesHTCWorkshop.Confidential©2002SynopsysProprietaryAVerySimplePLIExamplevcsmy_model.v-Phello.tabhello.oPLItable//hello.tab$hellocall=hello_callVCS//my_model.vmodulemy_model;initial$hello;endmoduleVerilogCodeuserdefinedPLICcall/*hello.c*/#include“vcsuser.h”hello_call{io_printf(“Hello!\n”);}CPLIProgramhello.omy_model.vgccPLItfroutinesimv6-6SynopsysProfessionalServicesHTCWorkshop.Confidential©2002SynopsysProprietaryAnotherExample:TheFileI/OPackageVCSismostefficientreadingstimulusfromanexternalfileThecurrentVeriloglanguageislimitedinfileI/O:zOnly$readmemformatsupportedzOnly32filescanbeopenatonceFutureIEEE-1364standardwillincludesystemfunctionstoreadandwritefilesFornow,usethefileI/OpackagefromChrisSpear:zAvailablefrom©2002SynopsysProprietaryTheFileI/OPackageFilemanipulation:z$fopenr,$fcloser,$fopenw,$fclosew,$ferrorReadingASCIIfiles:z$fgetc,$ungetc,$fgets,$fscanf,$ftell,$fseekReadingbinaryfilesz$freadWritingASCIIfilesz$fprintfReadingandwritingVerilogstrings:z$sscanf,$sprintf6-8SynopsysProfessionalServicesHTCWorkshop.Confidential©2002SynopsysProprietaryFileI/ORoutinesComparedtoCCodeVerilogCCode`timescale1ns/10psmodulestim;integerfile,r,bin,dec,hex;realrtime;initialbegin$display(timedecimalhex);file=$fopenr(stim.pat);while(!$feof(file))begin//Readthenexttimer=$fscanf(file,%f,rtime);//Waituntiltheabsolutetimeinthefile,readstimulus#(rtime-$realtime)r=$fscanf(file,%d%h\n,dec,hex);$display(“@%t%d%h\n”,rtime,dec,hex);end//whilenotEOFr=$fcloser(file);end//initialendmodule//stim#include“stdio.h”main(){FILE*file;intdec,hex;doublertime;charline[1000];/*Lineoftextreadfromfile*/printf(timebindecimalhex\n);file=fopen(”stim.pat”,“r”);while(!feof(file)){/*Readthenexttime*/fscanf(file,%f,&rtime);/*readstimulus*/fscanf(file,%d%x\n,&dec,&hex);printf(“@%f%d%x\n”,rtime,dec,hex);}/*whilenotEOF*/fclose(file);}6-9SynopsysProfessionalServicesHTCWorkshop.Confidential©2002SynopsysProprietaryCompileFileI/OPackageCompilethefileI/OpackageMakesureyouhavethefollowingfileio.tabfilegcc-cfileio.c-I$VCS_HOME/`vcs-platform`/lib//file.tabforFileIOapplicationwithVCS$fopenacheck=fopen_checkcall=fopen_callmisc=fopen_miscsize=32data=1acc=rw:%TASK$fopenrcheck=fopen_checkcall=fopen_callmisc=fopen_miscsize=32data=2acc=rw:%TASK$fopenwcheck=fopen_checkcall=fopen_callmisc=fopen_miscsize=32data=3acc=rw:%TASK$fcloseacheck=fclose_checkcall=fclose_callsize=32data=1$fclosercheck=fclose_checkcall=fclose_callsize=32data=2$fclosewcheck=fclose_checkcall=fclose_callsize=32data=3$fgetscheck=fgets_checkcall=fgets_callsize=1acc=rw:%TASK$getscheck=gets_checkcall=gets_callsize=1acc=rw:%TASK$fgetccheck=fgetc_checkcall=fgetc_callsize=32acc=rw:%TASK$getcharcheck=getchar_checkcall=getchar_callsize=32acc=rw:%TASK$ungetccheck=ungetc_checkcall=ungetc_callsize=32$feofcheck=feof_checkcall=feof_callsize=32$ferrorcheck=ferror_checkcall=ferror_callsize=32$fscanfcheck=fscanf_checkcall=fscanf_callmisc=fscanf_miscsize=32acc=rw:%TASK$sscanfcheck=sscanf_checkcall=sscanf_callmisc=sscanf_miscsize=32acc=rw:%TASK$scanfcheck=scanf_checkcall=scanf_callmisc=scanf_miscsize=32acc=rw:%TASK$ftellcheck=ftell_checkcall=ftell_callsize=32$fseekcheck=fseek_checkcall=fseek_callsize=32$freadcheck=fread_checkcall=fread_callsize=32acc=rw:%TASK$sprintfcheck=sprintf_checkcall=sprintf_callmisc=sprintf_miscsize=32acc=rw:%TASK$fprintfcheck=fprintf_checkcall=fprintf_callmisc=fprintf_miscsize=32acc=rw:%TASK6-10SynopsysProfessionalServicesHTCWorkshop.Confiden