Texas Instruments TMS320 DSP Computer Hardware User Manual


 
www.ti.com
5.1CPURegisterTypes
Read−only Scratch Preserve
Init
Global
Local
Read−write
CPURegisterTypes
DSPalgorithmsareoftenwritteninassemblylanguageand,asaresult,theywilltakefulladvantageof
theinstructionset.Unfortunatelyforthesystemintegrator,thisoftenmeansthatmultiplealgorithms
cannotbeintegratedintoasinglesystembecauseofincompatibleassumptionsabouttheuseofspecific
featuresoftheDSP(e.g.,useofoverflowmode,useofdedicatedregisters,etc.).Thischaptercovers
thoseguidelinesthatarespecifictoaparticularDSPinstructionset.Theseguidelinesaredesignedto
maximizetheflexibilityofthealgorithmimplementers,whileatthesametimeensurethatmultiple
algorithmscanbeintegratedintoasinglesystem.
Forthepurposeoftheguidelinesbelow,wedefineseveralcategoriesofregistertypes.
Scratchregister-theseregisterscanbefreelyusedbyanalgorithm,cannotbeassumedtocontain
anyparticularvalueuponentrytoanalgorithmfunction,andcanbeleftinanystateafterexitinga
function.
Preserveregisters-theseregistersmaybeusedbyanalgorithm,cannotbeassumedtocontainany
particularvalueuponentrytoanalgorithmfunction,butmustberestoreduponexitfromanalgorithm
tothevalueithadatentry.
Initializedregister-theseregistersmaybeusedbyanalgorithm,containaspecifiedinitialvalueupon
entrytoanalgorithmfunction(asstatednexttotheregister),andmustberestoreduponexitfromthe
algorithm.
Read-onlyregister-theseregistersmaybereadbutmustnotbemodifiedbyanalgorithm.
Inadditiontothecategoriesdefinedabove,allregisterscanbefurtherclassifiedasbeingeitherlocalor
global.Localregistersarethreadspecific;i.e.,everythreadmaintainsitsowncopyofthisregisteranditis
activewheneverthisthreadisrunning.Globalregisters,ontheotherhand,aresharedbyallthreadsin
thesystem;ifonethreadchangesaglobalregisterthenallthreadswillseethechange.
Figure5-1belowdepictstherelationshipamongthevariousregistertypesdefinedabove.
Figure5-1.RegisterTypes
Inpreemptivesystems,globalregisterscanchangeatanypointthatpreemptionmayoccur.Local
registers,ontheotherhand,canonlybemodifiedbythecurrentexecutingthread.Thus,applicationcode
thatdependsexclusivelyonlocalregisterswillbeunaffectedbyotherpreemptingthreads.Conversely,
applicationcodethatdependsonglobalregistersmustpreventpreemptionaroundthosesectionsthat
havethisdependence.
Guideline10
Algorithmsshouldavoidtheuseofglobalregisters.
DSP-SpecificGuidelines 46SPRU352GJune2005RevisedFebruary2007
SubmitDocumentationFeedback