Transcript
Page 1: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

FPGAInterfaceJune2008,371107E-01TheFPGAInterfaceprovidesprogrammingfeaturesandfunctionstohelpyoucommunicatewithVIsorbitfilesthatrunonNationalInstrumentsFPGAtargets,suchasNationalInstrumentsReconfigurableI/O(NI-RIO)devices.TheVIthatrunsontheFPGAtargetiscalledtheFPGAVI.TheVIyouusetocommunicatewithFPGAVIsorbitfilesiscalledthehostVI.ThehostVIcanrunonPCsorRTtargets.TheFPGAInterfaceisavailablewithFPGAtargetdriversoftware.YoucanusetheFPGAInterfacefunctionsinahostVIifyouhaveanFPGAtargetandtheappropriatedriversoftware.YoudonotneedtheLabVIEWFPGAModuletousetheFPGAInterfacefunctions.YouneedtheFPGAModuleifyouwanttodevelopFPGAVIs.

Toviewrelatedtopics,clicktheLocatebutton,shownatleft,inthetoolbaratthetopofthiswindow.TheLabVIEWHelphighlightsthistopicintheContentstabsoyoucannavigatetherelatedtopics.

©2003–2008NationalInstrumentsCorporation.Allrightsreserved.

Page 2: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

UsingLabVIEWFPGAInterfacewithouttheFPGAModule(FPGAInterface)IfyouhaveanFPGAtarget,youcanusetheLabVIEWFPGAInterfaceVIsandfunctionstointerfacewithanFPGAbitfileevenifyoudonothavetheLabVIEWFPGAModuleinstalled.UsetheOpenFPGAVIReferencefunctiontoopenareferencetotheFPGAbitfile.YouthencanuseotherFPGAInterfacefunctions,suchasRead/WriteControl,InvokeMethod,andCloseFPGAVIReference,tointerfacewiththeFPGAbitfile.

NoteYoucanuseanuncompiledFPGAVIonlyifyouhavetheLabVIEWFPGAModuleinstalled.

Page 3: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

CommunicatingwithFPGAVIs(FPGAInterface)ThisbookprovidesfunctionsandproceduresthatenablehostVIstocommunicatewithFPGAVIs.

Toviewrelatedtopics,clicktheLocatebutton,shownatleft,inthetoolbaratthetopofthiswindow.TheLabVIEWHelphighlightsthistopicintheContentstabsoyoucannavigatetherelatedtopics.

Page 4: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

OpeningaReferencetoanFPGAVI(FPGAInterface)YoucancommunicatewithFPGAVIsorbitfilesrunningonFPGAtargetsusinghostVIs.HostVIscanrunonPCsorRTtargets.EachhostVImustopenareferencetotheFPGAVIorbitfilethatrunsontheFPGAtarget.YoucanopenareferencetoanFPGAVIinthesameLabVIEWprojectasthehostVI,oryoucanopenareferencetoabitfile.

NoteIfyouwanttoopenreferencestodifferentFPGAVIsorbitfilesononetarget,openonlyonereferenceatatime,andclosethereferencebeforeopeninganother.YoucanhavemorethanoneFPGAVIreferencesimultaneouslyopenonatarget,aslongasallthereferencescorrespondtothesameFPGAVIorbitfileonthesametarget.

TipTomakehostVIdevelopmentfaster,keeptheFPGAVIinmemory.

Page 5: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

OpeningaReferencetoanFPGAVICompletethefollowingstepstoopenareferencetoanFPGAVIinahostVI.YoucanopenareferencetoanFPGAVIifthehostVI,theFPGAtarget,andtheFPGAVIareinthesameproject.YoucannotopenareferencetoanFPGAVIifyoudonothavetheLabVIEWFPGAModuleinstalled.

1. Createanewprojectoropenanexistingproject.2. AddanFPGAtargettotheprojectorverifytheFPGAtarget

appearsintheProjectExplorerwindow.3. CreateanewFPGAVIorverifytheFPGAVItowhichyouwant

toopenareferenceappearsintheProjectExplorerwindowundertheFPGAtarget.

