Professional Documents
Culture Documents
Module 5 FPGADesign
Module 5 FPGADesign
AltiumDesignerTrainingModule
FPGADesign
DocumentVersion1.2,February2008 Software,documentationandrelatedmaterials: Copyright2008AltiumLimited. Allrightsreserved.Youarepermittedtoprintthisdocumentprovidedthat(1)theuseofsuchisfor personaluseonlyandwillnotbecopiedorpostedonanynetworkcomputerorbroadcastinany media,and(2)nomodificationsofthedocumentismade.Unauthorizedduplication,inwholeorpart, ofthisdocumentbyanymeans,mechanicalorelectronic,includingtranslationintoanother language,exceptforbriefexcerptsinpublishedreviews,isprohibitedwithouttheexpresswritten permissionofAltiumLimited.Unauthorizedduplicationofthisworkmayalsobeprohibitedbylocal statute.Violatorsmaybesubjecttobothcriminalandcivilpenalties,includingfinesand/or imprisonment. Altium,AltiumDesigner,BoardInsight,CAMtastic,CircuitStudio,DesignExplorer,DXP,LiveDesign, NanoBoard,NanoTalk,Nexar,nVisage,PCAD,Protel,SimCode,Situs,TASKING,andTopological AutoroutingandtheirrespectivelogosaretrademarksorregisteredtrademarksofAltiumLimitedor itssubsidiaries. Microsoft,MicrosoftWindowsandMicrosoftAccessareregisteredtrademarksofMicrosoft Corporation.OrCAD,OrCADCapture,OrCADLayoutandSPECCTRAareregisteredtrademarksof CadenceDesignSystemsInc.AutoCADisaregisteredtrademarkofAutoDeskInc.HPGLisa registeredtrademarkofHewlettPackardCorporation.PostScriptisaregisteredtrademarkofAdobe Systems,Inc.Allotherregisteredorunregisteredtrademarksreferencedhereinarethepropertyof theirrespectiveownersandnotrademarkrightstothesameareclaimed.
Module1
ii
AltiumDesignerTrainingModule
FPGADesign
FPGADesignBasics
1 FPGADesign......................................................................................................... 11 1.1 Learningobjectives..................................................................................... 11 1.2 Topicoutline............................................................................................... 11 IntroductiontoFPGADesign ............................................................................... 12 2.1 FPGAbasics .............................................................................................. 12 CreatinganFPGAproject..................................................................................... 13 3.1 Overview.................................................................................................... 13 3.2 Aquickwordaboutprojectsanddesignworkspaces................................... 13 3.3 FPGAproject.............................................................................................. 14 FPGAschematicconnectivity.............................................................................. 15 4.1 Overview.................................................................................................... 15 4.2 Wiringthedesign........................................................................................ 15 4.3 IncludingHDLsourcefilesinaschematic................................................... 15 4.4 Establishingconnectivitybetweendocuments............................................. 15 4.5 Usingbusesandbusjoiners....................................................................... 16 FPGAreadyschematiccomponents ................................................................... 19 5.1 Overview.................................................................................................... 19 5.2 Processorcores ......................................................................................... 19 5.3 DesktopNanoBoardportplugins .............................................................. 110 5.4 PeripheralComponents ............................................................................ 110 5.5 Genericcomponents ................................................................................ 110 5.6 Vendormacroandprimitivelibraries......................................................... 110 5.7 Exercise1CreateaPWM...................................................................... 111 Targetingthedesign........................................................................................... 113 6.1 Constraintfiles ......................................................................................... 113 6.2 Configurations .......................................................................................... 114 6.3 NanoBoardconstraintfiles........................................................................ 114 6.4 ConfigurationManager ............................................................................. 114 6.5 AutoConfiguringanFPGAproject ............................................................ 115 6.6 Definingconstraintsmanually ................................................................... 115 6.7 Editingaconstraintfile.............................................................................. 116 6.8 Exercise2ConfiguringMyPWM............................................................. 117 Runningthedesign ............................................................................................ 119 7.1 Overview.................................................................................................. 119 7.2 Controllingthebuildprocess..................................................................... 119 7.3 Understandingthebuildprocess............................................................... 120 7.4 Buttonregions .......................................................................................... 120 7.5 Accessingstagereports/outputs ............................................................. 121 7.6 Buildstages.............................................................................................. 121 7.7 Configuringabuildstage .......................................................................... 124 7.8 HowAltiumDesignerinteractswithbackendvendortools........................ 125 7.9 Exercise3RunMyPWMontheNanoBoard........................................... 125 Embeddedinstruments ...................................................................................... 126 8.1 Overview.................................................................................................. 126 8.2 OnChipdebugging .................................................................................. 126 8.3 CLKGEN .................................................................................................. 127 8.4 CROSSPOINT_SWITCH.......................................................................... 127 8.5 FRQCNT2 ................................................................................................ 127
2 3
AltiumDesignerTrainingModule
FPGADesign
IOB_x....................................................................................................... 128 DIGITAL_IO ............................................................................................. 128 LAX_x ...................................................................................................... 129 TerminalConsole ..................................................................................... 131 Exercise4AUsingembeddedinstruments............................................. 131 WherearetheInstruments?..................................................................... 135 Enablingembeddedinstruments............................................................... 135
InteractingwiththeNanoBoard ......................................................................... 137 9.1 Overview.................................................................................................. 137 9.2 NanoBoardcommunications..................................................................... 137 9.3 Technicalbackground.............................................................................. 138 9.4 TheNanoBoardcontroller......................................................................... 140 9.5 FPGAI/Oview.......................................................................................... 141 9.6 Livecrossprobing .................................................................................... 142 9.7 Exercise4BViewMyPWMontheNanoBoard ....................................... 142 Creatingacorecomponent................................................................................ 143 10.1 Coreproject.............................................................................................. 143 10.2 CreatingacorecomponentfromanFPGAproject .................................... 143 10.3 AwordaboutEDIF ................................................................................... 144 10.4 Settingupthecoreproject ........................................................................ 144 10.5 Constrain/configure ................................................................................ 145 10.6 Creatinganewconstraintfile.................................................................... 146 10.7 Creatingaconfiguration............................................................................ 147 10.8 Synthesize............................................................................................... 148 10.9 Publish ..................................................................................................... 149 10.10 Creatingacoreschematicsymbol ............................................................ 149 10.11 Usingacorecomponent........................................................................... 151 10.12 Exercise5CreateacorecomponentfromMyPWM ............................... 152 FPGAdesignsimulation..................................................................................... 153 11.1 Creatingatestbench................................................................................ 153 11.2 AssigningtheTestbenchDocument.......................................................... 153 11.3 Initiatingasimulationsession ................................................................... 154 11.4 Projectcompileorder................................................................................ 154 11.5 Settingupthesimulationdisplay............................................................... 155 11.6 Runninganddebuggingasimulation ........................................................ 156 11.7 Exercise6CreateatestbenchandsimulateMyPWM ............................ 158 Review................................................................................................................. 159
10
11
12
ii
AltiumDesignerTrainingModule
FPGADesign
1 FPGADesign
Theprimaryobjectiveofthisdayoftrainingistomakeparticipantsproficientintheprocessof developing,downloadingandrunninganFPGAdesignontheDesktopNanoBoard.Wewillgo throughtheFPGAdesignframeworkanddemonstratejusthowsimpleFPGAdesigniswithAltium Designer.
1.1
Learningobjectives
1.2
Topicoutline
NanoBoard Concepts
FPGA Instruments
AdvancedTopics(TimePermitting)
FPGACore Components
.
Digital Simulation
Figure1.TopicOutlineforPartIFPGADesignBasics.
11
AltiumDesignerTrainingModule
FPGADesign
2 IntroductiontoFPGADesign
2.1 FPGAbasics
FPGA:FieldProgrammableGateArray.Conceptuallyitcanbeconsideredasanarrayof ConfigurableLogicBlocks(CLBs)thatcanbeconnectedtogetherthroughavastinterconnection matrixtoformcomplexdigitalcircuits.
Figure2.ExplodedviewofatypicalFPGA
FPGAshavetraditionallyfounduseinhighspeedcustomdigitalapplicationswheredesignstendto bemoreconstrainedbyperformanceratherthancost.Theexplosionofintegrationandreductionin pricehasledtothemorerecentwidespreaduseofFPGAsincommonembeddedapplications. FPGAs,alongwiththeirnonvolatilecousinsCPLDs(ComplexProgrammableLogicDevices),are emergingasthenextdigitalrevolutionthatwillbringaboutchangeinmuchthesamewaythat microprocessorsdid. Withcurrenthighenddevicesexceeding2000pinsandtoppingbillionsoftransistors,thecomplexity ofthesedevicesissuchthatitwouldbeimpossibletoprogramthemwithouttheassistanceofhigh leveldesigntools. Xilinx,Altera,Actel,andLatticeallofferhighendEDAtoolsuitesdesigned specificallytosupporttheirowndeviceshowevertheyalsoofferfreeversionsaimedatsupporting thebulkofFPGAdevelopment.Thesevendorsunderstandtheimportanceoftoolavailabilityto increasedsiliconsalesandtheyallseemcommittedtosupportingafreeversionoftheirtoolsforthe foreseeablefuture. ThroughtheuseofEDAtools,developerscandesigntheircustomdigitalcircuitsusingeither schematicbasedtechniques,VHDL,Verilogoranycombinationofthesemethods.Priortothe AltiumDesignersystem,vendorindependentFPGAdevelopmenttoolswereextremelyexpensive. FurthermoretheywereonlyusefulforcircuitsthatresidedwithintheFPGAdevice.Oncethedesign wasextendedtoincludeaPCBandancillarycircuits,aseparateEDAtoolwasneeded.Altium DesignerhaschangedallofthisbybeingthefirstEDAtoolcapableofofferingcompleteschematic toPCBtoolintegrationalongwithmultivendorFPGAsupport. AltiummadethelogicalextrapolationoftrendsintheFPGAworldandrecognizedthatFPGAsare quicklybecomingastapleinmoderndesigns.Bymakingavailablearangeofprocessorcoresthat canbedownloadedontoanFPGAdeviceandbundlingthemwithacompletesuiteofembedded softwaredevelopmenttools,AltiumDesignerrepresentsaunifiedPCBandembeddedsystems developmenttool.
12
AltiumDesignerTrainingModule
FPGADesign
3 CreatinganFPGAproject
3.1 Overview
AllcomponentsthatwillbecombinedtogetherintoasingleFPGAdesignmustbeencapsulated withinanFPGAProject. ThetermProjectreferstoagroupofdocumentsthatcombinetogethertoformasingletarget. Caremustbeexercisedwhencreatingaprojecttoensurethatthecorrectprojecttypeisselectedfor thedesiredtarget.
3.2
Aquickwordaboutprojectsanddesignworkspaces
Totheuninitiated,AltiumDesignerprojectsmayappearalittle confusingespeciallywhenprojectscontainotherprojects. Theimportantthingtorememberisthateachprojectcanonly haveoneoutput.Ifyouhaveadesignthatrequiresseveral PCBsthenyouwillneedaseparatePCBprojectforeach PCB.IfyouhaveadesignthatusesseveralFPGAsthenyou willalsoneedaseparateFPGAprojectforeachFPGAused onthefinaldesign. Projectsthatarerelatedtogetherinsomewaycanbegrouped togetherusingatypeofsuperprojectcalledaDesign Workspace.DesignWorkspacesaresimplyaconvenient wayofpackagingoneormoreprojectstogethersothatall projectsfromasingledesigncanbeopenedtogether. AltiumDesignersupportsafullyhierarchicaldesignapproach. Assuchitispossibleforsomeprojectstocontainother projectswithinthem. Figure3showsastructuralviewofthe SpiritLeveldesignthatisdistributedasanexampleinthe AltiumDesignerinstallation.Fromthisviewwecanobserve thehierarchyofthedifferentprojectsinvolved.Thetoplevel projectisaPCBprojectcalledSL1XilinxSpartanIIE Figure3.Anexampleofprojecthierarchy. PQ208Rev1.01 andhasthefilenameextensionPRJFPG. WithinthisPCBprojectisaninstanceofanFPGAProject FPGA_51_Spirit_Level.PrjFpg.RunningontheFPGAisa softcoreprocessor8051.Theprogramorsoftwarethatthisembeddedsoftcoreexecutesis containedwithinanotherprojectcalledSpiritLevel.PrjEmb. Thehierarchyofprojectsisgivenbelow.
PRJPCB PCBProject OutputisasinglePCB
PRJFPG
FPGAProject
PRJEMB
EmbeddedProject
Figure4.PossibleProjectHierarchyforadesigncontainingmultipleprojects
AltiumDesignerTrainingModule
FPGADesign
3.3
FPGAproject
Figure5.CreatinganewFPGAproject
14
AltiumDesignerTrainingModule
FPGADesign
4 FPGAschematicconnectivity
4.1 Overview
SchematicdocumentsusedinFPGAdesignsareconvertedtoeitherVHDLorVerilogintheprocess ofbeingcompiledintothedesign.Thisprocessistotallytransparenttotheuseranddoesnot requiretheusertoknowanythingspecificabouteitherofthesetwoHardwareDescription Languages(HDLs).ThisconversiontoHDLsdoesplacesomerequirementsontotheschematic documenthoweverthatmustbeconsideredtoensurethattheconversionprocessgoessmoothly andthattheresultantHDLsourcefileisvalid. Inthissectionwewilldiscusssomeoftheextensionsthathavebeenaddedtotheschematic environmentforthepurposesofservicingFPGAdesigns.
4.2
Wiringthedesign
4.3
IncludingHDLsourcefilesinaschematic
Figure6.Linkingschematicsheetsymbolstolowerleveldocuments
4.4
Establishingconnectivitybetweendocuments
AltiumDesignerTrainingModule
FPGADesign
Figure7.Connectivitybetweensheetsymbolsandlowerleveldocuments
4.5
Usingbusesandbusjoiners
U8 PORTA[7..0] O[7..0] IB[3..0] GND KEY[3..0]
IA[3..0] J4B2_8B
Busescanbereordered, PORTB[7..0] O[7..0] U9 I0 renamed,split,andmerged.To I1 I2 managethemappingofnetsin I3 buses,thereisaspecialclassof I4 component,knownasabus I5 joiner.Busjoinerscanbeplaced I6 I7 fromtheFPGA J8S_8B Generic.IntLiblibrary(bus joinernamesallstartwiththe Figure8.Examplesofusingbusjoiners letterJ).Figure8showsexamples ofusingbusjoiners.Thereare alsomanyexamplesofusingbusjoinersintheexampledesignsinthesoftware.
LCD_BUSY VALIDKEY
GND
4.5.1 Busjoinernamingconvention
Busjoinersfollowastandardizednamingconventionsothattheycanbeeasilyfoundwithinthe FPGAGeneric.IntLiblibrary. J<width><B/S>[Multiples]_<width><[B/S]>[Multiples] Forexample: J8S_8B:describesabusjoinerthatroutes8singlewirestoasingle,8bitbus. J8B_8S:describesabusjoinerthatroutesasingle,8bitbusinto8singlewires. J8B_4B2:describesabusjoinerthatroutesasingle8bitbusintotwo4bitbusses, J4B4_16B:describesabusjoinerthatroutesfour,4bitbussesintoasingle16bitbus.
16
AltiumDesignerTrainingModule
FPGADesign
4.5.2 Busjoinersplitting/mergingbehaviour
Thebasicruleisthatbusjoinersseparate/mergethebits(orbusslice) fromleastsignificantbit(orslice)downtomostsignificantbit(orslice). Forexample,inFigure9,U17splitstheincoming8bitbusonpinI[7..0] intotwo4bitbusslices,OA[3..0]andOB[3..0].Obeyingtheleasttomost mappingattheslicelevel,thelowerfourbitsoftheinputbusmapto OA[3..0],andtheupperfourbitsmaptoOB[3..0].Followingthisthroughto thebitlevel,I0willconnecttoOA0,andI7willconnecttoOB3. ThejoinerU27mergesthefourincoming4bitslicesintoa16bitbus.With thisjoinerIA0connectstoO0,andID3connectstoO15.
Figure9.Busjoiners
Figure10.Joinbusesofdifferentwidths,andcontrolthenettonetmapping
Figure11.AnexampleofusingtheJBbusjoinertoachievesubsetmapping
Ifbothbusrangesaredescending,matchbysamebusindex(onerangemustliewithintheother forvalidconnections).InFigure11thematchingis:
(InthisexampleROMADDR10thruROMADDR13willbeunconnected)
Figure12.Usingofabusjoinerforoffsetmapping
InFigure12thematchingis:
INPUTS15 INPUTS0
17
AltiumDesignerTrainingModule
FPGADesign
Figure13.Usingabusjoinerforrangeinversion
Ifonebusrangeisdescendingandanotherisascending,theindicesarematchedfromleftto right.InFigure13thematchingis:
Figure14.Anotherexampleofusingabusjoinerforrangeinversion
InFigure14thematchingis:
INPUTS15 INPUTS0
18
AltiumDesignerTrainingModule
FPGADesign
5 FPGAreadyschematiccomponents
5.1 Overview
AwidevarietyofFPGAreadyschematic componentsareincludedwiththesystem,ranging fromprocessors,toperipheralcomponents,down togenericlogic.Placingandwiringthese schematiccomponents,orwritingVHDL,captures thehardwaredesign.TheFPGAreadyschematic componentsareliketraditionalPCBready components,exceptinsteadofthesymbolbeing linkedtoaPCBfootprinteachislinkedtoapre synthesizedEDIFmodel. Aswellascomponentsthatyouusetoimplement yourdesign,theavailableFPGAlibrariesinclude componentsforthevirtualinstruments,andthe componentsthataremountedontheNanoBoard andareaccessibleviathepinsontheFPGA. HelpforallFPGAreadycomponentscanbe accessedbypressingtheF1keywhilstthe componentisselectedinthelibrarylist.
5.2
Processorcores
Softcoreprocessorscanbeplacedfromthe \ProgramFiles\AltiumDesigner 6\Library\Fpga\FPGAProcessors.IntLib library.Atthetimeofreleaseofthismanual,the followingprocessorsandrelatedembedded softwaretoolsaresupported: TSK165Microchip165xfamilyinstructionset compatibleMCU TSK51/528051instructionsetcompatible MCU TSK80Z80instructionsetcompatibleMCU PPC405AEmbeddedPowerPCCore availableonsomeVirtexFPGAs TSK300032bitRISCprocessor Thereisalsofullembeddedtoolsupportfor: ActelCoreMP7softcore,whichrequiresthe appropriateActeldeviceandlicensetouse AlteraNiosIIsoftcore,whichrequiresthe appropriateAlteradeviceandlicensetouse XilinxMicroBlazesoftcore,whichrequiresthe appropriateXilinxdeviceandlicensetouse XilinxVirtex2ProbasedPowerPC405 AMCCPowerPC405discreteprocessorfamily ARM7,ARM9,ARM9E&ARM10Efamilies,supportedintheSharpBlueStreak(ARM20T) discreteprocessorfamily LPC2100,LPC2200,LPC2300&LPC2800ARM7baseddiscreteprocessorsfromNXP
Figure15.Thelibrariespanel
19
AltiumDesignerTrainingModule
FPGADesign
5.3
DesktopNanoBoardportplugins
5.4
PeripheralComponents
5.5
Genericcomponents
Genericcomponentscanbeplacedfromthelibrary \ProgramFiles\AltiumDesigner 6\Library\Fpga\FPGAGeneric.IntLib.This libraryisincludedtoimplementtheinterfacelogic inyourdesign.Itincludespinwideandbuswide versionsformanycomponents,simplifyingthe wiringcomplexitywhenworkingwithbuses.Aswell asabroadrangeoflogicfunctions,thegeneric libraryalsoincludespullupandpulldown componentsaswellasarangeofbusjoiners,used tomanagethemerging,splittingandrenamingof buses. Foradefinitionofthenamingconventionusedin thegenericlibraryandacompletelistingof availabledevices,refertothedocument:CR0118 FPGAGenericLibraryGuide.pdf. Wildcardcharacterscanbeusedtofilterwhen searchingthecomponentlibrary.
5.6
Vendormacroand primitivelibraries
Ifvendorindependenceisnotrequired,thereare alsocompleteprimitiveandmacrolibrariesforthe currentlysupportedvendors/devicefamilies.These librariescanbefoundintherespectiveActel, Altera,LatticeandXilinxsubfoldersin\Program Files\AltiumDesigner6\Library\.The macroandprimitivelibrarynamesendwiththe Figure16.Usingwildcardstoquicklyfindaspecific string*FPGA.IntLib.Notethatsomevendors componentintheGenericLibrary requireyoutouseprimitiveandmacrolibrariesthat matchthetargetdevice.Designsthatinclude vendorcomponentscannotberetargetedto anothervendorsdevice.
110
AltiumDesignerTrainingModule
FPGADesign
5.7
Exercise1CreateaPWM
Library FPGANB2DSK01PortPlugin.IntLib
NameinLibrary CLOCK_BOARD
TEST_BUTTON
FPGANB2DSK01PortPlugin.IntLib
TEST_BUTTON
ON
SW[7..0]
1 2 3 4 5 6 7 8
LEDS[7..0]
U1 CB8CEB Q[7..0] CE C CEO TC CLR
U2
FPGAGeneric.IntLib
INV
INV
FPGAGeneric.IntLib
GT LT
COMPM8B
FPGAGeneric.IntLib
O[7..0]
J8S_8B
J8S_8B
1. 2. 3. 4.
111
AltiumDesignerTrainingModule
FPGADesign
SW[7..0]
1 2 3 4 5 6 7 8
J8S_8B
GND
Figure17.Saveyourwork wewillcontinuewiththisschematicsoon
112
AltiumDesignerTrainingModule
FPGADesign
6 Targetingthedesign
Theschematicthatwehavejustcreatedcontainsalloftheconnectivitythatmustoccurinternallyon ourFPGAdevicebutwestillneedsomefurtherinformationtomaptheportsontheFPGAschematic tophysicalpinsonanactualFPGAdevice.Thisprocessiscalledtargetingourdesign.
6.1
Constraintfiles
Figure18.ConceptualviewshowingthelinkageofportsonanFPGAschematicroutedtophysicaldevicepins.
113
AltiumDesignerTrainingModule
FPGADesign
6.2
Configurations
6.2.1 Deviceandboardconstraintinformation:
ThespecificFPGAdevicemustbeidentifiedandportsdefinedinthetoplevelFPGAdesignmustbe mappedtospecificpinnumbers.
6.2.2 Deviceresourceconstraintinformation:
Insomedesignsitmaybeadvantageoustomakeuseofvendorspecificresourcesthatareunique toagivenFPGAdevice.Someexamplesarehardwaremultiplicationunits,clockmultipliersand memoryresources.
6.2.3 Projectordesignconstraintinformation:
Thiswouldincluderequirementswhichareassociatedwiththelogicofthedesign,aswellas constrainsonitstiming.Forexample,specifyingthataparticularlogicalportmustbeallocatedto globalclocknet,andmustbeabletorunatacertainspeed.
6.3
NanoBoardconstraintfiles
6.4
ConfigurationManager
Figure19.ConfigurationManagershowingmultipleconfigurationsandconstraintfiles.
114
AltiumDesignerTrainingModule
FPGADesign
6.5
AutoConfiguringanFPGAproject
Configuringadesignforuse withtheDesktopNanoBoard hasbeenalmostcompletely automatedwiththeintroduction oftheAutoConfigurationoption inAltiumDesigner.Fromthe DevicesViewlocatedunder ViewDevicesViewor alternativelyaccessedfromthe iconinthetoolbar,simply rightclicktheimageofthe DesktopNanoBoardandselect theoptionConfigureFPGA Project<ProjectName>.
Figure20.AutoconfiguringanFPGA
Figure21.Autoconfigurationdisplayedintheconfigurationmanager
6.6
Definingconstraintsmanually
Figure22.Newblankconstraintfile
115
AltiumDesignerTrainingModule
FPGADesign
6.7
Editingaconstraintfile
Figure23.Add/ModifyConstraintmenuoptions
6.7.1 Specifyingportconstraints
UsetheAdd/ModifyConstraintPortto applyaconstrainttoaportintheFPGA project.
Figure24.Add/ModifyPortConstraintdialogbox.
SelectingOKfromthedialogboxinFigure24willcausethefollowingconstrainttobeaddedtothe constraintfile:
Record=Constraint|TargetKind=Port|TargetId=CLK_BRD|FPGA_CLOCK_PIN=True
Figure25.Add/ModifyPortConstraintdialogbox.
116
AltiumDesignerTrainingModule
FPGADesign
6.8
Exercise2ConfiguringMyPWM
buttoninthe
1. SwitchtotheDevicesViewunderViewDevicesViewsorbyhittingthe toolbaratthetopofthescreen.
2. RightClicktheimageofthe DesktopNanoboardatthetop ofthewindowandselect ConfigureFPGA ProjectMyPWM.PrjFpgas seeninFigure26. Becausewearetargetingour designfortheDesktop NanoBoard,wewillbeusing existingconstraintfiles locatedintheAltiumDesigner 6\Library\FPGAdirectory. Whenweelecttoauto configureaswehaveinthis Figure26.ConfiguringtheFPGAProjectAutomatically fashion,AltiumDesignerwill retrieveinformationaboutthe daughterboardandvariousperipheralboardsthatwehavepluggedintotheDesktop NanoBoardandaddconstraintfilesasrequired. 3. AfterlaunchingtheConfigureFPGAProjectcommand,theConfigurationManagerFor MyPWM.PRJFPGdialogshouldcomeupandshowalistingofalloftheconstraintsfilesthat havebeenautomaticallyincludedunderthisnewconfiguration.
Figure27.ConfigurationManagerwithconstraintfilesaddedbytheConfigureFpgaProjectcommand.
Figure28.BuildflowafterautoconfiguringtheFPGAdesign.
117
AltiumDesignerTrainingModule
FPGADesign
4. TheautoconfigurationprocessdealswiththemappingofportsdefinedonthetoplevelFPGA schematicdocumentandtheirtargetFPGApins.Thereare,however,additionalconstraints (suchastheclockfrequency)thatareimportantforthedesignbutwhichcannotbehandled automatically.Inordertocapturethisinformation,itisbesttocreateanotherconstraintfilethat isreservedforthisinformationandaddittotheconfiguration.RightclicktheFPGAproject andselectAddNewtoProjectConstraintFiletoaddanew,blankconstraintfile. 5. 6. 7. 8. SavethenewconstraintfilewiththenameMyConstraint.constraint SelectDesign>>Add/ModifyConstraint>>Port . IntheAdd/ModifyPortConstraintdialogsettheTargettoCLK_BRD SettheConstraintKindtoFPGA_CLOCK_FREQUENCY
9. SettheConstraintValueto50MHz. 10. ClickOKtoclosetheAdd/ModifyPortConstraintdialog. 11. ObservethatanewconstraintrecordhasbeenaddedtoMyConstraints.Constraint. 12. Saveyourwork. 13. ReturntotheConfigurationManagerandaddMyConstraint.Constrainttotheexisting configuration. 14. Saveyourproject.
118
AltiumDesignerTrainingModule
FPGADesign
7 Runningthedesign
HavingjustconfiguredourdesignfortheNanoBoardthenextstepistobuildandrunthedesignon theNanoBoard.
7.1
Overview
7.2
Controllingthebuildprocess
Figure29.DevicesviewofanFPGAdesignthatisyettobeprocessed.
Figure30.ThismessageindicatesthattheprojectisnotconfiguredtotargettheavailableFPGA.
119
AltiumDesignerTrainingModule
FPGADesign
7.3
Understandingthebuildprocess
Figure31.NavigatingthroughtheBuildProcessflow.
7.4
Buttonregions
Eachofthemainbuttonsdisplayedinthebuildflowhaveseveralregionsthatprovideinformationor controlovertheindividualbuildstage.
7.4.1 StatusLED
Thecoloredindicatortellsyouthestatusofthatparticularstepintheoverallbuildflow.
Grey Red Yellow NotAvailableThesteporstagecannotberun. MissingThesteporstagehasnotbeenpreviouslyrun. OutofDateAsourcefilehaschangedandthesteporstagemustberunagaininorder toobtainuptodatefile(s). RunningThesteporstageiscurrentlybeingexecuted. CancelledThesteporstagehasbeenhaltedbyuserintervention. FailedAnerrorhasoccurredwhilerunningthecurrentstepofthestage. UptoDateThesteporstagehasbeenrunandthegeneratedfile(s)areuptodate.
7.4.2 Runall
7.4.3 Run
120
AltiumDesignerTrainingModule
FPGADesign
7.4.4 Showsubstages
Figure32.Substagesavailableunderthemainbuildstage.
7.5
Accessingstagereports/outputs
7.6
Buildstages
Wewillnowexplainthedifferentstagesinthebuildprocess.
7.6.1 Compile
Figure33.Compilestageoftheprocessflow.
121
AltiumDesignerTrainingModule
FPGADesign
7.6.2 Synthesize
Figure34.Synthesizestageoftheprocessflow.
ThisstageoftheprocessflowisusedtosynthesizethecompiledFPGAproject,aswellasanyother componentsthatneedtobegeneratedandsynthesizedtospecificdevicearchitectures.Thevendor placeandroutetoolssubsequentlyusethesynthesisfilesgenerated,duringthebuildstageofthe flow.Runningthisstagewilldeterminewhetherthedesignissynthesizableornot. ThisstagecanberunwiththeDevicesviewconfiguredineitherLiveorNotLivemode. TheactualstepsinvolvedinprovidingatoplevelEDIFnetlistandsatellitesynthesismodelfilesfor usebythenextstageintheprocessflowcanbesummarizedasfollows: Thecoresforanydesign/devicespecificblocksusedintheFPGAdesignwillbeautogenerated andsynthesized(e.g.ablockofRAMwiredtoanOCDversionmicrocontrollerforuseas externalProgrammemoryspace).Thesesynthesizedmodelswillcontaincompiledinformation fromtheembeddedproject(Hexfile). ThemainFPGAdesignisthensynthesized.AnintermediateVHDLorVerilogfilewillbe generatedforeachschematicsheetinthedesignandatoplevelEDIFnetlistwillbecreated usingtheseandanyadditionalHDLsourcefiles. Fortheparticularphysicaldevicechosen,synthesizedmodelfilesassociatedwithcomponentsin thedesignwillbesearchedforandcopiedtotherelevantoutputfolder.BothSystemandUser presynthesizedmodelsaresupported. ThetoplevelfolderforSystempresynthesizedmodelsisthe\ProgramFiles\Altium Designer6\Library\Ediffolder,whichissubdividedbyVendorandthenfurtherbydevice family. ThetoplevelfolderforuserpresynthesizedmodelsisdefinedintheSynthesispageofthe FPGAPreferencesdialog,accessedundertheTools menu. Thefollowinglistsummarizestheorder(toptobottom=firsttolast)inwhichfoldersaresearched whenlookingforasynthesizedmodelassociatedwithacomponentinthedesign:
FPGAprojectfolder Usermodelstopfolder\Vendorfolder\Familyfolder Usermodelstopfolder\Vendorfolder Usermodelstopfolder Systemmodelstopfolder(Edif)\VendorFolder\Familyfolder Systemmodelstopfolder(Edif)\Vendorfolder Systemmodelstopfolder(Edif).
7.6.3 Build
Figure35.BuildstageoftheprocessflowforXilinxdevices.
Thisstageoftheprocessflowisusedtorunthevendorplaceandroutetools.Thisstagecanberun withtheDevicesviewconfiguredineitherliveornotlivemode.
122
AltiumDesignerTrainingModule
FPGADesign
Runningthetoolsatthisstagecanverifyifadesignwillindeedfitinsidethechosenphysicaldevice. YoumayalsowishtoruntheVendortoolsifyouwanttoobtainpinassignmentsforimportingback intotherelevantconstraintfile. TheendresultofrunningthisstageisthegenerationofanFPGAprogramming filethatwill ultimatelybeusedtoprogramthephysicaldevicewiththedesign.Thereareessentiallyfivemain stagestothebuildprocess: TranslateDesignusesthetoplevelEDIFnetlistandsynthesizedmodelfiles,obtainedfrom thesynthesisstageoftheprocessflow,tocreateafileinNativeGenericDatabase(NGD)format i.e.vendortoolprojectfile MapDesigntoFPGAmapsthedesigntoFPGAprimitives PlaceandRoutetakesthelowleveldescriptionofthedesign(fromthemappingstage)and worksouthowtoplacetherequiredlogicinsidetheFPGA.Oncearranged,therequired interconnectionsarerouted TimingAnalysisperformsatiminganalysisofthedesign,inaccordancewithanytiming constraintsthathavebeendefined.Iftherearenospecifiedconstraints,defaultenumerationwill beused MakeBitFilegeneratestheprogrammingfilethatisrequiredfordownloadingthedesigntothe physicaldevice. WhentargetingaXilinxdevice,anadditionalstageisavailableMakePROMFile.Thisstageis usedwhenyouwanttogenerateaconfigurationfileforsubsequentdownloadtoaXilinx configurationdeviceonaProductionboard. AftertheBuildstagehascompleted,theResultsSummarydialogwillappear(Figure36).This dialogprovidessummaryinformationwithrespecttoresourceusagewithinthetargetdevice. Informationcanbecopiedandprintedfromthedialog.Thedialogcanbedisabledfromopening, shouldyouwish,astheinformationisreadilyavailableintheOutputpanelorfromthereportfiles producedduringthebuild.
Figure36.Summarizingresourceusageforthechosendevice.
123
AltiumDesignerTrainingModule
FPGADesign
7.6.4 Program
Thisstageoftheprocessflowisusedto downloadthedesignintothephysical FPGAdeviceonaNanoBoardorproduction board.Thisstageisonlyavailablewhenthe DevicesviewisconfiguredinLivemode.
Figure37.ProgramFPGAstageoftheprocessflow.
Thisstageoftheflowcanonlybeused oncethepreviousthreestageshavebeen runsuccessfullyandaprogrammingfilehas beengenerated.Agreenarrowwillpointto thedevicetobeprogrammedintheHard DevicesChain. Astheprogrammingfileisdownloadedto thedeviceviatheJTAGlink,theprogress willbeshownintheStatusbar.Once successfullydownloaded,thetext underneaththedevicewillchangefrom ResettoProgrammed(Figure38)and anyNexusenableddevicesonthesoft chainwillbedisplayedasRunning(Figure 39).
Figure38.SuccessfulprogrammingofthephysicalFPGAdevice.
Figure39.Softdevicesrunningaftersuccessfulprogramdownload.
7.7
Configuringabuildstage
Shouldyouwishtoconfigureanyofthespecificoptionsassociated witheachofthedifferentsubstagesintheFPGAbuildflow,youcan dosobyclickingontheappropriateconfigurationicon. ConsiderthecasewhereyouwanttogenerateaPROMfilefor subsequentdownloadtoaXilinxconfigurationdeviceonaproduction board.IntheprocessflowassociatedtothetargetedFPGAdevice, expandthebuildsection.ThelastentryinthebuildmenuisMake PROMFile Clickingonthe icon,tothefarrightofthismenuentry,willopen theOptionsforPROMFileGenerationdialog(Figure41).From hereyoucanchoosethenonvolatileconfigurationdevicethatwillbe usedbytheproductionboardtostoretheFPGAconfiguration.
Figure41.AccessingtheoptionsdialogforPROMfilegeneration.
124
AltiumDesignerTrainingModule
FPGADesign
7.8
HowAltiumDesignerinteractswithbackendvendortools
IfyouarealreadyfamiliarwiththebuildflowsofferedbyAlteraandXilinx,youwillbefamiliarwith oneorbothofthefollowingpanels:
Figure42.Xilinx(left)andAltera(right)vendortoolinterfaces.
AlthoughAltiumDesignerhasitsownHDLsynthesizer,itisreliantonbackendvendortoolsto implementthedesignonaspecificdevice.Thismakessense,asitisthedevicevendorswhohave themostintimateknowledgeoftheirspecificdevicesandwhohavealreadydevelopedwellproven targetingtechnologies. Mostvendorspecifictoolshavebeendevelopedinamodularfashionandcontainanumberof separateexecutableprogramsforeachphaseoftheimplementationprocess.ThevendorGUIsthat arepresentedtotheuserarecocoordinatingprogramsthatsimplypasstheappropriateparameters tobackend,commandlineprograms. WhenitcomestoFPGAtargeting,AltiumDesigneroperatesinasimilarfashioninthatitactsasa coordinatorofbackend,vendorspecificprograms.Parametersthatneedtobepassedfromthe AltiumDesignerfrontendtothevendorspecificbackendprogramsarehandledbyaseriesoftext basedscriptfiles.Userswhoarealreadyfamiliarwiththebackendprocessingtoolsmayfindsome useinaccessingthesescriptfilesshouldtheywishtomodifyortweakinteractionwithbackend processingtools.Thishoweverisconsideredahighlyadvancedtopicandonethatshouldbe handledcautiously.Ensurebackupsaretakenpriortomodification. ThefilescontrollinginteractionwithvendorspecificbackendtoolscanbefoundintheSystem directoryundertheAltiumDesigner6installdirectory.Thenamingconventionusedforthese filesis: Device[Options|Script]_<vendor>[_<tool>|<family>].txt soforexampleDeviceOptions_Xilinx_PAR.txtcontrolsthedefaultoptionsforXilinxsPlace andRoutetool.
7.9
Exercise3RunMyPWMontheNanoBoard
125
AltiumDesignerTrainingModule
FPGADesign
8 Embeddedinstruments
8.1 Overview
SofarwehavebuiltourPWMFPGAdesignandrunitontheNanoBoard.Fortunatelythisdesign providedanoutputontheLEDsthatenabledustoimmediatelyverifythatthecircuitwasperforming asweexpected.Buthowdoweverifyotherdesigns?Inthissectionwewillintroducetherangeof embeddedinstrumentsthatcanbeintegratedintoFPGAdesignstofacilitateonchiptestingand debugging.
8.2
OnChipdebugging
AbigconcernofmanyembeddedsystemsdesignerstransitioningtoFPGAbaseddesignisthe issueofdebugginghowdoesoneseeinsideanFPGAcircuittodiagnoseafault?Whattheymay notbeawareofisthattheflexibilityofFPGAdevicesenablestypicaltestandmeasurement instrumentstobewiredinsidethedeviceleadingtofareasierdebuggingthanwhathaspreviously beenpossible. TheAltiumDesignersystemincludesahostofvirtualinstrumentsthatcanbeutilizedtogain visibilityintothehardwareandquicklydiagnoseelusivebugs.Theseinstrumentscanbefoundin theFPGAInstruments.IntLibintegratedlibrary.Thehardwareportionoftheinstrumentis placedandwiredontheschematiclikeothercomponents.Oncethedesignhasbeenbuilt,realtime interactionwitheachinstrumentispossiblefromtheDevicesView.
Figure43.Embeddedinstrumentsdisplayedinthedevicesview.
Thecontrolsfortheindividualembeddedinstrumentscanbeaccessedbydoubleclickingtheir associatediconintheDevicesView.
126
AltiumDesignerTrainingModule
FPGADesign
8.3
CLKGEN
Figure44.Frequencygenerator,usedtogeneratethespecifiedfrequency
Thefrequencygeneratoroutputsa50%dutycyclesquare U7 wave,ofthespecifiedfrequency.Clickingtheappropriate buttoncanchooseanumberofpredefinedfrequencies,ora TIMEBASE FREQ customfrequencycanbeselectedusingtheOtherFrequency button.Ifthespecifiedfrequencycannotbegeneratedthe FrequencyGenerator closestpossibleisgeneratedandtheerrorshownonthe CLKGEN display.Notethatwhenthefrequencygeneratorisinstantiated intheFPGAitwillnotberunning,youmustclicktheRunbuttontogenerateanoutput.
8.4
CROSSPOINT_SWITCH
Figure45.Crosspointswitch,usedtocontroltheconnectionbetweeninputandoutputsignals
U18 CrosspointSwitch AIN_A[7..0] AOUT_A[7..0] AIN_B[7..0] AOUT_B[7..0] BIN_A[7..0] BIN_B[7..0] CROSSPOINT_SWITCH BOUT_A[7..0] BOUT_B[7..0]
8.5
FRQCNT2
Figure46.Frequencycounter,usedtomeasurefrequencyinthedesign
127
AltiumDesignerTrainingModule
FPGADesign
8.6
IOB_x
Figure47.DigitalIOmodule,usedtomonitorandcontrolnodesinthedesign
ThedigitalI/Oisageneralpurposetoolthatcanbeusedfor bothmonitoringandactivatingnodesinthecircuit.Itis availableineither8bitwideor16bitwidevariants,with1to 4channels. EachinputbitpresentsasaLED,andthesetof8or16bits alsopresentsasaHEXvalue.Outputscanbesetorcleared individuallybyclickingtheappropriatebitintheOutputsdisplay.AlternativelytypinginanewHEX valueintheHEXfieldcanaltertheentirebyteorword.IfaHEXvalueisenteredyoumustclickthe buttontooutputit.TheSynchronizebuttoncanbeusedtotransferthecurrentinputvaluetothe outputs.
8.7
DIGITAL_IO
Figure48.ConfigurableDigitalIOmodule,usedtomonitorandcontrolnodesinthedesign
128
AltiumDesignerTrainingModule
FPGADesign
8.8
LAX_x
Thelogicanalyzerallowsyoutocapturemultiplesnapshotsofmultiplenodesinyourdesign.Use theLAXtomonitormultiplenetsinthedesignanddisplaytheresultsasadigitalorananalog waveform. TheLAXisaconfigurablecomponent.Configureittosimultaneouslycapture8,16,31or64bits. Thenumberofcapturesnapshotsisdefinedbytheamountofcapturememorythisrangesfrom1K to4Kofinternalstoragememory(usinginternalFPGAmemoryresources).Itcanalsobeconfigured touseexternalmemory.ThisrequiresyoutowireittoFPGAmemoryresourcesortooffchip memory(e.g.DesktopNanoBoardMemory). AfterplacingtheconfigurableLAXfromthelibrary,rightclickonthesymbolandselectConfigure fromthefloatingmenutoopentheConfigure(logicanalyzer)dialog,whereyoucandefinethe Capturewidth,memorysizeandthesignalsets. TheConfigurableLAXincludesaninternalmultiplexer,thisallowsyoutoswitchfromonesignalset toanotheratruntime,displayingthecapturedataofinterest.Youcanalsotriggeroffonesignalset whileobservingtheresultsofanotherset. NotethattheFPGAInstrumentslibraryincludesanumberofLAXcomponents.TheLAX componentistheconfigurableversion,allothersarelegacyversions. 129
AltiumDesignerTrainingModule
FPGADesign
8.8.1 Waveformdisplayfeatures
Figure50.Digitalwaveformcaptureresultsfromthelogicanalyzer
Figure51.Analogwaveformcaptureresultsfromthelogicanalyzer
8.8.2 Zoominginandout
InboththeanaloganddigitalwaveformviewersitispossibletozoominandoutbyhittingthePage UporPageDownkeysrespectively
8.8.3 Continuousdisplaymode
Waveformscapturedbythelogicanalyzercanbedisplayedasasinglepassorasacontinuously updateddisplay.Continuousupdatescanbeenabled/disabledfromthelogicanalyzertoolbar.
Figure52.Enablingthecontinuouscapturemode.
130
AltiumDesignerTrainingModule
FPGADesign
8.9
TerminalConsole
Figure53.Terminalconsoleinstrumentrackfunctionsasadebugconsoleforembeddedapplications.
TheTERMINALdeviceisadebugconsolewhichallowsyoutotypetext directlyinitsassociatedinstrumentpanelandsenditdirectlytothe processorinyourdesign,tobehandledbytheembeddedsoftwarecode runningtherein.Conversely,itallowsthedisplayoftextsentfromthat processor. AlthoughclassedasoneofAltiumDesigner'svirtual instruments,theTERMINALdeviceisreallyahybrid partinstrumentand partWishbonecompliantslaveperipheral.Whereasotherinstrumentsare configuredandoperateddirectlyfromaGUI,theTERMINALdevice requiresinteractionatthecodelevel,toinitializeinternalregistersandto writeto/readfromitsinternalstoragebuffers.
U1 TerminalConsole STB_I CYC_I ACK_O ADR_I[3..0] DAT_O[7..0] DAT_I[7..0] WE_I CLK_I RST_I INT_O[1..0] TERMINAL
8.10
Exercise4AUsingembeddedinstruments
FrequencyGenerator CLKGEN
1Chx8BitDigitalIO IOB_1X8
. . .
Figure54.PWMcircuitwithseveralembeddedinstrumentsconnected.
1. OpentheprovidedprojectanddownloadittoyourNanoBoard. 2. Followonyourowncircuitastheinstructordiscussesthevariousembeddedinstruments.
131
AltiumDesignerTrainingModule
FPGADesign
3. DoubleclicktheNanoBoardiconintheDevicesViewtoopentheinstrumentrackforthe NanoBoardandsetitsclockfrequencyto50MHz.
Figure55.NanoBoardcontroller.
4. Openthefrequencygenerators instrumentpanel.Ifthetimebase indicatedinthewindownexttothe SetTimeBasebuttonisnot50 MHzthenpresstheSetTime Basebuttontoopenadialogbox thatwillenableyoutosetit correctly.TheRequire50/50 Dutycheckboxshouldbe checked. Thefrequencygeneratorshould besetto1MHzasindicatedin Figure.
Figure56.Counteroptionsdialog
Figure57.FrequencygeneratorPanel
5. Openthefrequencycounters instrumentpanel.Selectthe CounterOptionsbuttononthe frequencycountermoduleand makesuretheCounterTimeBase isalsosetto50MHz(thesameas theNanoBoardclockfrequency), asshowninFigure57.PressOK. UsetheModebuttonasnecessary oneachchannelofthefrequency countermoduletotogglethe displaymodebetweenfrequency, periodorcount.Youshouldgeta similardisplaytowhatisdepicted inFigure59.
Figure58.Counteroptionsdialog
132
AltiumDesignerTrainingModule
FPGADesign
Figure59.Frequencycountercontrolpanel
6. OpentheDigitalIOBsinstrumentpanel.
Figure60.DigitalIOBinstrumentcontrolpanel
Figure61.Logicanalyserinstrumentcontrolpanel
11. SelectShowPanelonthelogicanalyzer.SetthepanelupasdepictedinFigure62.
Figure62.Logicanalysertriggeringoptions.
133
AltiumDesignerTrainingModule
FPGADesign
12. SelectOptionsonthelogic analyser.Settheclockcapture frequencyto1MHzthesameas thefrequencygeneratormodule. Adjusttheothercontrolstobethe sameasshowninFigure63. 13. SelectArmandobservethe waveformdisplayedinthewaveform viewer.SelectContinuousCapture fromtheLogicAnalyzermenuand adjusttheIOBoutput.Observethe changeinthePWMmarktospace ratio.
Figure63.Logicanalysersetupoptions.
Figure64.Logicanalyzerwaveformwithbit7oftheIOBset.
Figure65.Logicanalyzerwaveformwithbits6&7oftheIOBset.
134
AltiumDesignerTrainingModule
FPGADesign
8.11
WherearetheInstruments?
Figure66.FloorplanofMyPWM.SchDocafterithasbeenplacedontoanFPGA.
8.12
Enablingembeddedinstruments
135
AltiumDesignerTrainingModule
FPGADesign
NEXUS_JTAG_PORT
JTAG JTAG JTAG JTAG JTAG JTAG
. . .
Figure67.NEXUSJTAGPortandNEXUSJTAGConnector.
136
AltiumDesignerTrainingModule
FPGADesign
9 InteractingwiththeNanoBoard
9.1 Overview
TheNanoBoardispivotaltorapidembeddedsystemsdevelopmentwithAltiumDesigner.Itcontains arangeofperipheralsandexpansioncapabilitiestoallowittoadapttoabroadcrosssectionof embeddedprojects.Inthissectionwewilldiscusstheconceptsnecessaryforadesignertomake effectiveusetheNanoBoardspotential.
9.2
NanoBoardcommunications
NanoTalk Chain
Figure68.Devicesviewwithitsvariouscommunicationschannelshighlighted.
137
AltiumDesignerTrainingModule
FPGADesign
9.2.1 NanoTalkchain
NanoTalkistheproprietarycommunicationsprotocoldevelopedbyAltiumtoenablemultiple NanoBoardstocommunicatewithoneanother.The10pinNanoTalkheaderscanbefoundonboth theleftandrightedgesattheupperendoftheDesktopNanoBoard.Communicationsviathis channelistotallytransparenttotheuser.Thereshouldbenoneedtointeractwiththisstandard.
9.2.2 JTAGHardChain
TheJTAGHardChainisaserialcommunicationschannelthatconnectsphysicaldevicestogether. JTAGdevicescanbeconnectedendonendbyconnectingtheTDOpinofanupstreamdeviceto theTDIpinofadownstreamdevice.ThehardJTAGchainisvisibleinthemiddleportionofthe DevicesView.UsuallythisiswhereanFPGAwillbelocatedhoweverifyoualsohaveother devicesthatareconnectedtotheJTAGchainsuchasaconfigurationdevicethenthesewillbe visiblealso. ThehardJTAGchaincanbeextendedbeyondtheNanoBoardthroughtheUserBoardAandUser BoardBconnectors.Whenusingeitheroftheseconnectors,itisimperativethattheJTAGchainis notbrokeni.e.theTDI/TDOchainmustbeloopedbacktotheNanoBoard.
9.2.3 JTAGSoftChain
TheJTAGSoftChainisaseparateJTAGchannelthatprovidescommunicationwiththeEmbedded InstrumentsthatcanbeincorporatedintoanFPGAdesign.Thischainislabeledasasoftchain sinceitdoesnotconnecttangiblephysicaldevicestogetherbutratherconnectssoftordownloadable instrumentsthatresideinsideahardorphysicalFPGAdevice.
9.3
Technicalbackground
TD DI T I
JT G TA J AG Cel el C ll
TD DO T O
Figure69.ConceptualViewofJTAGdataflows.
9.3.1 JTAGindepth
TheacronymJTAGstandsforJointTestApplicationGroupandissynonymouswithIEEE1149.1. ThestandarddefinesaTestAccessPort(TAP),boundaryscanarchitectureandcommunications protocolthatallowsautomatedtestequipmenttointeractwithhardwaredevices.Essentiallyit enablesyoutoplaceadeviceintoatestmodeandthencontrolthestateofeachofthedevicespins orrunabuiltinselftestonthatdevice.TheflexibilityoftheJTAGstandardhasalsoleadtoits usageinprogramming(configuring)devicessuchasFPGAsandmicroprocessors. Atminimum,JTAGrequiresthatthefollowingpinsaredefinedonaJTAGdevice: TCK:TestClockInput TMS:TestModeSelect
138
AltiumDesignerTrainingModule
FPGADesign
Figure70.UsingJTAGChaintoconnectmultipleJTAGdevicestogetherinadigitaldesign.
Figure70.JTAGTestAccessPort(TAP)StateMachine.
AltiumDesignerTrainingModule
FPGADesign
9.3.2 Nexus5001
TheflexibilityofJTAGforhardwaredebuggingpurposeshasflowedoverintothesoftwaredomain. Inthesamewaythattestengineershavesoughtastandardizedmethodfortestingsilicon,software engineershavealsosoughtastandardizedmeansfordebuggingtheirprograms. In1998,theGlobalEmbeddedDebugInterfaceStandard(GEDIS)Consortiumwasformed.Inlate 1999thegroupmovedoperationsintotheIEEEISTOandchangedtheirnametotheNexus5001 ForumandreleasedV1.0ofIEEEISTO1999.InDecember2003,V2.0wasreleased. TheNexus5001standardprovidesastandardizedmechanismfordebugtoolstointeractwithtarget systemsandperformtypicaldebuggingoperationssuchassettingbreakpointsandanalyzing variables,etc.Thereare4classesofNexuscomplianceeachwithdifferinglevelsofsupported functionality.ThelowestlevelusesJTAGasthelowlevelcommunicationsconduit. TheimplementationofNexus5001ontheDesktopNanoBoardhasbeenlabeledastheJTAGSoft Chain.Itisaserialchainjustlikethehardchainhoweverratherthanconnectingphysicaldevices together,itconnectsvirtualdevicestogether.Thesedevicesincludethesetofvirtualinstruments thataresuppliedwithAltiumDesigneranddescribedinthefollowingchapter.Controlofdeviceson theSoftChaincanbeperformedfromtheDevicesViewSoftChainDevicesarelocatedtowards thebottomoftheDevicesViewundertheHardChain. AswiththeJTAGHardChain,theSoftChaincanbetakenofftheNanoBoardviatheUserBoardA andUserBoardBconnectors.Thisprovidesthemeansfortargetsystemstoalsoincludevirtual instrumentsandtobenefitfromtheAltiumDesignerdevelopmentenvironment.SimilarlytotheHard Chain,itisimperativethatacompleteloopbemaintainedbetweentheSoftChainTDIandTDO connections.
9.4
TheNanoBoardcontroller
TheNanoBoardControllercanbeaccessedbydoubleclickingontheNanoBoardiconinthe DevicesView.
Figure71.TheNanoBoardControllerInstrumentRack.
SelectinganonstandardfrequencyispossiblebyclickingtheOtherFrequencybutton.The NanoBoardclocksystememploysaseriallyprogrammableclocksource(partnumberICS30702) thatiscapableofsynthesizinganyclockfrequencybetween6and200MHz.Advancedaccessto theClockControlICregistersisavailablethroughtheClockControlOptionsbutton.Adatasheet forthisdeviceisavailablefromtheICSwebsitehttp://www.icst.com/products/pdf/ics3070102.pdf. AnonlineformusefulforcalculatingsettingsfortheclockcontrolICisalsoavailableat http://www.icst.com/products/ics307inputForm.html. TotherightoftheNanoBoardControllerisasectionwiththeheading FlashRAM.TheFPGABootbuttonaffordsthefacilitytostoreadaughter boardconfigurationfilethatwillgetautomaticallyloadedintothedaughter boardonpowerup.TheEmbeddedbuttonexposesmemorythatcanbe usedbytheuserapplicationtostorenonvolatleuserdata.The EmbeddedMemorydeviceisaccessibleviatheSERIALFMEMORYcomponentintheFPGA NB2DSK01PortPlugin.IntLibLibrary.
140
AltiumDesignerTrainingModule
FPGADesign
9.5
FPGAI/Oview
TodisplaytheInstrumentrackforadevice,doubleclickonthedeviceintheJTAGHardchain. ClickingontheJTAGViewerPanelbuttonthenbringsuptheJTAGViewerPanel.
Figure72.TheHardDevicesinstrumentrack.
Figure73.TheFPGAI/OInstrumentRackandJTAGViewerPanel.
Thisinterfaceenablesthedevelopertoseeinrealtimetheflowofsignalsacrossthedevicespins. Thiscanbeparticularlyusefulwhenensuringthatsignalsarebeingcorrectlypropagatedtoandfrom thedevice. PlacingatickintheLiveUpdatecheckboxwillcausethedisplaytoupdateinrealtime. Alternatively,leavingtheLiveUpdatecheckboxclearandselectingtheupdateiconwillcause signalinformationtobelatchedtothedisplayandheld. CheckHideUnassignedI/OPinstoremoveclutterfromthedisplay. TheBSDLInformationdropdownlistshouldonlyneedtobeaccessedfordeviceswhichare unknowntoAltiumDesigner.Inthiscase,youwillneedtoprovidethelocationofthevendor suppliedBSDLfileforthedeviceyouareviewing. TheFPGAIOinstrumentrackisavailableforalldevicesontheJTAGHardChainincluding devicesonauserboardthatisconnectedtotheJTAGHardChain. 141
AltiumDesignerTrainingModule
FPGADesign
9.6
Livecrossprobing
9.7
1. 2. 3. 4. 5.
Exercise4BViewMyPWMontheNanoBoard
142
AltiumDesignerTrainingModule
FPGADesign
10 Creatingacorecomponent
10.1 Coreproject
AltiumDesignerprovidestheabilitytoencapsulateanentireFPGAcircuitintoasinglecomponent thatcanbeusedasabuildingblockinotherprojects.Theseselfcontainedblocksarecalledcore componentsandoffertheadvantageofdesignreuseanddesignsecurity.Corecomponentscanbe synthesizedforatargetFPGAandmadeavailabletootherswithoutexposingtheunderlyingIP. AcoreprojectisusedtocreateanFPGAcomponentthatmaybeusedmultipletimeswithinoneor acrossmanyFPGAprojects.Theoutputofacoreprojectbehavesinasimilarfashiontoalibrary componentinthatitbecomesanelementalunitthatisusedasacomponentinlargerdesigns. Acoreprojectisusefulwhenyouwishtomakesomefunctionalityavailabletoabroaduserbasebut youdonotwanttoexposetheIPusedtoimplementthefunctionality.
Figure75.UsingacorecomponentinanFPGAProject.
10.2
CreatingacorecomponentfromanFPGAproject
143
AltiumDesignerTrainingModule
FPGADesign
10.3
AwordaboutEDIF
10.4
Settingupthecoreproject
Figure76.Settingoptionsforacorecomponent.
144
AltiumDesignerTrainingModule
FPGADesign
Figure77. Specifyingthelocationofcorecomponentmodels.
10.5
Constrain/configure
10.5.1 Deviceandboardconsiderations:
ThespecificFPGAdevicemustbeidentifiedandportsdefinedinthetoplevelFPGAdesignmustbe mappedtospecificpinnumbers.
10.5.2 Deviceresourceconsiderations:
Insomedesignsitmaybeadvantageoustomakeuseofvendorspecificresourcesthatareunique toagivenFPGAdevice.Someexamplesarehardwaremultiplicationunits,clockmultipliersand memoryresources.
145
AltiumDesignerTrainingModule
FPGADesign
10.5.3 Projectordesignconsiderations:
Thiswouldincluderequirementswhichareassociatedwiththelogicofthedesign,aswellas constraintsonitstiming.Forexample,specifyingthataparticularlogicalportmustbeallocatedto globalclocknet,andmustbeabletorunatacertainspeed. Aconfigurationisasetofoneormoreconstraintfilesthatmustbeusedtotargetadesignfora specificoutput.Themigrationofadesignfromprototype,refinementandproductionwilloften involveseveralPCBiterationsandpossiblyevendifferentdevices.Inthiscase,aseparate configurationwouldbeusedtobringtogetherconstraintfileinformationforeachdesigniteration. Eachnewconfiguration(anditsassociatedconstraintfile(s)isstoredwiththeprojectandcanbe recalledatanytime. Tosummarize: Constraintfilesstoreimplementationspecificinformationsuchasdevicepinallocationsand electricalproperties. AConfigurationisagroupingofoneormoreconstraintfilesanddescribeshowtheFPGA projectshouldbebuilt.
10.6
Creatinganewconstraintfile
Whentargetingadesignforauserboard,itisoftennecessarytomanuallycreateatleastone constraintfile.Thisconstraintfilewouldincludeataminimumthedevicethatisbeingtargetedand mayincludeanynumberofadditionalconstraintsappropriateforthetargetPCB.Ascoresmay oftenbesynthesizedforanumberofpossibletargets,itisusefultodiscusstheprocessofmanually constrainingandconfiguringadesigninthecontextofcreatingcoreprojects. Beforeaconfigurationcanbebuilt,aconstraintfilemustexist.Constraintfileshavetheextension .Constraint.ConstraintfilesforusewiththeDesktopNanoBoardcanbefoundinthe\Program Files\AltiumDesigner6\Library\Fpga\directory.Ingeneralitisadvisabletotakeacopy ofthesefilesandstoreitinyourprojectdirectorybeforeaddingittotheproject.Thiswaytheproject iskeptselfcontainedandanyeditsyoumayinadvertentlymakewillnotaffectthesupplied constraintfile. Toaddyourown,newconstraintfile,rightclickontheprojectnameintheProjectspaneland selectAddNewToProjectConstraintFile. Anewblankconstraintfilewillappear.TospecifythetargetdeviceselectDesignAdd/Modify ConstraintPartandtheBrowsePhysicalDevicesdialogwillopen.
Figure78.TheBrowsePhysicalDevicesdialog,whereyouselectthetargetFPGA.
146
AltiumDesignerTrainingModule
FPGADesign
Figure79.Basicconstraintfile.
Selectthevendor,family,deviceand temperature/speedgradesasdesiredandclick OK. Alinesimilartotheoneabovewillbe automaticallyinsertedintotheconstraintfile: Savetheconstraintfile.Typicallyitwouldbe namedtoreflectitsrole forexampleifthe targetdevicewasaXilinxSpartan3FPGA mountedonyourprojectPCByoumightcallit MyProject_Spartan3_1500.Constraint. Youwillnoticetheconstraintfilehasbeen addedtotheprojectunderthesettingstab.
Figure80.ProjectwithconstraintFile.
10.7
Creatingaconfiguration
Figure81.Specifyingaconfigurationusingtheconfigurationmanager.
147
AltiumDesignerTrainingModule
FPGADesign
Figure82.Specifyingaconfigurationusingtheconfigurationmanager.
Figure83.Exampleofaprojectwithmultipleconfigurationsdefined.
Configurationscanbeupdatedormodifiedasdesiredatanytimethroughouttheprojects developmentbyreturningtotheConfigurationManagerdialog.
10.8
Synthesize
Nowthatwehavedefinedaconfiguration wearereadytosynthesizethecoreforthe target. WiththetoplevelFPGAdocumentopen selectDesignSynthesize.Ifwehad definedmorethanoneconfigurationand wishedtosynthesizeallconfigurationsat oncewecouldselectDesign SynthesizeAllConfigurations. Ifyouhavenotalreadynominatedthe toplevelentity/configurationinthe SynthesistaboftheOptionsforCore Figure84.SpecifyinganFPGAprojectstopleveldocument. Project,theChooseTopleveldialogwill appear.EnterthecoreprojectnameorselectfromthedropdownlistandclickOKtocontinue. TheprojectwillbesynthesizedresultinginthegenerationofVHDLfilesfortheschematic,EDIF filesfortheschematicwiringandparts,andasynthesislogfile.Thesewillallbelocatedunder theGeneratedfolderintheprojectpanel. YouwillobservetheconfigurationnameinbracketsbesidetheGeneratedFolder.Hadwe synthesizedmorethanoneconfigurationthenaseparateGeneratedfolderwouldhaveappeared foreachofthedefinedconfigurations.
148
AltiumDesignerTrainingModule
FPGADesign
10.9
Publish
Nowwecanpublishthecoreproject.Thiswillzip together(archive)alltheEDIFfilesinthecore projectsProjectOutputsfolderandthencopythis totheuserEDIFmodelsfolderthatwasspecified earlier. SelectDesignPublish.Iftheerrormessage cannotfindworkingfolderappears,make sureyouhavesetuptheUsepresynthesized Figure85.Filesgeneratedaftersynthesizingthedesign modelfolderoptionintheFPGAPreferences dialog. ChecktheMessagespaneltoensurethedesignhasbeensuccessfullypublished. Savethecoreprojectfile.
10.10 Creatingacoreschematicsymbol
Thecoreprojecthasbeensuccessfullysynthesizedandpublished.Itwouldbepossibleatthispoint forotherpersonneltomakeuseofyourcorethroughaVHDLinstantiationprocess.Thiscanbea messyaffair.Afarsimpleroptionwouldbeforthemtouseaschematicsymbolthatislinkedtoyour coreandassociatedEDIFfiles.Todothis,weneedtocreateourownschematicsymbolfromthe corecomponent. WiththetoplevelFPGAdocumentopenselectDesignGenerateSymbol.
Figure86.Creatingacorecomponentsymbol.
149
AltiumDesignerTrainingModule
FPGADesign
Figure87.Specifyingcorecomponentoptions.
Figure88.Specifyingthepropertiesofthenewlycreatedcorecomponentsymbol.
150
AltiumDesignerTrainingModule
FPGADesign
Figure89.Editingthecorecomponentpins.
10.11 Usingacorecomponent
Whenacorecomponentissynthesizedandpublished,theEDIFmodelisarchivedintothelocation specifiedintheFPGAPreferencesdialog.Anyprojectthatsubsequentlyusesthecorecomponent mustensurethattheEDIFarchivecanbefoundwithinthesearchpath.Thesearchsequencefor EDIFmodelsis: $project_dir $user_edif\$vendor\$family $user_edif\$vendor $user_edif $system_edif\$vendor\$family $system_edif\$vendor $system_edif Notethatthesearchlocationsincludestheprojectdirectorywhichmakesitusefulifyouneedto transferthedesigntoanotherPCthatdoesnothavetheuserEDIFmodelslocationdefined. 151
AltiumDesignerTrainingModule
FPGADesign
10.12 Exercise5CreateacorecomponentfromMyPWM
1. CreateanewcoreprojectandcallitMyPWMCore.PrjCor.Notethatthefilenamemustnothave spacesinit. 2. SettheIncludemodelsinpublishedarchivecheckboxintheProjectOptionsdialog. 3. InthePreferencesdialog,gotoFPGASynthesis,andselectanoutputpathforEDIFfiles. Thispathshouldnotincludeanyspaces. 4. AttachtheexistingMyPWM.SchDocthatyoucreatedaspartofexercise3. 5. CreateaprojectlevelconstraintfileandcallitMyPWMPrj.Constraint.Addthefollowingtothis constraintfile:
Record=Constraint|TargetKind=Port|TargetId=CLK_BRD|FPGA_CLOCK_PIN=True Record=Constraint|TargetKind=Port|TargetId=CLK_BRD|FPGA_CLOCK=True Record=Constraint|TargetKind=Port|TargetId=CLK_BRD|FPGA_CLOCK_FREQUENCY=50Mhz Figure90.UpdatestobemadetoMyPWMPrj.Constraintfile.
6. CreateaconstraintfileeachforanAlteraCycloneIIdeviceaswellasaXilinxSpartan3device. 7. Createaconfigurationthatlinkseachoftheindividualdeviceconstraintfileswiththeproject constraintfile. 8. Synthesizeallconfigurationsandpublishthedesign.ChecktheUserPresynthesizedmodel Folder(assetinStep3)usingwindowsexplorerandviewthedirectoriesthatarecreatedand theircontents. 9. CreateacoreschematicsymbolandsaveittothelibraryMyCoreLib.SchLib 10. CreateanewFPGAprojectandschematicthatmakesuseofyourPWMcoreandtestitonthe NanoBoard.
CLK_BRD
ON
SW[7..0]
1 2 3 4 5 6 7 8
SW[7..0] TEST_BUTTON
TEST_BUTTON
MyPWMCore
Figure90.TestprojectusedtotestthefunctionofMyPWMCore.
152
AltiumDesignerTrainingModule
FPGADesign
11 FPGAdesignsimulation
AltiumDesignersupportsbehavioralsimulationofVHDLdesigns.Thisisparticularlyusefulwhen verifyingthefunctionaloperationofdigitalcircuitspriortoimplementingtheminsideanFPGA.
11.1
Creatingatestbench
DUT Inputs
DesignUnderTest(DUT)
DUT Outputs
Figure91.ConceptualviewofhowaVHDLtestbenchinteractswiththeDesignUnderTest(DUT).
AltiumDesignerprovidesaconvenientmethodforbuildingaVHDLTestbenchbasedontheinputs andoutputsofthenominatedDUT.Ashelltestbenchfilecanbeautomaticallycreatedbythe system. Openaschematicdocumentandselect ToolsConvertCreateVHDLTestbench fromthemenu. OpenaVHDLdocumentandselectDesignCreateVHDLTestbench. AnewVHDLdocumentwillbecreatedwiththeextension.VHDTSTandwillbeaddedtotheproject. WithintheTestbenchfilewillbeacommentinsertstimulushere.ByplacingVHDLcodeatthis pointyoucancontroltheoperationofthesimulationsession.Ataminimum,theTestbenchmustset alloftheDUTsinputstoaknownstate.IftheDUTrequiresaclockthenthattoomustbeprovided bytheTestbench.MostsimulationerrorsoccurasaresultoftheTestbenchfailingtoproperly initializetheinputsoftheDUT.
11.2
AssigningtheTestbenchDocument
Figure9218.Specifyingthetestbenchdocument
153
AltiumDesignerTrainingModule
FPGADesign
11.3
Initiatingasimulationsession
11.4
Projectcompileorder
Figure93.Messagespanel.
154
AltiumDesignerTrainingModule
FPGADesign
11.5
Settingupthesimulation display
TheSimulationSignalsdialog(Figure95)is automaticallypresentedatthebeginningofa simulationoritcanbeaccessedviaSimulator Signals. TheWatchNameisthenameofthesignaldeclared insidetheblockofVHDLcode. SignalsmustbeEnabledinordertobeapartofthe simulation.Furthermore,iftheyneedtobe displayedaspartofthesimulationoutputthen ShowWavemustalsobeselected. TheWaveformviewer(Figure95)providesa visualizationofthestatusofeachofthedisplayed signals. Theicon nexttothebusnameindicatesabus signal.Clickingonthisiconwillexpandthebus intoitsindividualsignalsforcloserinspection. Thetimecursor(indicatedbythepurplevertical bar)canbedraggedalongthetimeaxisviathe mouse.Thecurrentpositionofthecursoris providedinthetimebaracrossthetopofthe display. Zoominginoroutisachievedbypressingthe PageUporPageDownkeysrespectively. Thedisplayformatoftheindividualsignalscan bealteredviathemenuitemToolsFormat andRadix. .
Figure9519.Specifyingsignalstodisplayinthe simulation.
Figure96.Thewaveformviewer
155
AltiumDesignerTrainingModule
FPGADesign
11.6
Runninganddebuggingasimulation
Runningasimulationisreasonablystraightforwardwithallthe stepping/runningfunctionsthatyoumightwishtousebeing availablefromtheSimulatormenuortheVHDLToolstoolbar. RunForeverwillrunthesimulationindefinitelyuntilStopis pressed.ThiscommandisusedtorunaVHDLsimulationuntil therearenochangesoccurringinthesignalsenabledinthe simulation. UsetheRun(foratimestep)commandtorunthecurrent simulationforauserspecifiedperiodoftime(timestep). Runfor (thelasttimestep)willrunthesimulatorforthesame periodoftimeasspecifiedinthelastRuncommand. RuntoTimewillrunthesimulatortoanabsolutetime. Selectingatimepriortowherethesimulationhasalready simulatedtowillcausethesimulatortodonothing. RuntoCursorisusefulwhendebuggingVHDLsourceand willcausethesimulatortorununtilthedefinedcursorlocation isencounteredinasourceVHDLdocument.Thesimulatorwill simulateeverythinguptotheselectedline.Makesurethatthe Showexecutionpointoptionisenabled,intheDebugging OptionsregionoftheFPGASimulationDebuggerpageof thePreferencesdialog(Figure97). CustomStep(Runsimulationtothenextdebugpoint):This commandisusedtorunthecurrentsimulation,uptothenext executablelineofcodeinthesourceVHDLdocuments.The nextexecutablecodepointcanbeanywhereinthecodeand thereforethecommandcanbeconsideredtobestepping Figure97.Thesimulatormenu throughthecodeinparallel,ratherthanthesequentiallybased stepintoandstepovercommands. StepTime:Thiscommandisusedtorunthecurrentsimulation,executingcodeinthesource VHDLdocumentsuntiltimeincrementsi.e.alldeltatimeeventspriortothenexttimeincrement willbeexecuted. DeltaStep:Thiscommandisusedtorunthecurrentsimulationforasinglecycle,whichcanbe calledaDeltastep.ADeltastepcanbesosmallthatnochangeinrealtimeisseen. StepIntoenablestheusertosinglestepthroughtheexecutablelinesofcodeinthesource VHDLdocuments.Ifanyprocedures/functionsareencountered,steppingwillcontinueintothe calledprocedureorfunction. StepOverissimilartoStepIntoexceptthatifanyprocedures/functionsareencountered, steppingwillexecutetheentireprocedure/functionasasingleexecutablelineandwillnotstep intoit. Stopwillpausethesimulatoratitscurrentsimulationpoint.Apausedsimulationcancontinueto berunwithanyoftheabovecommands. Resetwillabortthecurrentsimulation,clearanywaveformsandresetthetimebackto0. Endterminatestheentiresimulationsession.Endedsimulationscannotberestartedotherthan byinitiatinganothersimulationsession.
156
AltiumDesignerTrainingModule
FPGADesign
Figure98.Thesimulationdebuggeroptionsinthepreferencesdialog.
157
AltiumDesignerTrainingModule
FPGADesign
11.7
Exercise6CreateatestbenchandsimulateMyPWM
Figure99.TestbenchcodefortestingMyPWM
158
AltiumDesignerTrainingModule
FPGADesign
12 Review
159