计算机组成与结构体系英文课件:Chapter-3-–-Basic-InputOutput_第1页
已阅读1页,还剩66页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

ComputerOrganization&Architecture

Chapter3–BasicInput/OutputContentofthislecture3.1AccessingI/ODevices3.2Interrupts8.4DirectMemoryAccessSummaryAccessingI/ODevices(1)I/ODevicesLinktotheoutsideworldTypesHumanreadableMonitorPrinterMachinereadableDiskCDROMScannerCommunicationModemNetworkInterfaceCard(NIC)AccessingI/ODevices(2)ExamplesofI/ODevicesDevice Input/Output DateRate(Kbytes/s)Keyboard Input 0.01Mouse Input 0.02Voiceinput(microphone)Input 0.02Scanner Input 200Voiceoutput(speaker) Output 0.5Dot-matrixprinter Output 1Laserprinter Output 100Graphicsdisplay Output 30,000Localareanetwork Input/output 200–20,000Opticaldisk Storage(I/O) 500Magnetictape Storage(I/O) 2,000Magneticdisk Storage(I/O) 2,000AccessingI/ODevices(3)AccessingI/ODevices(4)AccessingI/ODevices(ctd.)AccessingI/ODevices(5)AccessingI/ODevices(6)I/ODeviceInterfaceTheaddressdecoder,thedataandstatusregisters,andthecontrolcircuitryconstitutethedevice’sinterfacecircuit.AccessingI/ODevices(7)I/OInterface(ctd.)FunctionsofinterfaceDevicecommunicationControl:DeterminewhetherdevicewillsendorreceivedataData:ActualdatatransferredStatus:Deviceisready,DataisavailablefortransferorerrorDatabufferingMusthandlevaryingdataratesfrommemoryandI/OdeviceBufferdatasothatnoonegetstieddownErrordetectionReporttoCPUmechanicalfailuree.g.paperjamReportdatatransmissionerrorAccessingI/ODevices(8)I/OInterface(ctd.)Functionsofinterface(ctd.)ControlandSignalingCo-ordinatesdatatransferbasedoncommunicationmethodwiththeprocessorCommunicationwithCPUProgrammeda.k.aPollingInterruptdrivenDirectMemoryAccess(DMA)AccessingI/ODevices(9)AddressingModesofI/ODevices(Interface)Memory-mappedI/OI/Odevicesandthememorysharethesameaddressspace.Somememoryaddressvaluesareusedtorefertoperipheraldeviceinterfaceregisters.I/Olooksjustlikememoryread/writeExample

LoadR2,DATAINDATAINistheaddressoftheinputbufferassociatedwiththekeyboard.AdvantageAnymachineinstructionthatcanaccessmemorycanbeusedtotransferdatatoorfromanI/Odevice.AccessingI/ODevices(10)AddressingModesofI/ODevices(Interface)(ctd.)Memory-mappedI/O(ctd.)DisadvantageValuablememoryaddressspaceisusedup.IsolatedI/OUsespecialInandOutinstructionstoperformI/Otransfers.AdvantageI/Odevicesdealwithfewaddresslines.NoteAseparateI/OaddressspacedoesnotnecessarilymeanthattheI/Oaddresslinesarephysicallyseparatefromthememoryaddresslines.AccessingI/ODevices(11)Program-controlledI/OCPUexecutesaprogramthatcommunicateswithI/OmoduleRead/writecommandsSensingstatusTransferringdataCPUwaitsforI/OmoduletocompleteoperationDisadvantageisthatitwastesCPUtimeExample:Considerataskthatreadscharacterstypedonakeyboard,storesthesedatainthememory,anddisplaysthesamecharactersonadisplayscreen.AccessingI/ODevices(12)Program-controlledI/O(ctd.)Example(ctd.)ThedifferenceinspeedbetweentheprocessorandI/Odevicescreatestheneedformechanismstosynchronizethetransferofdatabetweenthem.Onoutput,theprocessorsendsthefirstcharacterandthenwaitsforasignalfromthedisplaythatthecharacterhasbeenreceived.Itthensendsthesecondcharacter,andsoon.Oninput,theprocessorwaitsforasignalindicatingthatacharacterkeyhasbeenstruckandthatitscodeisavailableinsomebufferregisterassociatedwiththekeyboard.Thentheprocessorproceedstoreadthatcode.AccessingI/ODevices(13)Program-controlledI/O(ctd.)Example(ctd.)SignalingProtocolforI/ODevicesAssumethattheI/Odeviceshaveawaytosenda‘ready’signaltotheprocessorForkeyboard,indicatescharactercanberead

soprocessorusesLoadtoaccessdataregisterFordisplay,indicatescharactercanbesentsoprocessorusesStoretoaccessdataregisterThe‘ready’signalineachcaseisastatusflag

