COMP3221 lec26-io.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 26: I/O Interfacing September,

Slides:



Advertisements
Similar presentations
So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –
Advertisements

Chapter 5 Input/Output 5.1 Principles of I/O hardware
ECE 495: Integrated System Design I
Chapter 8 Interfacing Processors and Peripherals.
I/O InterfaceCS510 Computer ArchitecturesLecture Lecture 17 I/O Interfaces and I/O Busses.
Computer Buses Ref: Burd, Chp – 220 Englander, Chp 7 p
Processor Data Path and Control Diana Palsetia UPenn
HARDWARE Rashedul Hasan..
Figure 12–1 Basic computer block diagram.
Microprocessor Architecture Pipelined Architecture
CS61C L16 Disks © UC Regents 1 CS161 Lecture 25 - Disks Laxmi Bhuyan
Mehdi Naghavi Spring 1386 Operating Systems Mehdi Naghavi Spring 1386.
I/O Organization popo.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Slide 5-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 5 Device Management.
Chapter 4 The Von Neumann Model
COMP3221 lec29-io-examples-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 29: I/O Interfacing Examples - I
INPUT-OUTPUT ORGANIZATION
1 IKI20210 Pengantar Organisasi Komputer Kuliah No. 19: I/O, Interupsi 20 November 2002 Bobby Nazief Johny Moningka
Designing Embedded Hardware 01. Introduction of Computer Architecture Yonam Institute of Digital Technology.
Gursharan Singh Tatla PIN DIAGRAM OF 8086 Gursharan Singh Tatla Gursharan Singh Tatla
CS1104 – Computer Organization
1  1998 Morgan Kaufmann Publishers Interfacing Processors and Peripherals.
CS61C L13 I/O © UC Regents 1 CS 161 Chapter 8 - I/O Lecture 17.
THUMB Instructions: Branching and Data Processing
Input and Output CS 215 Lecture #20.
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Input-Output.
COMP3221 lec31-mem-bus-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 31: Memory and Bus Organisation - I
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 34 – Input / Output “Arduino is an open-source electronics prototyping.
CS 430 – Computer Architecture 1 CS 430 – Computer Architecture Input/Output: Polling and Interrupts William J. Taffe using the slides of David Patterson.
CS61C L13 I/O © UC Regents 1 CS61C - Machine Structures Lecture 13 - Input/Output: Polling and Interrupts October 11, 2000 David Patterson
CS 61C L39 I/O (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures.
CS61C L37 I/O (1) Garcia © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture.
Cs 61C L12 I/O.1 Patterson Spring 99 ©UCB CS61C Input/Output Lecture 12 February 26, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson) www-inst.eecs.berkeley.edu/~cs61c/schedule.html.
Microcontroller: Introduction
INPUT-OUTPUT ORGANIZATION
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
B.A. (Mahayana Studies) Introduction to Computer Science November March The Motherboard A look at the brains of the computer, the.
Input and Output Computer Organization and Assembly Language: Module 9.
Interrupts and DMA CSCI The Role of the Operating System in Performing I/O Two main jobs of a computer are: –Processing –Performing I/O manage and.
2007 Oct 18SYSC2001* - Dept. Systems and Computer Engineering, Carleton University Fall SYSC2001-Ch7.ppt 1 Chapter 7 Input/Output 7.1 External Devices.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Input/Output CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent University.
COMP3221 lec04--prog-model.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 4: Programmer’s Model of Microprocessors
Chapter 8 I/O. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 8-2 I/O: Connecting to Outside World So far,
2009 Sep 10SYSC Dept. Systems and Computer Engineering, Carleton University F09. SYSC2001-Ch7.ppt 1 Chapter 7 Input/Output 7.1 External Devices 7.2.
The Mechanics Of Computers The Operating System (OS) & Hardware.
COMPUTER ARCHITECTURE. Recommended Text 1Computer Organization and Architecture by William Stallings 2Structured Computer Organisation Andrew S. Tanenbaum.
CS2100 Computer Organisation Input/Output – Own reading only (AY2015/6) Semester 1 Adapted from David Patternson’s lecture slides:
CS 61C: Great Ideas in Computer Architecture (Machine Structures) Lecture 37: IO Basics Instructor: Dan Garcia
Adapted from Computer Organization and Design, Patterson & Hennessy ECE232: Hardware Organization and Design Part 17: Input/Output Chapter 6
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
IT3002 Computer Architecture
بسم الله الرحمن الرحيم MEMORY AND I/O.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Overview of microcomputer structure and operation
Operating Systems (CS 340 D)
Inst.eecs.berkeley.edu/~cs61c UC Berkeley CS61C : Machine Structures Lecture 35 – Input / Output Lecturer SOE Dan Garcia
Some of the slides are adopted from Prof. David Patterson (UCB)
May 2006 Saeid Nooshabadi ELEC2041 Microprocessors and Interfacing Lectures 29: I/O Interfacing Examples
CS 286 Computer Organization and Architecture
CS703 - Advanced Operating Systems
Chapter 8 I/O.
Overview 1. Inside a PC 2. The Motherboard 3. RAM the 'brains' 4. ROM
Chapter 8 I/O.
Lectures 9-1: I/O Interfacing
Modified from notes by Saeid Nooshabadi
CS61C - Machine Structures Lecture 14 - Input/Output
Presentation transcript:

