Texas Instruments TMS320 DSP Computer Hardware User Manual


 
www.ti.com
3.1InterfacesandModules
client.c
#include <fir.h>
...
FIR_apply();
}
fir.h
typedef struct FIR_obj *FIR_Handle;
extern void FIR_init();
extern void FIR_exit();
extern FIR_HandleFIR_create();
fir_apply.asm
FIR_apply:
.globalFIR_apply
fir_create.c
FIR_HandleFIR_create() {
Includes
Interface
Implementation
InterfacesandModules
Theserulesandguidelinesenablemanyofthebenefitsnormallyassociatedwithobject-orientedand
component-basedprogrammingbutwithlittleornooverhead.Moreimportantly,theseguidelinesare
necessarytoenabletwodifferentalgorithmstobeintegratedintoasingleapplicationwithoutmodifying
thesourceCodeofthealgorithms.Therulesincludenamingconventionstopreventduplicateexternal
nameconflicts,auniformmethodforinitializingalgorithms,andspecificationofauniformdatamemory
managementmechanism.
Thissectiondescribesthegeneralstructureofthemostbasicsoftwarecomponentofthe
eXpressDSP-compliantapplication—themodule.Sinceallstandard-compliantalgorithmsareimplemented
asmodules,thissectiondescribesthedesignelementscommontoallofthem.Thisstructureisdesigned
toencouragebothmodularcodingpracticesandreentrantimplementations.
Amoduleisanimplementationofone(ormore)interfaces.Aninterfaceissimplyacollectionofrelated
typedefinitions,functions,constants,andvariables.IntheClanguage,aninterfaceistypicallyspecified
byaheaderfile.Itisimportanttonotethatnotallmodulesimplementalgorithms,butallalgorithm
implementationsmustbemodules.Forexample,theDSP/BIOSisacollectionofmodulesandnoneof
theseareeXpressDSP-compliantalgorithms.
AlleXpressDSP-compliantmodules:
Provideasingleheaderthatdefinestheentireinterfacetothemodule
Implementamoduleinitializationandfinalizationmethod
Optionallymanageoneormore"instance"objectsofasingletype
Optionallydeclarea"Config"structuredefiningmodule-wideconfigurationoptions
SupposewecreateamodulecalledFIR,whichconsistsofacollectionoffunctionsthatcreateandapply
finiteimpulseresponsefilterstoadatastream.TheinterfacetothismoduleisdeclaredinthesingleC
headerfile,fir.h.AnyapplicationthatwantstousethefunctionsprovidedbytheFIRmodulemustinclude
theheaderfir.h.AlthoughtheinterfaceisdeclaredasaCheaderfile,themodulemaybeimplemented
entirelyinassemblylanguage(oramixofbothCandassembly).
Figure3-1.ModuleInterfaceandImplementation
Sinceinterfacesmaybuildatopotherinterfaces,itisimportantthatallheaderfilesallowforthepossibility
thattheymightbeincludedmorethanoncebyaclient.
26AlgorithmComponentModelSPRU352GJune2005RevisedFebruary2007
SubmitDocumentationFeedback