instatusregisterthatispolledbyprocessorAccessingI/ODevices(14)AccessingI/ODevices(15)Program-controlledI/O(ctd.)Example(ctd.)Keyboard&DisplayInterfaceRegisterOrganizationAccessingI/ODevices(16)Program-controlledI/O(ctd.)Example(ctd.)WaitLoopforPollingI/OStatusProgram-controlledI/Oimplementedwithawaitloopforpollingkeyboardstatusregister:

READWAIT: LoadByte R4,KBD_STATUS

And R4,R4,#2

Branch_if_[R4]0READWAIT

LoadByte R5,KBD_DATAKeyboardcircuitplacescharacterinKBD_DATAandsetsKINflaginKBD_STATUSCircuitclearsKINflagwhenKBD_STATUSreadAccessingI/ODevices(17)Program-controlledI/O(ctd.)Example(ctd.)WaitLoopforPollingI/OStatusSimilarwaitloopfordisplaydevice:

WRITEWAIT: LoadByte R4,DISP_STATUS

And R4,R4,#4

Branch_if_[R4]0WRITEWAIT

StoreByte R5,DISP_DATADisplaycircuitsetsDOUTflaginDISP_STATUSafterpreviouscharacterhasbeendisplayedCircuitautomaticallyclearsDOUTflag

whenDISP_STATUSregisterisreadAccessingI/ODevices(18)AccessingI/ODevices(19)Program-controlledI/O(ctd.)Example(ctd.)RISCProgramRISC-andCISC-styleI/OProgramsAccessingI/ODevices(20)Program-controlledI/O(ctd.)Example(ctd.)CISCProgramRISC-andCISC-styleI/OProgramsInterrupts(1)WhatisInterrupt?Aninterruptisaneventthatcausestheprocessortostopitscurrentprogramexecutionandswitchtoperforminganinterruptserviceroutine.AdvantagesofInterruptOvercomesCPUwaitingNorepeatedCPUcheckingofdeviceI/OmoduleinterruptswhenreadyInterrupts(2)Interrupts(3)Interrupts(4)Example3.1(ctd.)Interrupts(5)ConceptsofInterruptInterruptRequestSignalAsignalthatanI/Odevicesendstotheprocessorthroughoneofthebuscontrollines.InterruptAcknowledgeSignalTheCPUissuethesignaltoacknowledgestheinterruptInterrupts(6)ConceptsofInterrupt(ctd.)Interrupt-ServiceRoutine(InterruptHandler)Theroutineexecutedinresponsetoaninterruptrequestiscalledtheinterrupt-serviceroutine.InterruptLatencyThedelaybetweenthetimeaninterruptrequestisreceivedandthestartofexecutionoftheinterrupt-serviceroutine.Interrupts(7)ConceptsofInterrupt(ctd.)Differencebetweensubroutineandinterrupt-serviceroutineAsubroutineperformsafunctionrequiredbytheprogramfromwhichitiscalled.Assuch,potentialchangestostatusinformationandcontentsofregistersareanticipated.Aninterrupt-serviceroutinemaynothaveanyrelationtotheportionoftheprogrambeingexecutedatthetimetheinterruptrequestisreceived.Therefore,beforestartingexecutionoftheinterruptserviceroutine,statusinformationandcontentsofprocessorregistersthatmaybealteredinunanticipatedwaysduringtheexecutionofthatroutinemustbesaved.Thissavedinformationmustberestoredbeforeexecutionoftheinterruptedprogramisresumed.Interrupts(8)InterruptProcessingWhenaninterruptoccurs(andisaccepted),theexecutionofthecurrentprogramissuspendedMustsavePC,RegistersinProcessControlBlock(PCB)InterruptserviceroutineexecutestoservicetheinterruptFlowchart(nextpage)Interrupts(9)InterruptProcessing(ctd.)Interrupts(10)EnablingandDisablingInterruptsEnablinganddisablinginterruptsarefundamentaltoallcomputersTheinterruptionofprogramexecutionmustbecarefullycontrolledbecauseinterruptscanarriveatanytime,theymayalterthesequenceofeventsfromthatenvisagedbytheprogrammer.Itmaybenecessarytoguaranteethataparticularsequenceofinstructionsisexecutedtotheendwithoutinterruptionbecausetheinterruptserviceroutinemaychangesomeofthedatausedbytheinstructionsinquestion.Interrupts(11)EnablingandDisablingInterrupts(ctd.)InterruptControlatProcessorEndSetInterrupt-enablebitintheProgramStatusregisterSuitableforasimpleprocessorwithonlyoneinterrupt-requestline.Havetheprocessorautomaticallydisableinterrupts(cleartheInterrupt-enablebit)beforestartingtheexecutionoftheinterrupt-serviceroutine.(IE=0)WhenaReturn-from-interruptinstructionisexecuted,thecontentsofthePSarerestoredfromthestack,settingtheInterrupt-enablebitbackto1.(IE=1)Interrupts(12)EnablingandDisablingInterrupts(ctd.)InterruptControlatI/ODeviceEndItisimportanttoensurethatinterruptrequestsaregeneratedonlybythoseI/Odevicesthattheprocessoriscurrentlywillingtorecognize.Needamechanismintheinterfacecircuitsofindividualdevicestocontrolwhetheradeviceisallowedtointerrupttheprocessor.Aninterrupt-enablebitinacontrolregisterdetermineswhetherthedeviceisallowedtogenerateaninterruptrequest.Interrupts(13)EnablingandDisablingInterrupts(ctd.)InterruptControlatI/ODeviceEnd(ctd.)Interrupts(14)MultipleDevicesInterruptSystemDesignIssuesHowdoyouidentifythemoduleissuingtheinterrupt?Howtheprocessorobtainthestartingaddressoftheappropriateroutineofdifferentdevices?—IdentifyInterruptSourceShouldadevicebeallowedtointerrupttheprocessorwhileanotherinterruptisbeingserviced?—Multi-levelInterruptHowshouldtwoormoresimultaneousinterruptrequestsbehandled?—SimultaneousInterruptInterrupts(15)Interrupts(16)IdentifyInterruptSource(ctd.)CommonInterrupt-requestLine(ctd.)Polling(NonvectoredInterrupt)(ctd.)Interrupts(17)IdentifyInterruptSource(ctd.)

