cs222: i/o organizations · 2018. 11. 13. · – give mobile number of taxi driver to your friend,...

20
CS222: I/O Organizations CS222: I/O Organizations Dr. A. Sahu Dept of Comp. Sc. & Engg. Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati

Upload: others

Post on 30-Jan-2021

4 views

Category:

Documents


0 download

TRANSCRIPT

  • CS222: I/O OrganizationsCS222: I/O Organizations

    Dr.  A. Sahu

    Dept of Comp. Sc. & Engg.Dept of Comp. Sc. & Engg.

    Indian Institute of Technology Guwahati

  • Outline• I/O Organization

    – Device Characteristics– Interface methodology

    • Grand Four I/OS – PPC (Programmable Peripheral Controller)PPC (Programmable Peripheral Controller)– PIT  (Programmable interval timer)PIC (Programmable Interrupt Controller)– PIC (Programmable Interrupt Controller)

    – DMA (Direct Memory Access)

  • Introduction to IO

    ProcessorRAProcessorM

    • Computer  Systems– Internal  (processor + memory (RAM) ) p y– Peripheral (Disk, Display, Audio, Eth,..)

  • Introduction

    RProcessor 

    RAMM

    • Peripherals :  HD monitor, 5.1 speaker • Interfaces : Intermediate HardwareInterfaces :  Intermediate Hardware 

    – Nvidia GPU card,  Creative Sound Blaster card • Interfaces : Intermediate Software/Program• Interfaces : Intermediate Software/Program

    – Nvidia GPU driver , Sound Blaster Driver software

  • • Read Instruction from memory• Execute instruction • Read/Write data to memoryRead/Write data to memory • Some time send result to  output device

    LEDs Monitor Printer– LEDs, Monitor, Printer• Interfacing a peripheral 

    – Why: To enable CPU to communicate with I/O– Designing logic circuit H/W  for a I/O– Writing instruction (S/W) 

  • • Parallel – Entire 8bit or 16 bit transfer at one timet e 8b t o 6 b t t a s e at o e t e– In 8085 entire 8 bit transferred simultaneous using 8 data linesS S t LED D t t (ASCIIt HEX) M– Seven Segment LEDs, Data converter (ASCIItoHEX), Memory 

    • Serial– Data transferred one bit at a timeData transferred one bit at a time– Parallel to serial conversion (parallel 8 bit to stream of serial 8 bit) S i l P ll l i– Serial to Parallel conversion

    – Modem, USB, SATA, and  (sometimes monitor/printer)• UART: Universal Asynchronous Receiver & TransmitterUART: Universal Asynchronous Receiver & Transmitter

  • • Serial Data TransmissionSerial – Cheaper Slower

    Transmission 

    – Slower • Parallel 

    Parallel Serial– Faster– Data skew

    Parallel Serial

    – Limited to small distances 

    Synchronous ASynchronousSynchronous ASynchronous

  • Two basic modes of data transmission

    Parallel to serial Conversion

    Serial to parallelConversion

    110

    110

    110

    110

    Sender0100

    Receiver0100

    10010011Sender

    0100

    Receiver01000

    101

    01

    01

    Serial Transmission Parallel TransmissionSerial Transmission Parallel Transmission

  • Checking I/O in your Linux PCChecking I/O in your Linux PC

    • $ lspci$ lspci

    $ / /i• $cat /proc/ioports

  • • Synchronous : At the same time, high speed I/O– Transmitter & Receiver Synchronized with same clock– 7 Segment LEDs can work same/higher speed then CPU

    – RAM (may be I/O) can work at same speed as CPU ( b f l SRAM/L1 C h N t th t(may be for only SRAM/L1 Cache, Not the current Processor & DRAM)

    A h I l i t l l d I/O• Asynchronous : Irregular interval, low speed I/O– I/O are slower– Keyboard, ADC/DAC, Disk

  • • Synchronous Sender and receiver must synchronize– Sender and receiver must synchronize 

    • Done in hardware using phase locked loops (PLLs) – Block of data can be sentBlock of data can be sent – More efficient : Less overhead than asynchronous transmission 

    – Expensive • Asynchronous 

    – Each byte is encoded for transmission • Start and stop bits

    – No need for sender and receiver synchronization

  • Transmission Gaps

    Sender ReceiverData Data Dataa

    Asynchronous transmission 

    CLK

    Sender ReceiverD D D D D

    CLK

    Sender ReceiverData Data Data Data Data

    Synchronous transmission 

  • • Character orientedCharacter oriented • Each character carried start bit and stop bits 

    h d b i i d• When No data are being transmitted – Receiver stay at logic 1 called mark, logic 0 is Space

    • Framing: – Transmission begins with one start  bit (low/0)– Followed by DATA (8bit) and – Stop bits (1 or 2 bits of logic high)p ( g g )

  • Asynchronous transmission1 startbit

    1 or 2 Stop

    1 0 0 0 1 1 1 0

    bit bitSource data

    1        0         0         0          1         1          1        0LSB                                                                         MSB

    8 bit Data

    Start Bit Start BitsTime

  • • Peripheral I/OIN (I i ) OUT (i i )– IN port (Instruction), OUT port  (instruction) 

    – Identified with 8 bit address (Immediate)– Example:   IN 01H ; Receive data from port 1

    • Memory mapped I/O– A peripheral is connected as if it were a memory location

    – Identified with 16/32 bit address– Data transfer by : LDA, STA, MOV M R, MOV R M

  • • CPU controlYou will pick up and drop friend from Station (I/O)– You will pick up and drop friend from Station (I/O) to Home (Memory)

    – When ever you will get a call (interrupt you) from y g ( p y )him, you have do that work of pickup (Execute ISR)

    • Device Control (DMA)– You hire a Taxi wala, he will pick up and drop friend from Station to Home

    – Give mobile number of taxi driver to your friend, your friend will to the taxi driver (coordinate) and Taxi wala drop your friend in your homeTaxi wala drop your friend in your home

  • • Unconditional– Assume I/O is always available (Ex LED port)– CPU simply enable port, transfer data & execute Next Instruction

    • Polling (Status check of device)• Polling (Status check of device)– You will call to your friend how much distance he have come (check whether he have landed at Airport)( p )

    • Interrupt: Let me work, when you are ready INTR me • With READY Signal (Mix of both approach)g ( pp )

    – Status Check, Interrupt• With handshake signal (Mutual Understanding)

    – A/D converter, When ready send a signal to CPU, CPU keep check the DR signal, CPU check it own DR signal pin 

  • • Set Enable Interrupth k li d i i f h i i• Check INTR line during execution of each instruction

    • If INTR is high & EI=1 then set DI and put INTAbar low• INTAbar is used to insert a RST instruction, it transfer the program control to specific location (ISR)

    f h k• Perform the task using ISR• At end of ISR it enable interrupt (EI)• After RETurn form ISR it continue to execute the normal execution

  • • Assume you are the CPU• What is your priority to different personWhat is your priority to different person 

    – Unknown (INTR‐U), Friends (INT‐F), Boss (INT‐B), Parents (INT‐P), Medical/Accident case (INT‐M)

    – Higher priority make other Disable• When you don’t want any interrupt

    – When I am serving to my Boss at company– When I am sleeping 

    DI i t ti (Di bl I t t)– DI instruction (Disable Interrupt)• When I want interrupt (EI= Enable Interrupt)

    I am free– I am free– I am not doing any valuable thing