COMP3221 lec26-io.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 26: I/O Interfacing September, 2003 Saeid Nooshabadi Some of the slides are adopted from David Patterson (UCB)

COMP3221 lec26-io.2 Saeid Nooshabadi Overview °I/O Background °Polling °Interrupts

COMP3221 lec26-io.3 Saeid Nooshabadi Anatomy: 5 components of any Computer Processor (active) Computer Control (“brain”) Datapath (“brawn”) Memory (passive) (where programs, data live when running) Devices Input Output Keyboard, Mouse Display, Printer Disk (where programs, data live when not running)

COMP3221 lec26-io.4 Saeid Nooshabadi Motivation for Input/Output °I/O is how humans interact with computers °I/O lets computers do amazing things: Read pressure of synthetic hand and control synthetic arm and hand of fireman Control propellers, fins, communicate in BOB (Breathable Observable Bubble) Read bar codes of items in refrigerator °Computer without I/O like a car without wheels; great technology, but won’t get you anywhere

COMP3221 lec26-io.5 Saeid Nooshabadi I/O Device Examples and Speeds °I/O Speed: bytes transferred per second (from mouse to display: million-to-1) °DeviceBehaviorPartner Data Rate (Kbytes/sec) KeyboardInputHuman0.01 MouseInputHuman0.02 Line PrinterOutputHuman1.00 Floppy diskStorageMachine50.00 Laser PrinterOutputHuman Magnetic DiskStorageMachine10, Network-LANI or OMachine 10, Graphics DisplayOutputHuman30,000.00

COMP3221 lec26-io.6 Saeid Nooshabadi What do we need to make I/O work? °A way to connect many types of devices to the Proc-Mem °A way to control these devices, respond to them, and transfer data °A way to present them to user programs so they are useful Proc Mem PCI Bus SCSI Bus Status/cmd reg. data reg. Operating System Windows Files

COMP3221 lec26-io.7 Saeid Nooshabadi Buses in a PC: Connect a few devices CPU Memory bus Memory SCSI: External I/O bus (1 to 15 disks) SCSI Interface Ethernet Interface Ethernet Local Area Network °Data rates Memory: 133 MHz, 8 bytes  1064 MB/s (peak) PCI: 33 MHz, 8 bytes wide  264 MB/s (peak) SCSI: “Ultra3” (80 MHz), “Wide” (2 bytes)  160 MB/s (peak) Ethernet: 12.5 MB/s (peak) PCI Interface PCI: Internal (Backplane) I/O bus