4. CreateanewhostVIoropenanexistinghostVIintheproject.ThehostVImustbeunderMyComputeroranRTtargetintheProjectExplorerwindow.

5. PlaceanOpenFPGAVIReferencefunctionontheblockdiagram.

Place Find6. DragtheFPGAVIyouwanttoopenareferencetofromthe

ProjectExplorerwindowtotheOpenFPGAVIReferencefunction.TheFPGAVIiconappearsintheOpenFPGAVIReferencefunction.IftheFPGAtargetintheprojectisassociatedwithaphysicaltarget,thetargetnameandresourceappearsundertheOpenFPGAVIReferencefunction.

7. (Optional)Right-clicktheOpenFPGAVIReferencefunctionandselectConfigureOpenFPGAVIReferencefromtheshortcutmenutodisplaytheConfigureOpenFPGAVIReferencedialogbox,whichyoucanusetoselectoptionsforopeningthereference.

8. (Optional)WireacontrolorconstanttotheresourcenameinputontheOpenFPGAVIReferencefunctiontospecifyanFPGAtargetonwhichtoruntheFPGAVI.

NoteYoumustplaceandwireaCloseFPGAVIReferencefunctionforeveryOpenFPGAVIReferencefunctioninahostVI.

Page 6: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

OpeningaReferencetoaBitfileCompletethefollowingstepstoopenareferencetoabitfileinahostVI.ThehostVIdoesnotneedtobeinaproject.

1. CreateanewhostVIoropenanexistinghostVI.IfthehostVIisinaproject,thehostVImustbeunderMyComputeroranRTtargetintheProjectExplorerwindow.

2. PlaceanOpenFPGAVIReferencefunctionontheblockdiagram.

Place Find3. Right-clicktheOpenFPGAVIReferencefunctionandselect

ConfigureOpenFPGAVIReferencefromtheshortcutmenu.4. SelecttheBitfileoptionintheConfigureOpenFPGAVI

Referencedialogbox.5. NavigatetothebitfileyouwanttoopenonanFPGAtarget.6. (Optional)UsetheConfigureOpenFPGAVIReferencedialog

boxtoselectadditionaloptionsforopeningthereference.7. ClicktheOKbutton.TheFPGAVIiconappearsintheOpen

FPGAVIReferencefunction.AfoldericonappearsintheupperleftcorneroftheOpenFPGAVIReferencefunctiontodenotethebitfile.

8. WireacontrolorconstanttotheresourcenameinputontheOpenFPGAVIReferencefunctiontospecifyanFPGAtargetonwhichtoruntheFPGAVI.

NoteYoumustplaceandwireaCloseFPGAVIReferencefunctionforeveryOpenFPGAVIReferencefunctioninahostVI.

Page 7: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

CommunicatingwithanFPGAVIRunningonaDevelopmentComputer(FPGAInterface)ThefollowinglistdescribesbehaviortoconsiderwhenyouuseahostVItocommunicatewithanFPGAVIthatisrunningonadevelopmentcomputerwithsimulatedI/O:

YoumustrunthehostVIonaWindowsdevelopmentcomputertocommunicatewiththeFPGAVI.YoucannotrunthehostVIonanRTtarget.ToexecutedifferentcodeonthehostVIbasedonwheretheFPGAVIexecutes,usetheInvokeMethodfunctionconfiguredfortheGetFPGAVIExecutionModemethod.TheUpCastfunctionandtheAbort,Reset,andDownloadmethodsontheInvokeMethodfunctiondonotsupportrunningtheFPGAVIonthedevelopmentcomputer.IfyouusetheUpCastfunctionorthesemethods,thehostVIreturnsarun-timeerror.DirectMemoryAccess(DMA)FIFOsarevalidwhileeitherthehostVIorFPGAVIarerunning.IfbothVIsstoprunning,DMAFIFOslosealldata.InterruptsarevalidonlywhentheFPGAVIisrunning.IftheFPGAVIstopsrunning,allinterruptdataislostandanyhostinterfacewaitsreturnimmediately.IfyouusetheInvokeMethodfunctiontoreadDMAFIFOs,thefunctionmighttimeoutmorefrequentlybecausetheFPGAVIisnotrunningasfastonthedevelopmentcomputerasitwouldonanFPGAtarget.YoumustclosethefrontpanelwindowoftheFPGAVIbeforerunningtheFPGAVIifyouwanttousetheCloseFPGAVIReferencefunctiontoclosethereference,stoptheFPGAVI,andresettheFPGAVIrunningonthedevelopmentcomputer.YoumustopenthefrontpanelwindowoftheFPGAVIbeforerunningtheFPGAVIifyouwanttousetheCloseFPGAVIReferencefunctiontoclosethehostreferencewithoutresettingtheFPGAVIrunningonthedevelopmentcomputer.

