Texas Instruments TMS320 DSP Computer Hardware User Manual


 
www.ti.com
3.1.7ModuleConfiguration
3.1.8ExampleModule
InterfacesandModules
Guideline4
Allmodulesthatsupportobjectcreationshouldsupportrun-timeobjectcreation.
NotethattheeXpressDSP-compliantalgorithmsareaspecialtypeofmodule.Whenwedefinealgorithms
below,wewillseehowalgorithmssupportrun-timeobjectcreation.Theguidelineaboveisintendedto
covermodulessuchasthosethatmakeupthecorerun-timesupportaswellasthe
eXpressDSP-compliantalgorithms.
Inanidealworld,amodulethatimplementsanAPIcanbeusedinanysystemthatrequirestheAPI.Asa
practicalmatter,however,everymoduleimplementationmustmaketrade-offsamongavarietyof
performancemetrics;programsize,datasize,MIPS,andavarietyofapplicationspecificmetricssuchas
recognitionaccuracy,perceivedaudioquality,andthroughput,forexample.Thus,asingleimplementation
ofanAPIisunlikelytomaketherightsetoftradeoffsforallapplications.
Itisimportant,therefore,thatmultipleimplementationsofthesameAPIbewellsupportedbyany
eXpressDSP-standarddevelopmentframework.Inaddition,eachmodulehasoneormore"global
configuration"parametersthatcanbesetatdesigntimebythesystemintegratortoadjustthebehaviorof
themoduletobeoptimalforitsexecutionenvironment.
Supposeforexample,thatonecreatedamodulethatimplementsdigitalfilters.Thereareseveralspecial
casesfordigitalfiltersthathavesignificantperformancedifferences;all-pole,all-zero,andpole-zerofilters.
Moreover,forTIarchitectures,ifoneassumesthatthefilter'sdatabuffersarealignedoncertain
boundariestheimplementationcantakeadvantageofspecialdataaddressingmodesandsignificantly
reducethetimerequiredtocompletethecomputation.Afiltermodulemayincludeaglobalconfiguration
parameterthatspecifiesthatthesystemwillonlyuseall-zerofilterswithaligneddata.Bymakingthisa
design-timeglobalconfigurationparameter,systemsthatarewillingtoacceptconstraintsintheiruseof
theAPIarerewardedbysmallerfasteroperationofthemodulethatimplementstheAPI.
Modulesthathaveoneormore"global"configurationparametersshouldgroupthemtogetherintoaC
structure,calledXYZ_Config,anddeclarethisstructureinthemodule'sheader.Inaddition,themodule
shoulddeclareaglobalstructurenamedXYZoftypeXYZ_Configthatcontainsthemodule'scurrent
configurationparameters.
Thissectiondevelopsaverysimplemoduletoillustratetheconceptofmodulesandhowtheymightbe
implementedintheClanguage.ThismoduleimplementsasimpleFIRfilter.
Thefirsttwooperationsthatmustbesupportedbyallmodulesaretheinit()andexit()functions.Theinit()
functioniscalledduringsystemstartupwhiletheexit()functioniscalledduringsystemshutdown.These
entrypointsexisttoallowthemoduletoperformanyrun-timeinitializationnecessaryforthemoduleasa
whole.Moreoftenthannot,thesefunctionshavenothingtodoandaresimplyemptyfunctions.
voidFIR_init(void)
{
}
voidFIR_exit(void)
{
}
Thecreateentrypointcreatesandinitializesanobject;i.e.,aCstructure.Theobjectencapsulatesallthe
statenecessaryfortheotherfunctionstodotheirwork.Alloftheothermoduleentrypointsarepasseda
pointertothisobjectastheirfirstargument.Ifthefunctionsonlyreferencedatathatispartoftheobject
(orreferencedwithintheobject),thefunctionswillnaturallybereentrant.
typedefstructFIR_Params{/*FIR_Objcreationparameters*/
intframeLen;/*input/outputframelength*/
int*coeff;/*pointertofiltercoefficients*/
}FIR_Params;
FIR_ParamsFIR_PARAMS={64,NULL};/*defaultparameters*/
30AlgorithmComponentModelSPRU352GJune2005RevisedFebruary2007
SubmitDocumentationFeedback