www.ti.com
4.2ProgramMemory
ProgramMemory
Algorithmsmustcharacterizetheirstaticdatamemoryrequirementsbyfillingoutatablesuchasthat
illustratedbelow.Eachrowrepresentstherequirementsforanindividualobjectfilethatispartofthe
algorithm'simplementation.EachnamedCOFFsection(thatcontainsdata)inthealgorithm'sobjectfiles
isrepresentedbyacolumn.Eachentryshouldcontainthesize(in8-bitbytes)requiredbythealgorithm,
anyalignmentrequirements,whetherthedataisread-onlyorread-write,andwhetherthedataisscratch
memoryornot.Ifnospecialalignmentisrequired,thealignmentnumbershouldbesettozero.
.data.bss
ObjectfilesSizeAlignRead/WriteScratchSizeAlignRead/WriteScratch
a.obj120Rno320Rno
b.obj00Rno00Rno
Staticdatainanalgorithmforcesthesystemintegratortodedicatearegionofthesystem'smemorytoa
singlespecificpurpose.Whilethismaybedesirableinsomesystems,itisrarelytherightdecisionforall
systems.Moreover,modifiablestaticdatausuallyindicatesthatthealgorithmisnotreentrant.Unless
specialprecautionsaretaken,itisnotpossibleforareentrantfunctiontomodifystaticdata.
Guideline6
Algorithmsshouldminimizetheirstaticmemoryrequirements.
Withtheexceptionofinitializeddata,itispossibletovirtuallyeliminateallstaticdatainanalgorithmusing
theeXpressDSP-compliantIALGinterface.TheimplementationofinterfacesisdescribedinSection3.2
andadetaileddescriptionoftheIALGinterfaceisprovidedintheTMS320DSPAlgorithmStandardAPI
Reference.
Guideline7
Algorithmsshouldneverhaveanyscratchstaticmemory.
Algorithmcodecanoftenbepartitionedintotwodistincttypes:frequentlyaccessedcodeandinfrequently
accessedcode.Obviously,innerloopsofalgorithmsarefrequentlyaccessed.However,likemost
applicationcode,itisoftenthecasethatafewfunctionsaccountformostoftheMIPSrequiredbyan
application.
Guideline8
Algorithmcodeshouldbepartitionedintodistinctsectionsandeachsectionshouldbecharacterizedby
theaveragenumberofinstructionsexecutedperinputsample.
Characterizingthenumberofinstructionspersampleforeachalgorithmallowssystemintegratorsto
optimallyassignon-chipprogrammemorytotheappropriatealgorithms.Italsoallowsonetoperforma
quantitativecost/benefitanalysisofsimpleon-chipprogramoverlaypolicies,forexample.
Rule22
Allalgorithmsmustcharacterizetheirprogrammemoryrequirements.
Allalgorithmsmustcharacterizetheirprogrammemoryrequirementsbyfillingoutatablesuchasthat
shownbelow.Eachentryshouldcontainthesize(in8-bitbytes)requiredbythealgorithmandany
alignmentrequirements.Ifnospecialalignmentisrequired,thealignmentnumbershouldbesettozero
40AlgorithmPerformanceCharacterizationSPRU352G–June2005–RevisedFebruary2007
SubmitDocumentationFeedback