首页 > > > Programming languages - C - Extensions to suppo…

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

Programming languages - C - Ext…

上传者: 老赞 2011-10-30 评分1 评论0 下载29 收藏10 阅读量316 暂无简介 简介 举报

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

ISO/IECJTC1SC22WG14N1275Date:2007-10-20Referencenumberofdocument:ISO/IECTR18037Committeeidentification:ISO/IECJTC1SC22WG14SC22Secretariat:ANSIInformationTechnology—Programminglanguages-C-Extensionstosupportembeddedprocessors—WarningThisdocumentisanISO/IECdraftTechnicalReport.ItisnotanISO/IECInternationalTechnicalReport.Itisdistributedforreviewandcomment.ItissubjecttochangewithoutnoticeandshallnotbereferredtoasanInternationalTechnicalReportorInternationalStandard.Recipientsofthisdraftareinvitedtosubmit,withtheircomments,notificationofanyrelevantpatentrightsofwhichtheyareawareandtoprovidesupportingdocumentation.Documenttype:TechnicalReportType2Documentsubtype:n/aDocumentstage:(4)ApprovalDocumentlanguage:ECopyrightnoticeThisISOdocumentisaworkingdraftorcommitteedraftandiscopyright-protectedbyISO.RequestsforpermissiontoreproducethisdocumentforthepurposeofsellingitshouldbeaddressedasshownbelowortoISO’smemberbodyinthecountryoftherequester:ISOcopyrightofficeCasepostale56CH-1211Geneva20Tel.+41227490111Fax+41227490947E-mailcopyright@iso.orgWebwww.iso.orgReproductionforsalespurposesmaybesubjecttoroyaltypaymentsoralicensingagreement.Violatorsmaybeprosecuted.ContentsPage1Scope12References13Conformance14Fixed-pointarithmetic24.1Overviewandprinciplesofthefixed-pointdatatypes24.1.1Thedatatypes24.1.2Spellingofthenewkeywords34.1.3RoundingandOverflow44.1.4Typeconversion,usualarithmeticconversions54.1.5Fixed-pointconstants64.1.6Operationsinvolvingfixed-pointtypes74.1.7Fixed-pointfunctions94.1.8Fixed-pointdefinitions<stdfix.h>114.1.9FormattedI/Ofunctionsforfixed-pointarguments114.2DetailedchangestoISO/IEC9899:1999125Namedaddressspacesandnamed-registerstorageclasses375.1Overviewandprinciplesofnamedaddressspaces375.1.1Additionaladdressspaces375.1.2Address-spacetypequalifiers375.1.3Addressspacenestingandrulesforpointers385.1.4Standardlibrarysupport395.2Overviewandprinciplesofnamed-registerstorageclasses395.2.1Accesstomachineregisters395.2.2Named-registerstorage-classspecifiers395.2.3Ensuringcorrectsideeffectsviaobjectsallocatedinregisters415.2.4RelationshipbetweennamedregistersandI/O-registerdesignators415.3DetailedchangestoISO/IEC9899:1999416BasicI/Ohardwareaddressing496.1Rationale496.1.1BasicStandardizationObjectives496.2Terminology496.3BasicI/OHardwareaddressingheader<iohw.h>516.3.1Standardizationprinciples516.3.2Theabstractmodel526.4SpecifyingI/Oregisters546.4.1I/O-registerdesignators546.4.2AccessestoindividualI/Oregisters546.4.3I/Oregisterbuffers556.4.4I/Ogroups566.4.5Directandindirectdesignators566.4.6OperationsonI/Ogroups576.5DetailedchangestoISO/IEC9899:199958AnnexA-Fixed-pointarithmetic65A.1Fixed-pointdatatypes65A.1.1Introduction65A.2Numberofdatabitsin_Fractversus_Accum68A.3PossibleDataTypeImplementations69A.4RoundingandOverflow70A.5Typeconversions,usualarithmeticconversions71A.6Operationsinvolvingfixed-pointtypes71A.7Exceptionfor1and–1MultiplicationResults72A.8LinguisticVariablesandunsigned_Fract:anexampleofunsignedfixed-point73AnnexB-Namedaddressspacesandnamed-registerstorageclasses74B.1Embeddedsystemsextendedmemorysupport74B.1.1Modifiersfornamedaddressspaces74B.1.2Application-definedmultipleaddressspacesupport75B.1.3I/Oregisterdefinitionforintrinsicoruserdefinedaddressspaces76AnnexC-Implementingthe<iohw.h>header78C.1General78C.1.1Recommendedsteps78C.1.2Compilerconsiderations78C.2OverviewofI/OHardwareConnectionOptions79C.2.1Multi-AddressingandI/ORegisterEndianness79C.2.2AddressInterleaving80C.2.3I/OConnectionOverview:80C.2.4Genericbufferindex81C.3I/O-registerdesignatorsfordifferentI/Oaddressingmethods82C.4Atomicoperation83C.5Read-modify-writeoperationsandmulti-addressingcases.83C.6I/Oinitialization84C.7IntrinsicFeaturesforI/OHardwareAccess85AnnexD-Migrationpathfor<iohw.h>implementations86D.1Migrationpathfor<iohw.h>implementations86D.2<iohw.h>implementationbasedonCmacros86D.2.1Theaccessspecificationmethod86D.2.2An<iohw.h>implementationtechnique87D.2.3Features87D.2.4The<iohw.h>header88D.2.5Theuser’sI/O-registerdesignatordefinitions91D.2.6Thedriverfunction92AnnexE-FunctionalitynotincludedinthisTechnicalReport93E.1Circularbuffers93E.2Complexdatatypes94E.3ConsiderationofBCDdatatypesforEmbeddedSystems94E.4Modwrapoverflow94AnnexF-C++CompatibilityandMigrationissues96F.1Fixed-pointArithmetic96F.2MultipleAddressSpacesSupport96F.3BasicI/OHardwareAddressing96AnnexG–UpdatesandChangesintheSecondEditionofTR1803797ForewordISO(theInternationalOrganizationforStandardization)andIEC(theInternationalElectrotechnicalCommission)formthespecializedsystemforworldwidestandardization.NationalbodiesthataremembersofISOorIECparticipateinthedevelopmentofInternationalStandardsthroughtechnicalcommitteesestablishedbytherespectiveorganizationtodealwithparticularfieldsoftechnicalactivity.ISOandIECtechnicalcommitteescollaborateinfieldsofmutualinterest.Otherinternationalorganizations,governmentalandnongovernmental,inliaisonwithISOandIEC,alsotakepartinthework.TechnicalReportsaredraftedinaccordancewiththerulesgivenintheISO/IECDirectives,Part 3.Inthefieldofinformationtechnology,ISOandIEChaveestablishedajointtechnicalcommittee,ISO/IEC JTC 1.DraftTechnicalReportsadoptedbythejointtechnicalcommitteearecirculatedtonationalbodiesforvoting.PublicationasaTechnicalReportrequiresapprovalbyatleast75%ofthememberbodiescastingavote.ThemaintaskoftechnicalcommitteesistoprepareInternationalStandards,butinexceptionalcircumstancesatechnicalcommitteemayproposethepublicationofaTechnicalReportofoneofthefollowingtypes:type1,whentherequiredsupportcannotbeobtainedforthepublicationofanInternationalStandard,despiterepeatedefforts;type2,whenthesubjectisstillundertechnicaldevelopmentorwhereforanyotherreasonthereisthefuturebutnotimmediatepossibilityofanagreementonanInternationalStandard;type3,whenatechnicalcommitteehascollecteddataofadifferentkindfromthatwhichisnormallypublishedasanInternationalStandard("stateoftheart",forexample).TechnicalReportsoftypes1and2aresubjecttoreviewwithinthreeyearsofpublication,todecidewhethertheycanbetransformedintoInternationalStandards.TechnicalReportsoftype3donotnecessarilyhavetoberevieweduntilthedatatheyprovideareconsideredtobenolongervalidoruseful.ISO/IECTR18037,whichisaTechnicalReportoftype2,waspreparedbyJointTechnicalCommitteeISO/IEC JTC 1,Informationtechnology,SubcommitteeSC22,Programminglanguages,theirenvironments,andsystemsoftwareinterfaces.EDITOR’SNOTEFORTHESC22REVIEWVERSIONThefunctionaldifferencesbetweenthefirsteditionofTR18037andthisversionaredetailedinAnnexG.Duetothedifferentfontsusedandthedetailedlay-out,inafulldiff-barreddocumentthesedifferencesareblurred.Ifhoweversuchaversionisnecessaryforaproperreview,pleasecontacttheproject-editorMr.WillemWakker(willemw@ace.nl).IntroductionInthefastgrowingmarketofembeddedsystemsthereisanincreasingneedtowriteapplicationprogramsinahigh-levellanguagesuchasC.Basicallytherearetworeasonsforthistrend:programsforembeddedsystemsbecomemorecomplex(andhencearedifficulttomaintaininassemblylanguage),andprocessormodelsforembeddedsystemshaveadecreasinglifespan(whichimpliesmorefrequentre-adaptingofapplicationstonewinstructionsets).ThecodereusabilityachievedbyC-levelprogrammingisconsideredtobeamajorstepforwardinaddressingtheseissues.Varioustechnicalareashavebeenidentifiedwherefunctionalityofferedbyprocessors(suchasDSPs)thatareusedinembeddedsystemscannoteasilybeexploitedbyapplicationswritteninC.Examplesarefixed-pointoperations,usageofdifferentmemoryspaces,lowlevelI/Ooperationsandothers.Thecurrentproposaladdressesonlyafewofthesetechnicalareas.Embeddedprocessorsareoftenusedtoanalyzeanaloguesignalsandprocessthesesignalsbyapplyingfilteringalgorithmstothedatareceived.Typicalapplicationscanbefoundinallwirelessdevices.Thecommondatatypeusedinfilteringalgorithmsisthefixed-pointdatatype,andinordertoachievethenecessaryspeed,embeddedprocessorsareoftenequippedwithspecialhardwareforfixed-pointdata.TheClanguage(asdefinedinISO/IEC9899:1999)doesnotprovidesupportforfixed-pointarithmeticoperations,currentlyleavingprogrammerswithnooptionbuttohandcraftmostoftheiralgorithmsinassemblylanguage.ThisTechnicalReportspecifiesafixed-pointdatatypeforC,definableinarangeofprecisionandsaturationoptions.OptimizingCcompilerscangeneratehighlyefficientcodeforfixed-pointdataaseasilyasforintegerandfloating-pointdata.Manyembeddedprocessorshavemultipledistinctbanksofmemoryandrequirethatdatabegroupedindifferentbankstoachievemaximumperformance.Ensuringthesimultaneousflowofdataandcoefficientdatatothemultiplier/accumulatorofprocessorsdesignedforFIRfiltering,forexample,iscriticaltotheiroperation.Inordertoallowtheprogrammertodeclarethememoryspacefromwhichaspecificdataobjectmustbefetched,thisTechnicalReportspecifiesbasicsupportformultipleaddressspaces.Asaresult,optimizingcompilerscanutilizetheabilityofprocessorsthatsupportmultipleaddressspaces,forinstance,toreaddatafromtwoseparatememoriesinasinglecycletomaximizeexecutionspeed.AstheClanguagehasmaturedovertheyears,variousextensionsforaccessingbasicI/Ohardware(iohw)registershavebeenaddedtoaddressdeficienciesinthelanguage.TodayalmostallCcompilersforfreestandingenvironmentsandembeddedsystemssupportsomemethodofdirectaccesstoiohwregistersfromtheCsourcelevel.However,theseextensionshavenotbeenconsistentacrossdialects.ThisTechnicalReportprovidesanapproachtocodifyingcommonpracticeandprovidingasingleuniformsyntaxforbasiciohwregisteraddressing.ThefirsteditionofthisTechnicalReportwaspublishedasISO/IECTR18037:2004;thissecondeditionincludesanumberofcorrectionsandupdates,basedonimplementationexperiences.ThemostimportantchangesaredescribedinAnnexG.InformationTechnology—Programminglanguages-C-Extensionstosupportembeddedprocessors1ScopeThisTechnicalReportspecifiesaseriesofextensionsoftheprogramminglanguage C,specifiedbytheinternationalstandardISO/IEC 9899:1999.EachclauseinthisTechnicalReportdealswithaspecifictopic.Thefirstsubclausesofclauses 4,5and6containatechnicaldescriptionofthefeaturesofthetopic.Thesesubclausesprovideanoverviewbutdonotcontainallthefinedetails.Thelastsubclauseofeachclausecontainstheeditorialchangestothestandardnecessarytofullyspecifythetopicinthestandard,andtherebyprovidesacompletedefinition.AdditionalexplanationandrationaleareprovidedintheAnnexes.2ReferencesThefollowingreferenceddocumentsareindispensablefortheapplicationofthisdocument.Fordatedreferences,onlytheeditioncitedapplies.Forundatedreferences,thelatesteditionofthereferenceddocument(includinganyamendments)applies.ISO/IEC9899:1999–Programminglanguages-C3ConformanceThisTechnicalReportpresentsinthreeseparateclausesspecificationsforthree,inprincipleindependent,setsoffunctionality(clause 4:fixed-pointarithmetic,clause 5:namedaddressspacesandnamed-registerstorageclasses,andclause 6:basicI/Ohardwareaddressing).AsthisisaTechnicalReporttherearenoconformancerequirementsandimplementersarefreetoselectthosespecificationsthattheyneed.However,iffunctionalityisimplementedfromoneoftheclauses,implementersarestronglyencouragedtoimplementthatclauseinfull,andnotjustapartofit.If,atalaterstage,adecisionistakentoincorporatesomeorallofthetextofthisTechnicalReportintotheC standard,thenatthatmomenttheconformanceissueswithrespectto(partsof)thistextneedtobeaddressed(conformancewithrespecttofreestandingimplementationsetc.)4Fixed-pointarithmetic4.1Overviewandprinciplesofthefixed-pointdatatypes4.1.1ThedatatypesForthepurposeofthisTechnicalReport,fixed-pointdatavaluesareeitherfractionaldatavalues(withvaluebetween-1.0and+1.0),ordatavalueswithanintegralpartandafractionalpart.Asthepositionoftheradixpointisknownimplicitly,operationsonthevaluesofthesedatatypescanbeimplementedwith(almost)thesameefficiencyasoperationsonintegralvalues.Typicalusageoffixed-pointdatavaluesandoperationscanbefoundinapplicationsthatconvertanaloguevaluestodigitalrepresentationsandsubsequentlyapplysomefilteringalgorithm.Formoreinformationoffixed-pointdatatypes,seeclauseA.1.1intheAnnexofthisTechnicalReport.ForthepurposeofthisTechnicalReport,twogroupsoffixed-pointdatatypesareaddedtotheC language:thefracttypesandtheaccumtypes.Thedatavalueofafracttypehasnointegralpart,hencevaluesofafracttypearebetween-1.0and+1.0.Thevaluerangeofanaccumtypedependsonthenumberofintegralbitsinthedatatype.Thefixed-pointdatatypesaredesignatedwiththecorrespondingnewkeywordsandtype-specifiers_Fractand_Accum.Thesetype-specifierscanbeusedincombinationwiththeexistingtype-specifiersshort,long,signedandunsignedtodesignatethefollowingtwelvefixed-pointtypes:unsignedshort_Fractunsignedshort_Accumunsigned_Fractunsigned_Accumunsignedlong_Fractunsignedlong_Accumsignedshort_Fractsignedshort_Accumsigned_Fractsigned_Accumsignedlong_Fractsignedlong_AccumThesetwelvetypesarecollectivelycalledtheprimaryfixed-pointtypes.Thefixed-pointdatatypesshort_Fractshort_Accum_Fract_Accumlong_Fractlong_Accumwithouteitherunsignedorsignedarealiasesforthecorrespondingsignedfixed-pointtypes.Foreachprimaryfixed-pointtypethereisacorresponding(butdifferent)saturatingfixed-pointtype,designatedwiththetype-specifier_Sat.Theprimaryfixed-pointtypesandthesaturatingfixed-pointtypesarecollectivelycalledthefixed-pointtypes.Animplementationisrequiredtosupportallabove-mentionedtwenty-fourfixed-pointdatatypes.Justasforintegertypes,thereisnorequirementthatthetypesallhavedifferentformats.Thefixed-pointtypesareassignedafixed-pointrank.Thefollowingtypesarelistedinorderofincreasingrank:short_Fract,_Fract,long_Fract,short_Accum,_Accum,long_AccumEachunsignedfixed-pointtypehasthesamesize(inbytes)andthesamerankasitscorrespondingsignedfixed-pointtype.Eachsaturatingfixed-pointtypehasthesamerepresentationandthesamerankasitscorrespondingprimaryfixed-pointtype.Thebitsofanunsignedfixed-pointtypearedividedintopaddingbits,fractionalbits,andintegralbits.Thebitsofasignedfixed-pointtypearedividedintopaddingbits,fractionalbits,integralbits,andasignbit.Thefractfixed-pointtypeshavenointegralbits;consequently,valuesofunsignedfracttypesareintherangeof0to1,andvaluesofsignedfracttypesareintherangeof-1to1.Theminimalformatsforeachtypeare:signedshort_Fracts.7signedshort_Accums4.7signed_Fracts.15signed_Accums4.15signedlong_Fracts.23signedlong_Accums4.23unsignedshort_Fract.7unsignedshort_Accum4.7unsigned_Fract.15unsigned_Accum4.15unsignedlong_Fract.23unsignedlong_Accum4.23signedshort_Fracts.7signedshort_Accums4.7signed_Fracts.15signed_Accums4.15signedlong_Fracts.23signedlong_Accums4.23unsignedshort_Fract.7unsignedshort_Accum4.7unsigned_Fract.15unsigned_Accum4.15unsignedlong_Fract.23unsignedlong_Accum4.23(Fortheunsignedformats,thenotation"x.y"meansxintegralbitsandyfractionalbits,foratotalofx + ynon-paddingbits.Theadded"s"inthesignedformatsdenotesthesignbit.)Animplementationmaygiveanyofthefixed-pointtypesmorefractionalbits,andmayalsogiveanyoftheaccumtypesmoreintegralbits;therelevantrestrictionsaregiveninthetextforthenewclause 6.2.5(seeclause4.2ofthisTechnicalReport).Foranexampleofunsignedfixed-pointdatatypesseeA.8.4.1.2SpellingofthenewkeywordsThenaturalspellingofthenewlyintroducedkeywords_Fract,_Accumand_Sat,isfract,accumandsat.However,inordertoavoidnameclashesinexistingprogramsthenewkeywordsarehandledinthesamewayasthe_ComplexkeywordintheISO/IEC 9899:1999standard:theformalnamesofthenewkeywordsstartwithanunderscore,followedbyacapitalletter,andintheforfixed-pointarithmeticrequiredheader<stdfix.h>,theseformalnamesareusedtodefinethenaturalspellingsasaliases,andmaybeusedtodefineotherspellings,forinstance,inanenvironmentwithpre-existingfixed-pointsupport.InthecodefragmentsinthisTechnicalReport,thenaturalspellingwillbeused.ForinformationontheusageofthenewkeywordsinacombinedC/C++environment,seeAnnexF.4.1.3RoundingandOverflowConversionofarealnumericvaluetoafixed-pointtypemayrequireroundingand/ormayoverflow.Ifthesourcevaluecannotberepresentedexactlybythefixed-pointtype,thesourcevalueisroundedtoeithertheclosestfixed-pointvaluegreaterthanthesourcevalue(roundedup)ortotheclosestfixed-pointvaluelessthanthesourcevalue(roundeddown).Whenthesourcevaluedoesnotfitwithintherangeofthefixed-pointtype,theconversionoverflows.Ofthetwocommonapproachesforfixed-pointoverflowhandling(saturationandmodularwraparound)onlysaturationisrequiredbythisTechnicalReport;foradescriptionofmodularwrap-around,seeAnnexE.4.Whencalculatingthesaturatedresultonfixed-pointoverflow,thesourcevalueisreplacedbytheclosestavailablefixed-pointvalue.(Forunsignedfixed-pointtypes,thiswillbeeitherzeroorthemaximalpositivevalueofthefixed-pointtype.Forsignedfixed-pointtypesitwillbethemaximalnegativeormaximalpositivevalueofthefixed-pointtype.)Overflowbehavioriscontrolledintwoways:Byusingexplicitsaturatingfixed-pointtypes(e.g.,_Sat _Fract).Intheabsenceofanexplicitsaturatingfixed-pointtype,overflowbehavioriscontrolledbytheFX_FRACT_OVERFLOWandFX_ACCUM_OVERFLOWpragmaswithSATandDEFAULTaspossiblestates.WhenthestateoftheFX_FRACT_OVERFLOWpragmaisSAT,theoverfl