Page 8: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

UsingMultipleFPGAVIReferencesfortheSameTarget(FPGAInterface)IfyouwanttoopenreferencestodifferentFPGAVIsorbitfilesononetarget,openonlyonereferenceatatime,andclosethereferencebeforeopeninganother.YoucanhavemorethanoneFPGAVIreferencesimultaneouslyopenonatarget,aslongasallthereferencescorrespondtothesameFPGAVIorbitfileonthesametarget.YoucantakeadvantageofthisifyouwanttostructureanapplicationsothatdifferentpartsofthehostVIcommunicatewithcertainpartsoftheFPGAVI.ThehostVIaccessescertainresourcesfromtheFPGA.Theresourcescanincludecontrolsandindicators,logicalinterrupts,andDMAchannels.ThebestwaytopartitionthehostVIistoaccessoneoftheFPGAresourcesusingoneFPGAVIreference.TheonlytypeofaccessthatyoucanalwayssafelymakeusingmultipleFPGAVIreferencesisreadingofcontrolsandindicators.

Page 9: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

ReadingFPGAVIIndicators(FPGAInterface)CompletethefollowingstepstoreadanindicatorinanFPGAVIfromahostVI.TheFPGAVImusthavefrontpanelindicators.

1. OpenareferencetotheFPGAVIorbitfile.NoteTheFPGAtarget,FPGAVI,andhostVImustbeinthesameLabVIEWprojectifyouwanttoopenareferencetoanFPGAVI.ThehostVIdoesnotneedtobeinaprojectifyouopenareferencetoabitfile.

2. PlacetheRead/WriteControlfunctionontheblockdiagram.NoticethattheRead/WriteControlfunctioncontainsoneUnselectedinput.

Place Find3. WiretheFPGAVIReferenceOutparameteroftheOpenFPGA

VIReferencefunctiontotheFPGAVIReferenceInparameteroftheRead/WriteControlfunction.

4. ClicktheUnselectedinput.TheshortcutmenulistsallfrontpanelcontrolsandindicatorsintheFPGAVIintheControlssubmenu.

5. SelectanindicatoravailableintheFPGAVIfromtheshortcutmenu.NoticethattheUnselectedinputchangestoanoutputandreflectsthenameoftheindicatorintheFPGAVI.

ToreadmoreindicatorsintheFPGAVI,right-clicktheRead/WriteControlfunctionandselectAddElementfromtheshortcutmenuandthencustomizetheoutputasdescribedinthepreviousstep.YoualsocanclickthebottomlineoftheRead/WriteControlfunctionwiththePositioningtoolanddragthelinedowntoaddmorecontrolsandindicators.Thereadandwriteoperationsexecutesequentiallyfromtoptobottom.Also,iftheFPGAVIhassubVIsandyouwanttoaccesscontrolsandindicatorsonthesubVI,youmustwirethesubVIcontrolsandindicatorstothecontrolsandindicatorsoftheFPGAVIthatisusedintheOpenFPGAVIReferencefunction.

NoteYoualsocanreadFPGAVIcontrols.Toreadacontrol,right-clickthecontrolinputontheRead/WriteControlfunctionandselectChangetoReadfromtheshortcutmenu.

Page 10: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