COMP3221 lec26-io.8 Saeid Nooshabadi Instruction Set Architecture for I/O °Some machines have special input and output instructions °Alternative model (used by ARM): Input: ~ reads a sequence of bytes Output: ~ writes a sequence of bytes °Memory access also reading/ writing a sequence of bytes, so use loads for input, stores for output Called “Memory Mapped Input/Output” A portion of the address space dedicated to communication paths to Input or Output devices (no memory there)

COMP3221 lec26-io.9 Saeid Nooshabadi Computers with Special Instruction for I/O

COMP3221 lec26-io.10 Saeid Nooshabadi Computers with Memory Mapped I/O

COMP3221 lec26-io.11 Saeid Nooshabadi When Memory isn’t Memory °I/O devices often have a few registers Staus/ Control registers I/O registers 0 0xFFFFFFFF 0x100000C0 status reg. data reg. address °If these have an interface that looks like memory, we can connect them to the memory bus Reads/Writes to certain locations will produce the desired change in the I/O device controller °Typically, devices map to only a few bytes in memory status reg. data reg. 0x

COMP3221 lec26-io.12 Saeid Nooshabadi Processor-I/O Speed Mismatch °500 MHz microprocessor can execute 500 million load or store instructions per second, or 2,000,000 KB/s data rate I/O devices from 0.01 KB/s to 30,000 KB/s °Input: device may not be ready to send data as fast as the processor loads it Also, might be waiting for human to act °Output: device may not be ready to accept data as fast as processor stores it °What to do?

COMP3221 lec26-io.13 Saeid Nooshabadi Processor Checks Status before Acting °Path to device generally has 2 registers: 1 register says it’s OK to read/write (I/O ready), often called Status Register 1 register that contains data, often called Data Register °Processor reads from Status Register in loop, waiting for device to set Ready bit in Status reg to say its OK (0  1) °Processor then loads from (input) or writes to (output) data register Load from device/Store into Data Register resets Ready bit (1  0) of Status Register

COMP3221 lec26-io.14 Saeid Nooshabadi “What’s This Stuff Good For?” Remote Diagnosis: “NeoRest ExII,” a high-tech toilet features microprocessor-controlled seat warmers, automatic lid openers, air deodorizers, water sprays and blow-dryers that do away with the need for toilet tissue. About 25 percent of new homes in Japan have a “washlet,” as these toilets are called. Toto's engineers are now working on a model that analyzes urine to determine blood-sugar levels in diabetics and then automatically sends a daily report, by modem, to the user's physician. One Digital Day,

COMP3221 lec26-io.15 Saeid Nooshabadi DSLMU/Komodo Address Space Start Address End Address Size Function 0x x003FFFFF 4 MB Read/write memory (RAM) 0x x0FFFFFFF (252 MB) (Unused) 0x x1FFFFFFF 256 MB Microcontroller I/O space 0x x2FFFFFFF 256 MB Xilinx Spartan -XL I/O space 0x x3FFFFFFF 256 MB Xilinx Virtex-E I/O space 0x xFFFFFFFF (3072 MB) (Unused)

COMP3221 lec26-io.16 Saeid Nooshabadi DSLMU I/Os °Two RS232 serial port connectors °LEDs on the MU Board, °Boot Select switches °LCD module °Spartan-XL FPGA for I/O Expansion °Virtex-E FPGA for Co-processing °Single-chip 10 Mb Ethernet °Uncommitted Peripherals °Timers °Ref: Hardware Ref Manual on CD-ROM.

COMP3221 lec26-io.17 Saeid Nooshabadi DSLMU/Komodo I/O Addressing OffsetModePort NameFunction 0x00R/WPort A Bidirectional data port to LEDs, LCD, etc. 0x04R/WPort B Control port (some bits are read only) 0x08R/WTimer8-bit free-running 1 kHz timer 0x0CR/W Timer Compare Allows timer interrupts to be generated 0x10ROSerial RxDRead a byte from the serial port 0x10WOSerial TxDWrite a byte to the serial port 0x14WOSerial StatusSerial port status port 0x18R/WIRQ Status Bitmap of currently-active interrupts 0x1CR/WIRQ Enable Controls which interrupts are enabled 0x20WODebug Stop Stops program execution when written to

