关闭

关闭

封号提示

内容

首页 Programming languages - C - Extensions to suppo…

Programming languages - C - Extensions to support embedded processors.pdf

Programming languages - C - Ext…

上传者: 老赞 2011-10-30 评分 4.5 0 70 9 316 暂无简介 简介 举报

简介:本文档为《Programming languages - C - Extensions to support embedded processorspdf》,可适用于IT/计算机领域,主题内容包含ISOIECJTCSCWGNDate:Referencenumberofdocument:ISOIECTRCommitteeidentificati符等。

ISOIECJTCSCWGNDate:Referencenumberofdocument:ISOIECTRCommitteeidentification:ISOIECJTCSCWGSCSecretariat:ANSIInformationTechnologyProgramminglanguagesCExtensionstosupportembeddedprocessorsWarningThisdocumentisanISOIECdraftTechnicalReportItisnotanISOIECInternationalTechnicalReportItisdistributedforreviewandcommentItissubjecttochangewithoutnoticeandshallnotbereferredtoasanInternationalTechnicalReportorInternationalStandardRecipientsofthisdraftareinvitedtosubmit,withtheircomments,notificationofanyrelevantpatentrightsofwhichtheyareawareandtoprovidesupportingdocumentationDocumenttype:TechnicalReportTypeDocumentsubtype:naDocumentstage:()ApprovalDocumentlanguage:ECopyrightnoticeThisISOdocumentisaworkingdraftorcommitteedraftandiscopyrightprotectedbyISORequestsforpermissiontoreproducethisdocumentforthepurposeofsellingitshouldbeaddressedasshownbelowortoISO’smemberbodyinthecountryoftherequester:ISOcopyrightofficeCasepostaleCHGenevaTelFaxEmailcopyrightisoorgWebwwwisoorgReproductionforsalespurposesmaybesubjecttoroyaltypaymentsoralicensingagreementViolatorsmaybeprosecutedContentsPageScopeReferencesConformanceFixedpointarithmeticOverviewandprinciplesofthefixedpointdatatypesThedatatypesSpellingofthenewkeywordsRoundingandOverflowTypeconversion,usualarithmeticconversionsFixedpointconstantsOperationsinvolvingfixedpointtypesFixedpointfunctionsFixedpointdefinitions<stdfixh>FormattedIOfunctionsforfixedpointargumentsDetailedchangestoISOIEC:NamedaddressspacesandnamedregisterstorageclassesOverviewandprinciplesofnamedaddressspacesAdditionaladdressspacesAddressspacetypequalifiersAddressspacenestingandrulesforpointersStandardlibrarysupportOverviewandprinciplesofnamedregisterstorageclassesAccesstomachineregistersNamedregisterstorageclassspecifiersEnsuringcorrectsideeffectsviaobjectsallocatedinregistersRelationshipbetweennamedregistersandIOregisterdesignatorsDetailedchangestoISOIEC:BasicIOhardwareaddressingRationaleBasicStandardizationObjectivesTerminologyBasicIOHardwareaddressingheader<iohwh>StandardizationprinciplesTheabstractmodelSpecifyingIOregistersIOregisterdesignatorsAccessestoindividualIOregistersIOregisterbuffersIOgroupsDirectandindirectdesignatorsOperationsonIOgroupsDetailedchangestoISOIEC:AnnexAFixedpointarithmeticAFixedpointdatatypesAIntroductionANumberofdatabitsinFractversusAccumAPossibleDataTypeImplementationsARoundingandOverflowATypeconversions,usualarithmeticconversionsAOperationsinvolvingfixedpointtypesAExceptionforand–MultiplicationResultsALinguisticVariablesandunsignedFract:anexampleofunsignedfixedpointAnnexBNamedaddressspacesandnamedregisterstorageclassesBEmbeddedsystemsextendedmemorysupportBModifiersfornamedaddressspacesBApplicationdefinedmultipleaddressspacesupportBIOregisterdefinitionforintrinsicoruserdefinedaddressspacesAnnexCImplementingthe<iohwh>headerCGeneralCRecommendedstepsCCompilerconsiderationsCOverviewofIOHardwareConnectionOptionsCMultiAddressingandIORegisterEndiannessCAddressInterleavingCIOConnectionOverview:CGenericbufferindexCIOregisterdesignatorsfordifferentIOaddressingmethodsCAtomicoperationCReadmodifywriteoperationsandmultiaddressingcasesCIOinitializationCIntrinsicFeaturesforIOHardwareAccessAnnexDMigrationpathfor<iohwh>implementationsDMigrationpathfor<iohwh>implementationsD<iohwh>implementationbasedonCmacrosDTheaccessspecificationmethodDAn<iohwh>implementationtechniqueDFeaturesDThe<iohwh>headerDTheuser’sIOregisterdesignatordefinitionsDThedriverfunctionAnnexEFunctionalitynotincludedinthisTechnicalReportECircularbuffersEComplexdatatypesEConsiderationofBCDdatatypesforEmbeddedSystemsEModwrapoverflowAnnexFCCompatibilityandMigrationissuesFFixedpointArithmeticFMultipleAddressSpacesSupportFBasicIOHardwareAddressingAnnexG–UpdatesandChangesintheSecondEditionofTRForewordISO(theInternationalOrganizationforStandardization)andIEC(theInternationalElectrotechnicalCommission)formthespecializedsystemforworldwidestandardizationNationalbodiesthataremembersofISOorIECparticipateinthedevelopmentofInternationalStandardsthroughtechnicalcommitteesestablishedbytherespectiveorganizationtodealwithparticularfieldsoftechnicalactivityISOandIECtechnicalcommitteescollaborateinfieldsofmutualinterestOtherinternationalorganizations,governmentalandnongovernmental,inliaisonwithISOandIEC,alsotakepartintheworkTechnicalReportsaredraftedinaccordancewiththerulesgivenintheISOIECDirectives,Part Inthefieldofinformationtechnology,ISOandIEChaveestablishedajointtechnicalcommittee,ISOIEC JTC DraftTechnicalReportsadoptedbythejointtechnicalcommitteearecirculatedtonationalbodiesforvotingPublicationasaTechnicalReportrequiresapprovalbyatleastofthememberbodiescastingavoteThemaintaskoftechnicalcommitteesistoprepareInternationalStandards,butinexceptionalcircumstancesatechnicalcommitteemayproposethepublicationofaTechnicalReportofoneofthefollowingtypes:type,whentherequiredsupportcannotbeobtainedforthepublicationofanInternationalStandard,despiterepeatedeffortstype,whenthesubjectisstillundertechnicaldevelopmentorwhereforanyotherreasonthereisthefuturebutnotimmediatepossibilityofanagreementonanInternationalStandardtype,whenatechnicalcommitteehascollecteddataofadifferentkindfromthatwhichisnormallypublishedasanInternationalStandard("stateoftheart",forexample)TechnicalReportsoftypesandaresubjecttoreviewwithinthreeyearsofpublication,todecidewhethertheycanbetransformedintoInternationalStandardsTechnicalReportsoftypedonotnecessarilyhavetoberevieweduntilthedatatheyprovideareconsideredtobenolongervalidorusefulISOIECTR,whichisaTechnicalReportoftype,waspreparedbyJointTechnicalCommitteeISOIEC JTC ,Informationtechnology,SubcommitteeSC,Programminglanguages,theirenvironments,andsystemsoftwareinterfacesEDITOR’SNOTEFORTHESCREVIEWVERSIONThefunctionaldifferencesbetweenthefirsteditionofTRandthisversionaredetailedinAnnexGDuetothedifferentfontsusedandthedetailedlayout,inafulldiffbarreddocumentthesedifferencesareblurredIfhoweversuchaversionisnecessaryforaproperreview,pleasecontacttheprojecteditorMrWillemWakker(willemwacenl)IntroductionInthefastgrowingmarketofembeddedsystemsthereisanincreasingneedtowriteapplicationprogramsinahighlevellanguagesuchasCBasicallytherearetworeasonsforthistrend:programsforembeddedsystemsbecomemorecomplex(andhencearedifficulttomaintaininassemblylanguage),andprocessormodelsforembeddedsystemshaveadecreasinglifespan(whichimpliesmorefrequentreadaptingofapplicationstonewinstructionsets)ThecodereusabilityachievedbyClevelprogrammingisconsideredtobeamajorstepforwardinaddressingtheseissuesVarioustechnicalareashavebeenidentifiedwherefunctionalityofferedbyprocessors(suchasDSPs)thatareusedinembeddedsystemscannoteasilybeexploitedbyapplicationswritteninCExamplesarefixedpointoperations,usageofdifferentmemoryspaces,lowlevelIOoperationsandothersThecurrentproposaladdressesonlyafewofthesetechnicalareasEmbeddedprocessorsareoftenusedtoanalyzeanaloguesignalsandprocessthesesignalsbyapplyingfilteringalgorithmstothedatareceivedTypicalapplicationscanbefoundinallwirelessdevicesThecommondatatypeusedinfilteringalgorithmsisthefixedpointdatatype,andinordertoachievethenecessaryspeed,embeddedprocessorsareoftenequippedwithspecialhardwareforfixedpointdataTheClanguage(asdefinedinISOIEC:)doesnotprovidesupportforfixedpointarithmeticoperations,currentlyleavingprogrammerswithnooptionbuttohandcraftmostoftheiralgorithmsinassemblylanguageThisTechnicalReportspecifiesafixedpointdatatypeforC,definableinarangeofprecisionandsaturationoptionsOptimizingCcompilerscangeneratehighlyefficientcodeforfixedpointdataaseasilyasforintegerandfloatingpointdataManyembeddedprocessorshavemultipledistinctbanksofmemoryandrequirethatdatabegroupedindifferentbankstoachievemaximumperformanceEnsuringthesimultaneousflowofdataandcoefficientdatatothemultiplieraccumulatorofprocessorsdesignedforFIRfiltering,forexample,iscriticaltotheiroperationInordertoallowtheprogrammertodeclarethememoryspacefromwhichaspecificdataobjectmustbefetched,thisTechnicalReportspecifiesbasicsupportformultipleaddressspacesAsaresult,optimizingcompilerscanutilizetheabilityofprocessorsthatsupportmultipleaddressspaces,forinstance,toreaddatafromtwoseparatememoriesinasinglecycletomaximizeexecutionspeedAstheClanguagehasmaturedovertheyears,variousextensionsforaccessingbasicIOhardware(iohw)registershavebeenaddedtoaddressdeficienciesinthelanguageTodayalmostallCcompilersforfreestandingenvironmentsandembeddedsystemssupportsomemethodofdirectaccesstoiohwregistersfromtheCsourcelevelHowever,theseextensionshavenotbeenconsistentacrossdialectsThisTechnicalReportprovidesanapproachtocodifyingcommonpracticeandprovidingasingleuniformsyntaxforbasiciohwregisteraddressingThefirsteditionofthisTechnicalReportwaspublishedasISOIECTR:thissecondeditionincludesanumberofcorrectionsandupdates,basedonimplementationexperiencesThemostimportantchangesaredescribedinAnnexGInformationTechnologyProgramminglanguagesCExtensionstosupportembeddedprocessorsScopeThisTechnicalReportspecifiesaseriesofextensionsoftheprogramminglanguage C,specifiedbytheinternationalstandardISOIEC :EachclauseinthisTechnicalReportdealswithaspecifictopicThefirstsubclausesofclauses ,andcontainatechnicaldescriptionofthefeaturesofthetopicThesesubclausesprovideanoverviewbutdonotcontainallthefinedetailsThelastsubclauseofeachclausecontainstheeditorialchangestothestandardnecessarytofullyspecifythetopicinthestandard,andtherebyprovidesacompletedefinitionAdditionalexplanationandrationaleareprovidedintheAnnexesReferencesThefollowingreferenceddocumentsareindispensablefortheapplicationofthisdocumentFordatedreferences,onlytheeditioncitedappliesForundatedreferences,thelatesteditionofthereferenceddocument(includinganyamendments)appliesISOIEC:–ProgramminglanguagesCConformanceThisTechnicalReportpresentsinthreeseparateclausesspecificationsforthree,inprincipleindependent,setsoffunctionality(clause :fixedpointarithmetic,clause :namedaddressspacesandnamedregisterstorageclasses,andclause :basicIOhardwareaddressing)AsthisisaTechnicalReporttherearenoconformancerequirementsandimplementersarefreetoselectthosespecificationsthattheyneedHowever,iffunctionalityisimplementedfromoneoftheclauses,implementersarestronglyencouragedtoimplementthatclauseinfull,andnotjustapartofitIf,atalaterstage,adecisionistakentoincorporatesomeorallofthetextofthisTechnicalReportintotheC standard,thenatthatmomenttheconformanceissueswithrespectto(partsof)thistextneedtobeaddressed(conformancewithrespecttofreestandingimplementationsetc)FixedpointarithmeticOverviewandprinciplesofthefixedpointdatatypesThedatatypesForthepurposeofthisTechnicalReport,fixedpointdatavaluesareeitherfractionaldatavalues(withvaluebetweenand),ordatavalueswithanintegralpartandafractionalpartAsthepositionoftheradixpointisknownimplicitly,operationsonthevaluesofthesedatatypescanbeimplementedwith(almost)thesameefficiencyasoperationsonintegralvaluesTypicalusageoffixedpointdatavaluesandoperationscanbefoundinapplicationsthatconvertanaloguevaluestodigitalrepresentationsandsubsequentlyapplysomefilteringalgorithmFormoreinformationoffixedpointdatatypes,seeclauseAintheAnnexofthisTechnicalReportForthepurposeofthisTechnicalReport,twogroupsoffixedpointdatatypesareaddedtotheC language:thefracttypesandtheaccumtypesThedatavalueofafracttypehasnointegralpart,hencevaluesofafracttypearebetweenandThevaluerangeofanaccumtypedependsonthenumberofintegralbitsinthedatatypeThefixedpointdatatypesaredesignatedwiththecorrespondingnewkeywordsandtypespecifiersFractandAccumThesetypespecifierscanbeusedincombinationwiththeexistingtypespecifiersshort,long,signedandunsignedtodesignatethefollowingtwelvefixedpointtypes:unsignedshortFractunsignedshortAccumunsignedFractunsignedAccumunsignedlongFractunsignedlongAccumsignedshortFractsignedshortAccumsignedFractsignedAccumsignedlongFractsignedlongAccumThesetwelvetypesarecollectivelycalledtheprimaryfixedpointtypesThefixedpointdatatypesshortFractshortAccumFractAccumlongFractlongAccumwithouteitherunsignedorsignedarealiasesforthecorrespondingsignedfixedpointtypesForeachprimaryfixedpointtypethereisacorresponding(butdifferent)saturatingfixedpointtype,designatedwiththetypespecifierSatTheprimaryfixedpointtypesandthesaturatingfixedpointtypesarecollectivelycalledthefixedpointtypesAnimplementationisrequiredtosupportallabovementionedtwentyfourfixedpointdatatypesJustasforintegertypes,thereisnorequirementthatthetypesallhavedifferentformatsThefixedpointtypesareassignedafixedpointrankThefollowingtypesarelistedinorderofincreasingrank:shortFract,Fract,longFract,shortAccum,Accum,longAccumEachunsignedfixedpointtypehasthesamesize(inbytes)andthesamerankasitscorrespondingsignedfixedpointtypeEachsaturatingfixedpointtypehasthesamerepresentationandthesamerankasitscorrespondingprimaryfixedpointtypeThebitsofanunsignedfixedpointtypearedividedintopaddingbits,fractionalbits,andintegralbitsThebitsofasignedfixedpointtypearedividedintopaddingbits,fractionalbits,integralbits,andasignbitThefractfixedpointtypeshavenointegralbitsconsequently,valuesofunsignedfracttypesareintherangeofto,andvaluesofsignedfracttypesareintherangeoftoTheminimalformatsforeachtypeare:signedshortFractssignedshortAccumssignedFractssignedAccumssignedlongFractssignedlongAccumsunsignedshortFractunsignedshortAccumunsignedFractunsignedAccumunsignedlongFractunsignedlongAccumsignedshortFractssignedshortAccumssignedFractssignedAccumssignedlongFractssignedlongAccumsunsignedshortFractunsignedshortAccumunsignedFractunsignedAccumunsignedlongFractunsignedlongAccum(Fortheunsignedformats,thenotation"xy"meansxintegralbitsandyfractionalbits,foratotalofx  ynonpaddingbitsTheadded"s"inthesignedformatsdenotesthesignbit)Animplementationmaygiveanyofthefixedpointtypesmorefractionalbits,andmayalsogiveanyoftheaccumtypesmoreintegralbitstherelevantrestrictionsaregiveninthetextforthenewclause (seeclauseofthisTechnicalReport)ForanexampleofunsignedfixedpointdatatypesseeASpellingofthenewkeywordsThenaturalspellingofthenewlyintroducedkeywordsFract,AccumandSat,isfract,accumandsatHowever,inordertoavoidnameclashesinexistingprogramsthenewkeywordsarehandledinthesamewayastheComplexkeywordintheISOIEC :standard:theformalnamesofthenewkeywordsstartwithanunderscore,followedbyacapitalletter,andintheforfixedpointarithmeticrequiredheader<stdfixh>,theseformalnamesareusedtodefinethenaturalspellingsasaliases,andmaybeusedtodefineotherspellings,forinstance,inanenvironmentwithpreexistingfixedpointsupportInthecodefragmentsinthisTechnicalReport,thenaturalspellingwillbeusedForinformationontheusageofthenewkeywordsinacombinedCCenvironment,seeAnnexFRoundingandOverflowConversionofarealnumericvaluetoafixedpointtypemayrequireroundingandormayoverflowIfthesourcevaluecannotberepresentedexactlybythefixedpointtype,thesourcevalueisroundedtoeithertheclosestfixedpointvaluegreaterthanthesourcevalue(roundedup)ortotheclosestfixedpointvaluelessthanthesourcevalue(roundeddown)Whenthesourcevaluedoesnotfitwithintherangeofthefixedpointtype,theconversionoverflowsOfthetwocommonapproachesforfixedpointoverflowhandling(saturationandmodularwraparound)onlysaturationisrequiredbythisTechnicalReportforadescriptionofmodularwraparound,seeAnnexEWhencalculatingthesaturatedresultonfixedpointoverflow,thesourcevalueisreplacedbytheclosestavailablefixedpointvalue(Forunsignedfixedpointtypes,thiswillbeeitherzeroorthemaximalpositivevalueofthefixedpointtypeForsignedfixedpointtypesitwillbethemaximalnegativeormaximalpositivevalueofthefixedpointtype)Overflowbehavioriscontrolledintwoways:Byusingexplicitsaturatingfixedpointtypes(eg,Sat Fract)Intheabsenceofanexplicitsaturatingfixedpointtype,overflowbehavioriscontrolledbytheFXFRACTOVERFLOWandFXACCUMOVERFLOWpragmaswithSATandDEFAULTaspossiblestatesWhenthestateoftheFXFRACTOVERFLOWpragmaisSAT,theoverfl

精彩专题

职业精品

上传我的资料

热门资料

资料评价:

/ 64
所需积分:1 立即下载

意见
反馈

返回
顶部

Q