WritingtoFPGAVIControls(FPGAInterface)CompletethefollowingstepstowritetoacontrolinanFPGAVIfromahostVI.TheFPGAVImusthavefrontpanelcontrols.

1. OpenareferencetotheFPGAVIorbitfile.NoteTheFPGAtarget,FPGAVI,andhostVImustbeinthesameLabVIEWprojectifyouwanttoopenareferencetoanFPGAVI.ThehostVIdoesnotneedtobeinaprojectifyouopenareferencetoabitfile.

2. PlacetheRead/WriteControlfunctionontheblockdiagram.NoticethattheRead/WriteControlfunctioncontainsoneUnselectedinput.

Place Find3. WiretheFPGAVIReferenceOutoutputoftheOpenFPGAVI

ReferencefunctiontotheFPGAVIReferenceIninputoftheRead/WriteControlfunction.

4. ClicktheUnselectedinput.TheshortcutmenulistsallfrontpanelcontrolsandindicatorsintheFPGAVI.

5. SelectacontrolavailableintheFPGAVIfromtheshortcutmenu.NoticethattheUnselectedinputchangestoreflectthenameofthecontrolintheFPGAVI.

TowritetomorecontrolsintheFPGAVI,right-clicktheRead/WriteControlfunctionandselectAddElementfromtheshortcutmenuandthencustomizetheinputasdescribedinthepreviousstep.YoualsocanclickthebottomlineoftheRead/WriteControlfunctionwiththePositioningtoolanddragthelinedowntoaddmorecontrolsandindicators.Thereadandwriteoperationsexecutesequentiallyfromtoptobottom.Also,iftheFPGAVIhassubVIsandyouwanttoaccesscontrolsandindicatorsonthesubVI,youmustwirethesubVIcontrolsandindicatorstothecontrolsandindicatorsoftheFPGAVIthatisusedintheOpenFPGAVIReferencefunction.

NoteYoualsocanwritetoFPGAVIindicators.Towritetoanindicator,right-clicktheindicatoroutputandselectChangetoWritefromtheshortcutmenu.

Page 11: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

ReadingDMAFIFOsfromHostVIs(FPGAInterface)YoucancreateDirectMemoryAccess(DMA)FIFOsinFPGAVIstotransferdatafromFPGAVIstohostVIs.SomeFPGAtargetsdonotsupportDMA.TheFPGAtargetsthatsupportDMAincludeafixednumberofDMAchannelsavailablefortransferringdatabetweentheFPGAVIandthehostVI.RefertothespecificFPGAtargethardwaredocumentationforinformationaboutthenumberofDMAchannelsavailable,iftheFPGAtargetsupportsDMA.CompletethefollowingstepstoreadaDMAFIFOinanFPGAVI.

1. OpenareferencetoanFPGAVIorbitfile.NoteTheFPGAtarget,FPGAVI,andhostVImustbeinthesameLabVIEWprojectifyouwanttoopenareferencetoanFPGAVI.ThehostVIdoesnotneedtobeinaprojectifyouopenareferencetoabitfile.IfyouopenareferencetoanFPGAVI,theprojectmustincludeaDMAFIFOitemundertheFPGAtargetandtheFPGAVImustincludeaFIFOWritefunctionontheblockdiagramthatwritestotheDMAFIFOitem.

2. PlaceanInvokeMethodfunctionontheblockdiagramofthehostVIinthedataflowwhereyouwantthehostVItoreadtheDMAFIFO.MakesurethehostVIrunstheFPGAVIbeforeyoureadtheDMAFIFO.WiretheFPGAVIReferenceIninput.

Place Find3. ClicktheInvokeMethodfunctionandselectFIFO»Readfromthe

shortcutmenu,whereFIFOisthenameoftheFIFOitemintheproject.Wiretheinputsandoutputsasneeded.TheReadmethodreturnsDatawhentheNumberofElementsisavailableorwhentheTimeoutperiodends.IftheTimeoutperiodendsbeforetheNumberofElementsisavailable,Datawillbeempty.TheElementsRemainingoutputcontainsthenumberofelementsremaininginthehostmemorypartoftheDMAFIFO.