该用户的其他资料

  • 名称/格式
  • 评分
  • 下载次数
  • 资料大小
  • 上传时间
  • 1
    69
    10.7MB
    2011-10-30

    实时嵌入式开发、系统软件开发等领域C语言是绝对的语言之王,本人收集了大家耳熟能详的所有C语言经典大作拿出来和大家分享。[立即查看]

  • 1
    35
    7.6MB
    2011-10-30
  • 1
    103
    2.2MB
    2011-10-30
  • 1
    19
    4.8MB
    2011-10-30
  • 1
    35
    11.0MB
    2011-10-30
  • 1
    78
    18.6MB
    2011-10-30
  • 1
    46
    5.9MB
    2011-10-30

    实时嵌入式开发、系统软件开发等领域C语言是绝对的语言之王,本人收集了大家耳熟能详的所有C语言经典大作拿出来和大家分享。[立即查看]

  • 0
    202
    126.9KB
    2011-10-30

    C语言之父的传世经典,一般认为有这本书就不需要其它C语言参考书了,希望对大家有帮助。[立即查看]

  • 0
    346
    4.8MB
    2011-10-30

    C语言之父的传世经典,一般认为有这本书就不需要其它C语言参考书了,希望对大家有帮助。[立即查看]

  • 0
    475
    3.1MB
    2011-10-30

    C语言之父的传世经典,一般认为有这本书就不需要其它C语言参考书了,希望对大家有帮助。[立即查看]

  • 1
    57
    1.6MB
    2011-10-30

    当前资料暂无简介~[立即查看]

  • 1
    93
    39.8MB
    2011-10-30

    如果你想成为出色的Linux开发人员,这些书籍你必须拥有,我习惯标出书籍出版的年份和页数,希望对你也有帮助。[立即查看]

用户评论

0/200
    暂无评论
上传我的资料

相关资料

资料评价:

/ 64
所需积分:1 立即下载
返回
顶部
举报
资料
关闭

温馨提示

感谢您对爱问共享资料的支持,精彩活动将尽快为您呈现,敬请期待!