COMP3221 lec26-io.18 Saeid Nooshabadi DSLMU/Komodo Ports A & B: °Port A: Bidirectional: °Port B: Bit 4: LEDs Enable, Bit 2: Port A direction, Bit 1: LC_RS, Bit 0: LC_EN, Bit 4: LEDs enable

COMP3221 lec26-io.19 Saeid Nooshabadi I/O Example °Output: Write to LED Port. set iobase, 0x ; Base of the ; DSLMU I/O space.set portA, 0x00 ; Offset of Port A ; in the I/O space.set portB, 0x04 ; Offset of Port B ; in the I/O space mov r2, #iobase ; Use R2 as a base ; address pointer mov r0,#0b ; Set bit 4 and reset ; all other bits strb r0,[r2,#portB] ; Send the data to ; Port B (R2 + portB) mov r0,#0b ; R0 = data for the LEDs strb r0,[r2,#portA]

COMP3221 lec26-io.20 Saeid Nooshabadi DSLMU/Komodo Serial I/Os °DSLMU Serial Port: memory-mapped terminal (Connected to the PC for program download and debugging) Read from PC Keyboard (receiver); 2 device regs Writes to PC terminal (transmitter); 2 device regs Received Byte Receiver Data 0x Unused ( ) (IE)Receiver Status 0x Ready Unused ( ) Transmitted Byte Transmitter Status 0x Transmitter Data 0x Ready Unused ( ) Unused

COMP3221 lec26-io.21 Saeid Nooshabadi DSLMU/Komodo Serial I/Os °Status register rightmost bit (0): Ready Receiver: Ready==1 means character in Data Register not yet been read (or ready to be read); 1  0 when data is read from Data Reg Transmitter: Ready==1 means transmitter is ready to accept a new character; 0  Transmitter still busy writing last char °Data register rightmost byte has data Receiver: last char from keyboard; rest = 0 Transmitter: when write rightmost byte, writes char to display

COMP3221 lec26-io.22 Saeid Nooshabadi Reading Material °Reading Material: Experiment 4 Documentation Hardware Reference Manual on CD-ROM