4. PlacetheCloseFPGAVIReferencefunctionontheblockdiagram.

Page 12: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

Place Find5. WiretheFPGAVIReferenceOutoutputontheInvokeNodeto

theFPGAVIReferenceIninputontheCloseFPGAVIReferencefunction.

NoteYoucanreadDMAFIFOsusingonlytheInvokeMethodfunctionwiththeReadmethod.IfyouwantmorecontrolovertheDMAFIFOfromthehostVI,youalsocanconfigure,start,andstoptheDMAFIFOusingtheoptionalConfigure,Start,andStopmethodswiththeInvokeMethodfunction.

Page 13: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

WritingtoDMAFIFOsfromHostVIs(FPGAInterface)YoucancreateDirectMemoryAccess(DMA)FIFOstotransferdatafromhostVIstoFPGAVIs.SomeFPGAtargetsdonotsupportDMA.TheFPGAtargetsthatsupportDMAincludeafixednumberofDMAchannelsavailablefortransferringdatabetweenthehostVIandFPGAVI.RefertothespecificFPGAtargethardwaredocumentationforinformationaboutthenumberofDMAchannelsavailable,iftheFPGAtargetsupportsDMA.CompletethefollowingstepstowritetoaDMAFIFOinanFPGAVI.

1. OpenareferencetoanFPGAVIorbitfile.NoteTheFPGAtarget,FPGAVI,andhostVImustbeinthesameLabVIEWprojectifyouwanttoopenareferencetoanFPGAVI.ThehostVIdoesnotneedtobeinaprojectifyouopenareferencetoabitfile.IfyouopenareferencetoanFPGAVI,theprojectmustincludeaDMAFIFOitemundertheFPGAtargetandtheFPGAVImustincludeaFIFOReadfunctionontheblockdiagramthatreadstheDMAFIFOitem.

2. PlaceanInvokeMethodfunctionontheblockdiagramofthehostVIinthedataflowwhereyouwantthehostVItowritetotheDMAFIFO.WiretheFPGAVIReferenceIninput.

Place Find3. ClicktheInvokeMethodfunctionandselectFIFO»Writefromthe

shortcutmenu,whereFIFOisthenameoftheFIFOitemintheproject.Wiretheinputsandoutputsasneeded.TheWritemethodreturnsEmptyElementsRemainingwhenthedataiswrittenorwhentheTimeoutperiodends.

4. PlacetheCloseFPGAVIReferencefunctionontheblockdiagram.

Place Find5. WiretheFPGAVIReferenceOutoutputontheInvokeNodeto

theFPGAVIReferenceIninputontheCloseFPGAVIReferencefunction.

Page 14: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

NoteYoucanwriteDMAFIFOsusingonlytheInvokeMethodfunctionwiththeWritemethod.IfyouwantmorecontrolovertheDMAFIFOfromthehostVI,youalsocanconfigure,start,andstoptheDMAFIFOusingtheoptionalConfigure,Start,andStopmethodswiththeInvokeMethodfunction.

Page 15: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

UsingSubVIsinHostVIs(FPGAInterface)YoucanusesubVIsinhostVIsthatcommunicatewithFPGAVIsorbitfilesonFPGAtargets.However,ifyouchangetheconfigurationoftheOpenFPGAVIReferencefunctionortheUpCastfunction,LabVIEWdoesnotpropagatethechangestothesubsequentsubVIsinthedataflowunlessyoubindthereferenceoutputofthefunctiontoatypedefinition.CompletethefollowingstepstobindthereferenceoutputoftheOpenFPGAVIReferencefunctiontoatypedefinition.

1. Right-clicktheOpenFPGAVIReferencefunctiononthehostVIblockdiagramandselectConfigureOpenFPGAVIReferencefromtheshortcutmenu.

2. PlaceacheckmarkintheBindFPGAhostreferencetotypedefinitioncheckbox.TheSaveAsdialogboxappears.