CommonInterrupt-requestLine(ctd.)VectoredInterruptAninterruptschemewheretheinterruptingdeviceidentifiesitselfwhengeneratinginterrupts.InterruptVectorAninterruptvectoristhememoryaddressofaninterrupthandler,oranindexintoanarraycalledaninterruptvectortableordispatch

table.Interruptvectortablescontainthememoryaddressesofinterrupthandlers.Interrupts(18)IdentifyInterruptSource(ctd.)

CommonInterrupt-requestLine(ctd.)VectoredInterrupt(ctd.)

Whenadevicesendsaninterruptrequest,theprocessormaynotreadytoreceivetheinterrupt-vectorcodeimmediately.Whentheprocessorisreadytoreceivetheinterrupt-vectorcode,itactivatestheinterrupt-acknowledgeline,INTATheI/Odevicerespondsbysendingitsinterrupt-vectorcodeandturningofftheINTRsignal.Interrupts(19)Multi-levelInterrupt

Single-levelInterruptWhetheronedeviceorseveralI/Odevices,interruptsshouldbedisabledduringtheexecutionofaninterrupt-serviceroutine.Multi-levelInterrupt(InterruptNesting)Itisnecessarytoacceptanotherdeviceinterruptduringtheexecutionofaninterrupt-serviceroutineforadevice.I/Odevicesareorganizedinaprioritystructure.Aninterruptrequestfromahigh-prioritydeviceshouldbeacceptedwhiletheprocessorisservinganotherrequestfromalower-prioritydevice.Interrupts(20)Multi-levelInterrupt(ctd.)MultipleInterrupt(ctd.)Multi-LevelPriorityAssignapriorityleveltotheprocessorthatcanbechangedunderprogram(privilegedinstructions)control.Thepriorityleveloftheprocessoristhepriorityoftheprogramthatiscurrentlybeingexecuted.Theprocessoracceptsinterruptsonlyfromdevicesthathaveprioritieshigherthanitsown.Atthetimetheexecutionofaninterrupt-serviceroutineforsomedeviceisstarted,thepriorityoftheprocessorisraisedtothatofthedevice.

Theprocessor’sprioritycanbeencodedinafewbitsoftheprocessorstatusregister.Interrupts(21)Multi-levelInterrupt(ctd.)Multi-levelInterrupt(ctd.)Multi-LevelPriority(ctd.)Implementationofinterruptpriorityusingindividualinterrupt-requestandacknowledgelinesInterrupts(22)SimultaneousInterruptIndividualdevicehasindividualinterrupt-requestandacknowledgelinesTheprocessorsimplyacceptstherequesthavingthehighestpriority.Itallowstheprocessortoacceptinterruptrequestsfromsomedevicesbutnotfromothers,dependingupontheirpriorities.Severaldevicesshareoneinterrupt-requestlineSoftwarePollDaisyChain(HardwarePoll)PriorityGroupInterrupts(23)SimultaneousInterrupt(ctd.)SoftwarePollTheprocessorpollthestatusregisteroftheI/Odevice.Priorityisdeterminedbytheorderinwhichthedevicesarepolled.DaisyChainInthedaisychainarrangement,thedevicethatiselectricallyclosesttotheprocessorhasthehighestpriority.Theseconddevicealongthechainhassecondhighestpriority,andsoon.ProcessorDevice2INTRINTADevicenDevice1Interrupts(24)SimultaneousInterrupt(ctd.)PriorityGroupcircuitDeviceDevicePriorityarbitrationProcessorDeviceDeviceINTR1INTRpINTA1INTApInterrupts(25)ProcessorControlRegistersProcessorStatusRegister(PS)IPSregisteriswherePSisautomaticallysavedwhenaninterruptrequestisrecognizedIENABLEregisterallowstheprocessortoselectivelyrespondtoindividualI/Odevices.HasonebitperdeviceIPENDINGhasonebitperdevicetoindicateifinterruptrequesthasnotyetbeenservicedInterrupts(26)ProcessorControlRegisters(ctd.)Interrupts(27)ProcessorControlRegisters(ctd.)AccessingControlRegistersUsespecialMoveinstructionsthattransfervaluestoandfromgeneral-purposeregistersTransferpendinginterruptrequeststoR4:

