Basicfunctions
·Selecttheportaddressdecodingdevice.
·ProvidestatusinformationofI/OdevicesanddecodecommandstotheCPU.
·Performtimingandcorrespondingtimingcontrol.
·Provideabufferforthetransmitteddatatoeliminatethedifferencein"timing"ordataprocessingspeedbetweenthecomputerandperipherals.
·Providecompatibleconversionofrelevantinformationformatsbetweencomputersandperipherals.Provideselectricaladaptation
·TheexchangeofinformationbetweentheCPUandperipheralscanalsoberealizedinaninterruptmode.
Interfacecomposition
Includinghardwarecircuitandsoftwareprogramming.Thehardwarecircuitincludesbasiclogiccircuit,portdecodingcircuitandoptionalcircuit.Softwareprogrammingincludesinitializationprogramsegment,transmissionmethodprocessingprogramsegment,maincontrolprogramsegmentprogramterminationandexitprogramsegmentandauxiliaryprogramsegment.
Interfaceclassification
I/OinterfaceThefunctionistorealizethattheCPUconnectstheI/Ocircuitandperipheraldevicesthroughthesystembus.Accordingtothecomplexityofthecircuitandthedevice,thehardwareoftheI/Ointerfaceismainlydividedintotwocategories:
(1)I/Ointerfacechips
Thesechipsaremostlyintegratedcircuits.DifferentcommandsandparametersareinputthroughtheCPU,andtherelatedI/Ocircuitsandsimpleperipheralsarecontrolledforcorrespondingoperations.CommoninterfacesChipssuchastimer/counter,interruptcontroller,DMAcontroller,parallelinterface,etc.
(2)I/Ointerfacecontrolcard
Thereareseveralintegratedcircuitsformedintoacomponentaccordingtoacertainlogic,ordirectlyonthemotherboardwiththeCPU,oraplug-inPluginthesystembusslot.
Accordingtotheconnectionobjectoftheinterface,theycanbedividedintoserialinterface,parallelinterface,keyboardinterfaceanddiskinterface.
Interfacefunction
Becauseofthewidevarietyofcomputerperipherals,almostallofthemuseelectromechanicaltransmissionequipment.Therefore,theCPUhasthefollowingproblemswhenitexchangesdatawithI/Oequipment:
Speedmismatch:TheworkingspeedofI/OdevicesismuchslowerthanthatoftheCPU,andduetothedifferenttypes,thespeeddifferencebetweenthemisalsoverybig.Forexample,thetransmissionspeedoftheharddiskisfasterthanthatoftheprinter.alotof.
Timingdoesnotmatch:EachI/Odevicehasitsowntimingcontrolcircuit,whichtransmitsdataatitsownspeed,whichcannotbeunifiedwiththeCPUtiming.
Informationformatmismatch:DifferentI/Odevicesstoreandprocessinformationindifferentformats,forexample,itcanbedividedintoserialandparallel;itcanalsobedividedintobinaryformat,ACSIIencodingandBCDencoding,etc..
Informationtypemismatch:DifferentI/Odevicesusedifferentsignaltypes,somearedigitalsignals,andsomeareanalogsignals,sotheprocessingmethodsusedarealsodifferent.
Basedontheabovereasons,thedataexchangebetweentheCPUandtheperipheralsmustbecompletedthroughtheinterface.Usuallytheinterfacehasthefollowingfunctions:
(1)SetthedataregistrationandbufferlogicInordertoadapttothespeeddifferencebetweenCPUandperipherals,theinterfaceisusuallycomposedofsomeregistersorRAMchips.Ifthechipislargeenough,itcanalsorealizethetransmissionofbulkdata;
(2)cancarryoutinformationformatConversion,suchasserialandparallelconversion;
(3)ItcancoordinatethedifferenceininformationtypeandlevelbetweenCPUandperipherals,suchaslevelconversiondriver,digital/analogoranalog/Digitalconverters,etc.;
(4)Coordinatingtimingdifferences;
(5)Addressdecodinganddeviceselectionfunctions;
(6)SettinginterruptsandDMAcontrollogictoensurethatinterruptsandDMArequestsignalsaregeneratedwheninterruptsandDMAareallowed,andinterruptprocessingandDMAtransferarecompletedafterreceivinginterruptsandDMAresponses.
Controlmethod
ThereareseveralwaysfortheCPUtocontrolperipheralsthroughtheinterface:
(1)Programquerymethod
Inthisway,theCPUinquiresthecurrentstateofthespecifiedperipheralthroughtheI/Oinstruction.Iftheperipheralisready,itwillinputoroutputdata,otherwisetheCPUwillwaitandcyclicallyquery.
Theadvantageofthismethodisthatthestructureissimple,andonlyasmallamountofhardwarecircuitsareneeded.ThedisadvantageisthattheCPUspeedismuchhigherthantheperipherals,soitisusuallyinawaitingstate,andtheworkefficiencyisverylow
p>(2)Interrupthandlingmethod
Inthisway,theCPUnolongerpassivelywaits,butcanexecuteotherprograms,oncetheperipheralisdataexchangeWhenitisready,aservicerequestcanbemadetotheCPU.IftheCPUrespondstotherequest,itwilltemporarilystoptheexecutionofthecurrentprogram,andswitchtoexecutetheserviceprogramcorrespondingtotherequest.Aftercompletion,itwillcontinuetoexecutetheinterruptedprogram.
Theadvantagesoftheinterruptprocessingmethodareobvious.ItnotonlysavestheCPUthetimespentinqueryingthestatusoftheperipheralandwaitingfortheperipheraltobeready,itimprovestheworkefficiencyoftheCPU,anditalsosatisfiestherequirementsoftheperipherals.Real-timerequirements.However,eachI/Odeviceneedstobeassignedaninterruptrequestnumberandthecorrespondinginterruptserviceprogram.Inaddition,aninterruptcontroller(I/Ointerfacechip)isneededtomanagetheinterruptrequestraisedbytheI/Odevice,suchassettinginterruptmask,Interruptrequestpriority,etc.
Inaddition,theshortcomingoftheinterruptprocessingmethodisthateverytimeacharacteristransmitted,itmustbeinterrupted,theinterruptcontrollermustbestarted,andthescenemustberetainedandrestoredinordertocontinuetheexecutionoftheoriginalprogram,whichcostsalotofwork.Inthisway,ifalargeamountofdataexchangeisrequired,theperformanceofthesystemwillbeverylow.
(3)DMA(directmemoryaccess)transfermethod
ThemostobviousfeatureofDMAisthatitdoesnotusesoftwarebutaspecialThecontrollercontrolsthedataexchangebetweenthememoryandperipheralswithoutCPUintervention,whichgreatlyimprovestheefficiencyoftheCPU.
BeforetheDMAdatatransfer,theDMAcontrollerwillapplytotheCPUforbuscontrol.IftheCPUallowsit,thecontrolwillbehandedover.Therefore,duringdataexchange,theDMAcontrollerwillcontrolthebus.Master,afterthetransferisover,theDMAcontrollerwillreturnbuscontroltotheCPU.
(4)Unconditionaltransmissionmethod
(5)I/Ochannelmethod
(6)I/Oprocessormethod