Introduction to Computing Systems from bits & gates to C & beyond Chapter 8 Input/Output Basic organization Keyboard input Monitor output Interrupts DMA.

Slides:



Advertisements
Similar presentations
I/O Organization popo.
Advertisements

Computer Architecture
Chapter 10 And, Finally.... Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display A Final Collection of ISA-related.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 7 LC-2 Assembly Language.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 7 LC-2 Assembly Language.
I/O Unit.
FIU Chapter 7: Input/Output Jerome Crooks Panyawat Chiamprasert
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
CHAPTER 4 COMPUTER SYSTEM – Von Neumann Model
Overview I/O – memory mapped programmed / interrupt driven Traps mechanism & RET Subroutines & JSR & JSRR & RET Interrupt mechanism & RTI.
Chapter 9 Overview Traps mechanism & RET Subroutines & JSR & JSRR & RET Interrupt mechanism & RTI.
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,
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,
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
S. Barua – CPSC 240 CHAPTER 8 I/O How are I/O devices identified? Memory-mapped vs. special instructions.
Chapter 9 Trap Routines & RET Subroutines (or Functions) & JSR & JSRR & RET.
Overview Projects The Assembly Process Programmed I/O Interrupt Driven I/O.
Chapter 8 Overview Programmed I/O Introduction to Interrupt Driven I/O Project 3.
Chapter 8 I/O Programming Chapter 9 Trap Service Routines Programmed I/O Interrupts Interrupt Driven I/O Trap Service Routines.
Chapters 4 & 5: LC-3 Computer Architecture Machine Instructions Assembly language Programming in Machine and Assembly Language.
Chapter 8 Overview Programmed I/O Interrupt Driven I/O.
INPUT/OUTPUT ARCHITECTURE By Truc Truong. Input Devices Keyboard Keyboard Mouse Mouse Scanner Scanner CD-Rom CD-Rom Game Controller Game Controller.
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
The computer system’s I/O architecture is its interface to the outside world. This architecture provides a systematic means of controlling interaction.
Chapter 8 Input/Output l I/O basics l Keyboard input l Monitor output l Interrupt driven I/O l DMA.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
MICROPROCESSOR INPUT/OUTPUT
Introduction to Computing Systems from bits & gates to C & beyond Chapter 5 The LC-2 Instruction Set Architecture Operate instructions Data Movement instructions.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 4 The Von Neumann Model Basic components Instruction processing.
Computer Architecture Lecture10: Input/output devices Piotr Bilski.
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.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 5 The LC-3 Instruction Set Architecture ISA Overview Operate instructions Data.
Introduction to Computer Engineering CS/ECE 252, Fall 2009 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin – Madison.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 10 The Stack Stack data structure Activation records and function invocation.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 4 The Von Neumann Model Basic components Instruction processing.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
Introduction to Computer Engineering CS/ECE 252, Spring 2010 Prof. Guri Sohi Computer Sciences Department University of Wisconsin – Madison.
The computer system’s I/O architecture is its interface to the outside world. This architecture provides a systematic means of controlling interaction.
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
Input Output Techniques Programmed Interrupt driven Direct Memory Access (DMA)
I/O Organization Competency – C6. Important facts to remember when I/O devices are to be connected to CPU There is a vast variety of I/O devices. Some.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 10 The Stack Stack data structure Interrupt I/O (again!) Arithmetic using a stack.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Chapter 8 Input/Output An Hong 2015 Fall School of Computer Science and Technology Lecture on Introduction to.
Computer Science 210 Computer Organization
Chapter 8 I/O.
Computer Science 210 Computer Organization
COSC121: Computer Systems: LC3 I/O (Intro)
Computer Science 210 Computer Organization
Chapter 8 I/O.
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
Chapter 8 I/O.
Computer Science 210 Computer Organization
Introduction to Computer Engineering
TRAP Routines Subroutines Privileged Instructions
Chapter 8 I/O.
Introduction to Computer Engineering
TRAP Routines Privileged Instructions Subroutines
Chapter 8 I/O.
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