COMP3221 lec26-io.23 Saeid Nooshabadi Serial I/O Example (Read) °Input: Read from PC keyboard into R0.set iobase, 0x ; Base of DSLMU I/O space.set ser_RxD, 0x10 ; Serial RxD port.set ser_stat, 0x14 ; Serial Status port.set ser_Rx_rdy, 0b01 ; Test bit 0 for RxD ; ready status readbyte: ldr r1,=iobase ; R1 = base address of I/O Space Waitloop: ldrb r0,[r1,#ser_stat] ; Read the serial port ; status tst r0,#ser_Rx_rdy ; Check whether a byte ; is ready to be read beq Waitloop ; (No: jump back and try ; again ldrb r0,[r1,#ser_RxD] ; Read the available ; byte into R0 mov pc,lr °Processor waiting for I/O called “Polling”

COMP3221 lec26-io.24 Saeid Nooshabadi Serial I/O Example (Write) °Input: Write from to Display from R0.set iobase, 0x ; Base of DSLMU I/O space.set ser_RxD, 0x10 ; Serial TxD port.set ser_stat, 0x14 ; Serial Status port.set ser_Tx_rdy, 0b10 ; Test bit 1 for TxD ; ready status writebyte: ldr r1,=iobase ; R1 = base address of I/O Space Waitloop: ldrb r2,[r1,#ser_stat] ; Read the serial port ; status tst r2,#ser_Tx_rdy ; Check whether is ready ; to accept new data beq Waitloop ; (No: jump back and try ; again strb r0,[r1,#ser_TxD] ; Send the next byte ; from R0 mov pc, lr °Processor waiting for I/O called “Polling”

COMP3221 lec26-io.25 Saeid Nooshabadi Serial I/O Example Quiz °What gets printed out? ldr r1,=iobase mov r0, ‘A’; strb r0,[r1,#ser_TxD] mov r0, ‘B’; strb r0,[r1,#ser_TxD] mov r0, ‘C’; Waitloop: ldrb r1,[r1,#ser_stat] ; Read the serial port ; status tst r1,#ser_Tx_rdy ; Check whether is ready ; to accept new data beq Waitloop ; (No: jump back and try ; again strb r0,[r1,#ser_TxD] ; Send the next byte ; from R0 1.ABC 2.AB 3.AC 4.BC

COMP3221 lec26-io.26 Saeid Nooshabadi Cost of Polling? °Assume for a processor with a 500-MHz clock it takes 400 clock cycles for a polling operation (call polling routine, accessing the device, and returning). Determine % of processor time for polling Mouse: polled 30 times/sec so as not to miss user movement Floppy disk: transfers data in 2-byte units and has a data rate of 50 KB/second. No data transfer can be missed. Hard disk: transfers data in 16-byte chunks and can transfer at 8 MB/second. Again, no transfer can be missed.

COMP3221 lec26-io.27 Saeid Nooshabadi % Processor time to poll mouse, floppy °Mouse Polling Clocks/sec = 30 * 400 = clocks/sec °% Processor for polling: 12*10 3 /500*10 6 = 0.002%  Polling mouse little impact on processor °Times Polling Floppy/sec = 50 KB/s /2B = 25K polls/sec °Floppy Polling Clocks/sec = 25K * 400 = 10,000,000 clocks/sec °% Processor for polling: 10*10 6 /500*10 6 = 2%  OK if not too many I/O devices

COMP3221 lec26-io.28 Saeid Nooshabadi % Processor time to hard disk °Times Polling Disk/sec = 8 MB/s /16B = 500K polls/sec °Disk Polling Clocks/sec = 500K * 400 = 200,000,000 clocks/sec °% Processor for polling: 200*10 6 /500*10 6 = 40%  Unacceptable

COMP3221 lec26-io.29 Saeid Nooshabadi What is the alternative to polling? °Wasteful to have processor spend most of its time “spin-waiting” for I/O to be ready °Wish we could have an unplanned procedure call that would be invoked only when I/O device is ready °Solution: use exception mechanism to help I/O. Interrupt program when I/O ready, return when done with data transfer

COMP3221 lec26-io.30 Saeid Nooshabadi Interrupt Driven Data Transfer (1) I/O interrupt (2) save PC (3) interrupt service addr Memory add sub and or user program read store... return interrupt service routine (4) (5)

COMP3221 lec26-io.31 Saeid Nooshabadi Benefit of Interrupt-Driven I/O °500 clock cycle overhead for each transfer, including interrupt. Find the % of processor consumed if the hard disk is only active 5% of the time. °Interrupt rate = polling rate Disk Interrupts/sec = 8 MB/s /16B = 500K interrupts/sec Disk Polling Clocks/sec = 500K * 500 = 250,000,000 clocks/sec % Processor for during transfer: 250*10 6 /500*10 6 = 50% °Disk active 5%  5% * 50%  2.5% busy

COMP3221 lec26-io.32 Saeid Nooshabadi Polling vs. Interrupt Analogy °Imagine yourself on a long road trip with your 10-year-old younger brother… (You: I/O device, brother: CPU) °Polling: “Are we there yet? Are we there yet? Are we there yet? ….” CPU not doing anything useful °Interrupt: Stuff him a color gameboy, “interrupt” him when arrive at destination CPU does useful work while I/O busy

COMP3221 lec26-io.33 Saeid Nooshabadi Conclusion (#1/2) °I/O is how humans interact with computers °I/O lets computers do amazing things °I/O devices often have a few registers Status registers I/O registers Typically, devices map to only a few bytes in memory

COMP3221 lec26-io.34 Saeid Nooshabadi Conclusion (#2/2) °I/O gives computers their 5 senses °I/O speed range is million to one °Processor speed means must synchronize with I/O devices before use °Polling works, but expensive processor repeatedly queries devices °Interrupts works, more complex