3. TypeanameforanewtypedefinitionintheFilenametextboxornavigatetoanexistingtypedefinitionintheSaveAsdialogbox.IfyoutypeanameforthetypedefinitionintheFilenametextbox,LabVIEWcreatesthetypedefinitionforyou.

4. ClicktheSavebuttontoclosetheSaveAsdialogbox.5. ClicktheOKbuttontoclosetheConfigureOpenFPGAVI

Referencedialogbox.CompletethefollowingstepstobindthereferenceoutputoftheUpCastfunctiontoatypedefinition.

1. Right-clicktheUpCastfunctiononthehostVIblockdiagramandselectBindReferenceOutputtoTypeDefinitionfromtheshortcutmenu.TheSaveAsdialogboxappears.

2. TypeanameforanewtypedefinitionintheFilenametextboxornavigatetoanexistingtypedefinitionintheSaveAsdialogbox.IfyoutypeanameforthetypedefinitionintheFilenametextbox,LabVIEWcreatesthetypedefinitionforyou.

3. ClicktheSavebutton.LabVIEWnowautomaticallyupdatesthetypedefinitionyoucreatedwheneverchangestotheOpenFPGAVIReferencefunctionortheFPGAVInecessitatechangestothetypedefinition.LabVIEWalsopropagatesthesechangestoanysubVIsthatusethistypedefinition.This

Page 16: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

propagationallowsthesubVIstoremainconsistentwiththeOpenFPGAVIReferencefunctionorUpCastfunction.IfyoudonotbindtheoutputoftheOpenFPGAVIReferenceorUpCastfunctionstoatypedefinitionandyoumakeachangetotheconfigurationofeitherofthesefunctions,youmustmakethesamechangeinanysubVIsthatusethereferenceoutput.UsetheConfigureFPGAVIReferencedialogboxtoupdatethereference.

Page 17: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

SynchronizingFPGAVIsandHostVIsUsingInterrupts(FPGAInterface)SomeFPGAtargetsallowyoutogenerateinterruptsfromtheFPGAVItonotifythehostVIofevents,suchasdatabeingready,anerroroccurring,orataskfinishing.RefertothespecificFPGAtargethardwaredocumentationforinformationaboutwhethertheFPGAtargetsupportsinterrupts.

Page 18: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

WaitingforandAcknowledgingaSingleInterruptCompletethefollowingstepstowaitforandacknowledgeasingleinterruptinahostVI.

1. OpenareferencetotheFPGAVIorbitfilethatgeneratesinterrupts.

2. PlacetheInvokeMethodfunctionontheblockdiagramofthehostVIinthedataflowwhereyouwantthehostVItowaitforinterruptsfromtheFPGAVI.BesuretowiretheFPGAVIReferenceIninput.

Place Find3. Right-clicktheInvokeMethodfunctionandselectMethod»Wait

onIRQfromtheshortcutmenu.4. Right-clicktheIRQNumber(s)inputontheInvokeMethod

functionandselectCreate»Constantfromtheshortcutmenu.Youalsocancreateacontrol.

5. EnterthevalueofthelogicalinterruptyouselectedintheFPGAVI.

6. WiretheTimeoutinputifyouwanttospecifythemaximumtimethehostVIwaitsfortheinterruptbeforecontinuingthedataflow.Bydefault,thehostVIdoesnotwaitforaninterrupttooccurandreturnsonlyinterruptsalreadysetbytheFPGAVI.Youalsocanwireaconstantwithavalueof–1towaitindefinitelyforaninterrupt.IfyouusetheTimeoutinput,youcanusetheTimedOutoutputtodeterminewhetherthehostVIcontinueddataflowduetothetimeoutoccurringortothereceiptofaninterrupt.Ifatimeoutoccurs,theTimedOutoutputreturnsTRUE.

7. Right-clicktheIRQ(s)AssertedoutputontheInvokeMethodfunctionandselectCreate»Indicatorfromtheshortcutmenu.LabVIEWcreatesanumericindicator.Avalueof–1indicatesthattheinterruptwasnotreceived.