MoveControl R4,IPENDINGTransfercurrentprocessorIEsettingtoR2:

MoveControl R2,PSTransferdesiredbitpatterninR3toIENABLE:

MoveControl IENABLE,R3Interrupts(28)ExamplesofInterruptProgramsExample3.2Letusconsideragainthetaskofreadingalineofcharacterstypedonakeyboard,storingthecharactersinthemainmemory,anddisplayingthemonadisplaydevice.Now,wewilluseinterruptswiththekeyboard,butpollingwiththedisplay.Assumethataspecificmemorylocation,ILOC,isdedicatedfordealingwithinterrupts,andthatitcontainsthefirstinstructionoftheinterrupt-serviceroutine.Interrupts(29)ExamplesofInterruptPrograms(ctd.)Example3.2(ctd.)Wheneveraninterruptrequestarrivesattheprocessor,andprocessorinterruptsareenabled,theprocessorwillautomatically:Savethecontentsoftheprogramcounter,eitherinaprocessorregisterthatholdsthereturnaddressorontheprocessorstack.SavethecontentsofthestatusregisterPSbytransferringthemintotheIPSregister,andcleartheIEbitinthePS.LoadtheaddressILOCintotheprogramcounterInterrupts(30)ExamplesofInterruptPrograms(ctd.)Interrupts(31)ExamplesofInterruptPrograms(ctd.)Interrupts(32)ExamplesofInterruptPrograms(ctd.)Example3.3Supposeaprogramneedstodisplayapageoftextstoredinthememory.Thiscanbedonebyhavingtheprocessorsendacharacterwheneverthedisplayinterfaceisready,whichmaybeindicatedbyaninterruptrequest.Assumethatboththedisplayandthekeyboardareusedbythisprogram,andthatbothareenabledtoraiseinterruptrequests.Interrupts(33)ExamplesofInterruptPrograms(ctd.)Example3.3(ctd.)Touseinterruptsforbothkeyboard&display,callsubroutinesfromILOCserviceroutineServiceroutinereadsIPENDINGregisterCheckswhichdevicebit(s)is(are)set

todeterminewhichsubroutine(s)tocallServiceroutinemustsave/restoreLinkregisterAlsoneedseparatepointervariabletoindicate

outputcharacterfornextdisplayinterruptInterrupts(34)ExamplesofInterruptPrograms(ctd.)DirectMemoryAccess(1)InterruptdrivenandprogrammedI/OrequireactiveCPUinterventionTransferrateislimitedCPUistiedupSolution:DMAUsedforhigh-speedblocktransfersbetweenadeviceandmemoryDuringthetransfer,theCPUisnotinvolvedTypicalDMAdevices:Diskdrives,tapedrivesRememberKeyboarddatarate

0.01KB/s(1byteevery100ms)Diskdrivedatarate2,000KB/s(1byteevery0.5µs)TransferrateistoohightobecontrolledbysoftwareexecutingontheCPUDirectMemoryAccess(2)DMAOperation1.TheCPU“prepares”theDMAoperationbytransferringinformationtoaDMAcontroller(DMAC):LocationofthedataonthedeviceLocationofthedatainmemorySizeoftheblocktotransferDirectionofthetransferModeoftransfer(burst,cyclestealing,transparent)2.Whenthedeviceisreadytotransferdata,theDMACtakescontrolofthesystembuses(DMAcontrollerdealswithtransfer)3.DMACsendsinterruptwhenfinishedDirectMemoryAccess(3)DMAOperation(ctd.)DatabusAddressbusControlbusMemoryDMACCPUDiskTheCPU“prepares”theDMACProgram-controlledI/ODirectMemoryAccess(4)DMAOperation(ctd.)DatabusAddressbus

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论