Introduction to Computing Systems from bits & gates to C & beyond Chapter 8 Input/Output Basic organization Keyboard input Monitor output Interrupts DMA

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Slides prepared by Walid A. Najjar & Brian J. Linard, University of California, Riverside I/O Basics Definitions  Input  transfer data from the outside world to the computer: keyboard, mouse, scanner, bar-code reader, etc.  Output  transfer data from the computer to the outside: monitor, printer, LED display, etc.  Peripheral: any I/O device, including disks. LC-2 supports a keyboard and a monitor

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Slides prepared by Walid A. Najjar & Brian J. Linard, University of California, Riverside Device Registers I/O Interface  Through a set of Device Registers:  Status register (device is busy/idle/error)  Data register (data to be moved to/from device)  The device registers can be read/written by the CPU LC-2  KBDR: keyboard data register  KBSR: keyboard status register  CRTDR: monitor data register  CRTST: monitor status register KBSR[15] - keyboard ready (new character available) KBDR[7:0] - character typed (ASCII) CTRSR[15] - CRT ready CTRDR[7:0] - character to be displayed (ASCII) KBSR KBDR CTRSR CTRDR LC-2

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Slides prepared by Walid A. Najjar & Brian J. Linard, University of California, Riverside Addressing Device Registers Special I/O Instructions  Read or write a device register using specialized I/O instructions. Memory Mapped I/O  Use existing data movement instructions (Load & Store).  Map each device register to a memory address (fixed).  CPU communicates with the device registers as if they were memory locations. LC-2  Uses memory mapped I/O CRTSR CRTDR KBDR KBSR xF3FC xF3FF xF401 xF400 LC-2 memory map

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Slides prepared by Walid A. Najjar & Brian J. Linard, University of California, Riverside Synchronizing CPU and I/O Problem  Speed mismatch between CPU and I/O:  CPU runs at > 2 GHz, all I/O is much slower.  Example : Keyboard input is at irregular intervals.  Need a protocol to keep CPU & KBD synchronized Handshake synchronization  CPU checks the KBD Ready status bit.  If set, CPU reads the data register and resets the Ready bit.  Start over.  Make CPU-I/O interaction seem to be synchronous

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Slides prepared by Walid A. Najjar & Brian J. Linard, University of California, Riverside Polling v/s Interrupts (Who’s driving?) Polling - CPU driving  CPU checks the ready bit of status register (as per program instructions).  If (KBSR[15] == 1) then load KBDR[7:0] to a register.  If the I/O device is very slow, CPU is busy waiting. Interrupt - I/O driving  Event triggered - when the I/O device is ready, it sets a flag: the interrupt signal.  When interrupt is set, the CPU is forced to an interrupt service routine (ISR) which services the interrupting device.  There are different priority levels of interrupt.  Specialized instructions can mask an interrupt level.

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Slides prepared by Walid A. Najjar & Brian J. Linard, University of California, Riverside Polling Algorithm Algorithm  Input  The CPU loops checking the Ready bit  When bit is set, a character is available  CPU loads the character  Output  CPU loops checking the Ready bit  When bit is set, monitor is ready for next character  CPU stores a character in monitor data register Details (Keyboard)  When key is struck  ASCII code of character goes into KBDR[7:0]  KBSR[15] (Ready Bit) is set to 1  Keyboard is locked until CPU reads KBDR  Then Ready Bit is cleared, keyboard is unlocked

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Slides prepared by Walid A. Najjar & Brian J. Linard, University of California, Riverside Polling Routines STARTLDIR1, A;Loop if Ready not set BRzpSTART LDIR0,B;If set, load char BRNEXT_TASK A.FILLxF400;Address of KBSR B.FILLxF401;Address of KBDR Input a character from keyboard STARTLDIR1, A;Loop if Ready not set BRzpSTART STIR0,B;If set, send char BRNEXT_TASK A.FILLxF3FC;Address of CRTSR B.FILLxF3FF;Address of CRTDR Output a character to the monitor

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Slides prepared by Walid A. Najjar & Brian J. Linard, University of California, Riverside Keyboard Echo: combine the above START LDI R1,KBSR ;Loop if KB not ready BRzp START LDI R0,KBDR ;Get character ECHO LDI R1,CRTSR ;Loop if MON not ready BRzp ECHO STI R0,CRTDR ;Send character BR NEXT_TASK KBSR.FILL xF3FC ;Address of KBSR KBDR.FILL xF3FF ;Address of KBDR CRTSR.FILL xF400 ;Address of CRTSR CRTDR.FILL xF401 ;Address of CRTDR

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Slides prepared by Walid A. Najjar & Brian J. Linard, University of California, Riverside Example: Print a string LEA R1,STR ;Load address of string LOOP LDR R0,R1,#0 ;get next char to R0 BRZ DONE ;string ends with 0 L2 LDI R3,CRTSR ;Loop until MON is ready BRzp L2 STI R0,CRTDR ;Write next character ADD R1,R1,#1 ;Set address to next char BR LOOP STR.STRINGZ "Char String" DONE HALT

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Slides prepared by Walid A. Najjar & Brian J. Linard, University of California, Riverside Interrupts - More  Interrupt mask register: each bit specifies whether the corresponding device is allowed to interrupt.  In the CPU, the control logic checks the INT bit before each instruction fetch stage.  If INT is set:  (PC) is saved  PC  address of corresponding ISR  Change mask settings (allow nested interrupts)  ISR is executed  Reset mask settings  Saved PC is restored  How can CPU tell who interrupted? Interrupt mask register Interrupt lines CPU INT

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Slides prepared by Walid A. Najjar & Brian J. Linard, University of California, Riverside Interrupt – Who called? How can CPU tell who interrupted?  Polling  Vectored Interrupts  Multiple CPU INT lines, each dedicated to a device or group of devices (Intel: INT0, INT1 …)  Each INT line sends the CPU to a specific ISR (Interrupt Service Routine).  The ISR must figure out who called if more than one device is associated with that INT line.  Daisy Chain  CPU sends an interrupt acknowledge (IACK) that is passed from one device to another.  Interrupting device puts the address of its ISR on the Data Bus.  Order of devices in the chain is the priority.  Example: SCSII Data bus IACK

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Slides prepared by Walid A. Najjar & Brian J. Linard, University of California, Riverside DMA – Direct Memory Access DMA  A device specialized in transferring data between memory and an I/O device (disk).  CPU writes the starting address and size of the region of memory to be copied, both source and destination addresses.  DMA does the transfer in the background.  It accesses the memory only when the CPU is not accessing it (cycle stealing). I/O Dev CPU memory DMA