8. PlacetheInvokeMethodfunctionontheblockdiagramofthehostVIinthedataflowwhereyouwantthehostVItoacknowledgetheinterruptfromtheFPGAVI.PlacetheInvokeMethodfunctioninaCaseStructureifyouwantthefunctiontoexecuteonlywhenthehostVIreceivesaninterrupt.Ifyouwirea

Page 19: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

BooleanconstantofTRUEtotheWaitUntilClearedinputoftheInterruptVI,placetheInvokeMethodfunctioninthedataflowwhereyouwanttotelltheInterruptVItostopwaiting.BesuretowiretheFPGAVIReferenceIninputoftheInvokeMethodfunction.

Place Find9. Right-clicktheInvokeMethodfunctionandselect

Method»AcknowledgeIRQfromtheshortcutmenu.UsetheAcknowledgeIRQmethodtoacknowledgethelogicalinterruptreturnedbytheWaitonIRQmethod.

10. WiretheIRQ(s)AssertedoutputoftheWaitonIRQmethoddirectlytotheIRQNumber(s)inputoftheAcknowledgeIRQmethod.

Page 20: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

WaitingforandAcknowledgingMultipleInterruptsCompletethefollowingstepstowaitforandacknowledgemultipleinterruptsinahostVI.

1. OpenareferencetotheFPGAVIorbitfilethatgeneratesinterrupts.

2. PlacetheInvokeMethodfunctionontheblockdiagramofthehostVIinthedataflowwhereyouwantthehostVItowaitforinterruptsfromtheFPGAVI.BesuretowiretheFPGAVIReferenceIninput.

Place Find3. Right-clicktheInvokeMethodfunctionandselectMethod»Wait

onIRQfromtheshortcutmenu.4. PlaceanArrayConstantontheblockdiagram.Anarrayincludes

anindexdisplayontheleft,anelementdisplayontheright,andanoptionallabel.

Place Find5. PlaceaNumericConstantinthearray.

Place Find

6. UsingthePositioningtool,expandthearrayconstanttothenumberofinterruptsneeded.

7. Enterthevaluesofthelogicalinterrupts.8. WirethearrayconstanttotheIRQNumber(s)input.9. WiretheTimeoutinputifyouwanttospecifythemaximumtime

thehostVIwaitsfortheinterruptbeforecontinuingthedataflow.Bydefault,thehostVIdoesnotwaitforaninterrupttooccurandreturnsonlyinterruptsalreadysetbytheFPGAVI.Youalsocanwireaconstantwithavalueof–1towaitindefinitelyforaninterrupt.IfyouusetheTimeoutinput,youcanusetheTimedOutoutputtodeterminewhetherthehostVIcontinueddataflowduetothetimeoutoccurringortothereceiptofaninterrupt.Ifatimeoutoccurs,theTimedOutoutputreturnsTRUE.

10. Right-clicktheIRQ(s)AssertedoutputontheInvokeMethod

Page 21: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

functionandselectCreate»Indicatorfromtheshortcutmenu.LabVIEWcreatesanarrayindicator.TheIRQ(s)Assertedfrontpanelindicatordisplaysthenumber(s)oftheinterruptstheFPGAtargetasserts.Anemptyarrayindicatesthatnointerruptswerereceived.

11. PlacetheInvokeMethodfunctionontheblockdiagramofthehostVIinthedataflowwhereyouwantthehostVItoacknowledgetheinterruptsfromtheFPGAVI.PlacetheInvokeMethodfunctioninaCaseStructureifyouwantthefunctiontoexecuteonlywhenthehostVIreceivesaninterrupt.IfyouwireaBooleanconstantofTRUEtotheWaitUntilClearedinputoftheInterruptVI,placetheInvokeMethodfunctioninthedataflowwhereyouwanttotelltheInterruptVItostopwaiting.BesuretowiretheFPGAVIReferenceIninputoftheInvokeMethodfunction.

Place Find12. Right-clicktheInvokeMethodfunctionandselect

Method»AcknowledgeIRQfromtheshortcutmenu.UsetheAcknowledgeIRQmethodtoacknowledgethelogicalinterruptsreturnedbytheWaitonIRQmethod.

13. WiretheIRQ(s)AssertedoutputoftheWaitonIRQmethoddirectlytotheIRQNumber(s)inputoftheAcknowledgeIRQmethod.

Page 22: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

ForcinganFPGAVItoDownloadtoanFPGATarget(FPGAInterface)LabVIEWautomaticallydownloadsacompiledFPGAVItotheFPGAtargetwhenyouinvoketheOpenFPGAVIReferencefunction.LabVIEWalsoautomaticallycompiles,downloads,andrunsanFPGAVIontheFPGAtargetwhenyouclicktheRunbuttoninanFPGAVIiftheFPGAtargetsupportsInteractiveFrontPanelCommunication.LabVIEWdoesnotdownloadtheFPGAVIiftheVIisalreadyontheFPGAtargetoriftheFPGAisreservedforotherpurposes.Youcanforceadownloadbyright-clickingtheFPGAVIintheProjectExplorerwindowandselectingDownloadfromtheshortcutmenu.FPGAtargetfunctionalityvariesdependingonthespecifictarget.RefertothespecificFPGAtargethardwaredocumentationforinformationaboutdownloadingoptionsavailableforthetarget.YoualsocanprogrammaticallyforceLabVIEWtodownloadanFPGAVIorbitfiletoanFPGAtargetfromahostVI.CompletethefollowingstepstoprogrammaticallyforceanFPGAVIorbitfiletodownload.

1. OpenareferencetotheFPGAVIorbitfile.NoteTheFPGAtarget,FPGAVI,andhostVImustbeinthesameLabVIEWprojectifyouwanttoopenareferencetoanFPGAVI.ThehostVIdoesnotneedtobeinaprojectifyouopenareferencetoabitfile.

2. PlaceanInvokeMethodfunctionontheblockdiagram.

Place Find3. WiretheFPGAVIReferenceOutparameteroftheOpenFPGA

VIReferencefunctiontotheFPGAVIReferenceInparameteroftheInvokeMethodfunction.

4. Right-clicktheInvokeMethodfunctionandselectMethod»Downloadfromtheshortcutmenu.

IfyouprogrammaticallydownloadtheFPGAVItotheFPGAtargetwiththeInvokeMethodfunction,youalsomustprogrammaticallyruntheFPGAVIontheFPGAtargetwiththeInvokeMethodfunction.PlaceanotherInvokeMethodfunctionontheblockdiagramandselect

Page 23: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

Method»RunfromtheshortcutmenuoftheInvokeMethodfunctiontoprogrammaticallyrunanFPGAVIorbitfile.

Page 24: FPGA Module How-To - documentation.help · LabVIEW FPGA Module installed. Communicating with FPGA VIs (FPGA Interface) This book provides functions and procedures that enable host

Stopping,Aborting,andResettingFPGAVIs(FPGAInterface)IfyoucreateanFPGAVIthatyouwanttostopandrunagainfromahostVI,NationalInstrumentsrecommendsthatyoudesigntheFPGAVIsothatyoucanstopitsexecutionbysettingacontrolontheFPGAVItoacertainvalue.ThisdesignpracticeallowsyoutocontrolhowtheFPGAVIisstoppedandthevaluesontheoutputsontheFPGAtargetwhentheFPGAVIstops.YoucanstoptheFPGAVIfromthehostVIbywritingtherelevantFPGAVIcontrol.YouthencanruntheFPGAVIbyusingtheInvokeMethodfunctionwiththeRunmethod.IfyoudonotneedcontroloftheFPGAtargetoutputs,youcanusetheInvokeMethodfunctionwiththeResetmethodtoabortandrestoretheFPGAVItothedefaultstate.IfstoppingisnotdesignedaspartoftheFPGAVI,youcanresetand/oraborttheFPGAVIfromthehostVIusingtheResetmethodorAbortmethod.TheAbortmethoddoesnotresettheFPGAVItothedefaultstatewhichmightaffecthowtheFPGAVIreactstofutureexecutionsoftheRunmethodfromthehostVI.


Recommended