Chapter 8 Input/Output l I/O basics l Keyboard input l Monitor output l Interrupt driven I/O l DMA.

Slides:



Advertisements
Similar presentations
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Advertisements

Computer Architecture
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Input-Output.
1 Input and Output Patt and Patel Ch Computer System.
CSS 372 Lecture 1 Course Overview: CSS 372 Web page Syllabus Lab Ettiquette Lab Report Format Review of CSS 371: Simple Computer Architecture Traps Interrupts.
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,
CSS 372 Oct 2 nd - Lecture 1 Course Overview: CSS 372 Web page Syllabus Lab Ettiquette Lab Report Format Review of CSS 371: Simple Computer Architecture.
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 7 Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats.
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.
Chapter 8 Overview Programmed I/O Interrupt Driven I/O.
Practical Session No. 10 Input &Output (I/O). I/O Devices Input/output (I/O) devices provide the means to interact with the “outside world”. An I/O device.
1 COSC 3P92 Cosc 3P92 Week 11 Lecture slides Violence is the last refuge of the incompetent. Isaac Asimov, Salvor Hardin in "Foundation"
Input / Output CS 537 – Introduction to Operating Systems.
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.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 8 Input/Output Basic organization Keyboard input Monitor output Interrupts DMA.
ITEC 1011 Introduction to Information Technologies 7. Input / Output Chapt. 8.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
Input and Output Computer Organization and Assembly Language: Module 9.
Input/ Output By Mohit Sehgal. What is Input/Output of a Computer? Connection with Machine Every machine has I/O (Like a function) In computing, input/output,
1. Introduction 2. Methods for I/O Operations 3. Buses 4. Liquid Crystal Displays 5. Other Types of Displays 6. Graphics Adapters 7. Optical Discs 10/01/20151Input/Output.
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,
Practical Session 11 Computer Architecture and Assembly Language Input &Output (I/O)
Chapter 9 Chapter 9 Subroutines and TRAPs l Privileged Instructions l TRAP Routines l Subroutines.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
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.
CH10 Input/Output DDDData Transfer EEEExternal Devices IIII/O Modules PPPProgrammed I/O IIIInterrupt-Driven I/O DDDDirect Memory.
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
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.
بسم الله الرحمن الرحيم MEMORY AND I/O.
I/O: Input-Output By: Tommy Zeng. What is I/O? I/O – short for “Input – Output” How a computer interacts with its users Input – gets information from.
Practical Session 12 Input &Output (I/O). I/O Device Input / Output (I/O) devices Input / Output (I/O) devices provide the means to interact with the.
Amdahl’s Law & I/O Control Method 1. Amdahl’s Law The overall performance of a system is a result of the interaction of all of its components. System.
Chapter 8 Input/Output An Hong 2015 Fall School of Computer Science and Technology Lecture on Introduction to.
Practical Session 11 Computer Architecture and Assembly Language Input &Output (I/O)
Computer Science 210 Computer Organization
Chapter 8 I/O.
HKN ECE 220: Fall 2017 Midterm 1 AJ Schroeder, Evan Lissoos, Utsav Kawrani 23rd September, 2017.
Operating Systems (CS 340 D)
Computer Science 210 Computer Organization
COSC121: Computer Systems: LC3 I/O (Intro)
CS 286 Computer Organization and Architecture
Computer Science 210 Computer Organization
Chapter 8 I/O.
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
Computer Architecture
Chapter 8 I/O.
Computer Science 210 Computer Organization
HKN ECE 220: Spring 2018 Midterm 1
Introduction to Computer Engineering
Chapter 8 I/O.
Introduction to Computer Engineering
Computer Architecture and Assembly Language
TRAP Routines Privileged Instructions Subroutines
Chapter 8 I/O.
Chapter 8 Input/Output An Hong 2016 Fall
Presentation transcript:

Chapter 8 Input/Output l I/O basics l Keyboard input l Monitor output l Interrupt driven I/O l DMA

2 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly CS Realities l Computers do more than just execute your program –I/O –Interrupts

3 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly I/O Basics l Definitions –Input l transfer data from the outside world to the computer: keyboard, mouse, scanner, bar-code reader, etc. –Output l transfer data from the computer to the outside: monitor, printer, LED display, etc. –Peripheral: any I/O device, including disks. l LC-3 supports only a keyboard and a monitor

4 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly Device Registers l I/O Interface –Through a set of Device Registers: l Status register (device is busy/idle/error) l Data register (data to be moved to/from device) –The device registers have to be read/written by the CPU. l LC-3 l KBDR: keyboard data register l KBSR: keyboard status register l DDR: display data register l DSR: display status register KBSR[15] - keyboard ready (new character available) KBDR[7:0] - character typed (ASCII) DSR[15] - monitor ready DDR[7:0] - character to be displayed (ASCII) LC-3 KBSR KBDR DSR DDR

5 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly Addressing Device Registers l Special I/O Instructions – Read or write to device registers using specialized I/O instructions. l 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. –Frame buffers: Large areas of Memory Mapped I/O for video display l LC-3 – Uses memory mapped I/O: xFE00KBSRKeyboard Status Register xFE02KBDRKeyboard Data Register XFE04DSRDisplay Status Register XFE06DDRDisplay Data Register XFFFEMCRMachine Control Register

6 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly Memory-mapped Input

7 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly Memory-mapped Output

8 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly Synchronizing CPU and I/O l Problem – Speed mismatch between CPU and I/O l CPU runs at up to 4 GHz, while all I/O is much slower – Example: Keyboard input is both slow and irregular – We need a protocol to keep CPU & KBD synchronized l Two common approaches l Polling (handshake synchronization) – CPU checks the KBD Ready status bit – If set, CPU reads the data register and resets the Ready bit – Repeat – Makes CPU-I/O interaction seem to be synchronous l Interrupt-driven I/O – An external device is allowed to interrupt the CPU and demand attention – The CPU attends to the device in an orderly fashion (more later)

9 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly Polling v/s Interrupts (Who’s driving?) l Polling: CPU in charge –CPU checks the ready bit of status register (as per program instructions). l If (KBSR[15] == 1) then load KBDR[7:0] to a register. –If the I/O device is very slow, CPU is kept busy waiting. l Interrupt: peripheral in charge –Event triggered - when the I/O device is ready, it sets a flag called an interrupt –When an interrupt is set, the CPU is forced to an interrupt service routine (ISR) which services the interrupting device –There can be different priority levels of interrupt –Specialized instructions can mask an interrupt level

10 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly Polling Algorithm l Input (keyboard) l The CPU loops checking the Ready bit l When bit is set, a character is available l CPU loads the character waiting in the keyboard data register l Output (monitor) l CPU loops checking the Ready bit l When bit is set, display is ready for next character l CPU stores a character in display data register

11 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly Polling details l Keyboard –When key is struck l ASCII code of character is written to KBDR[7:0] (least significant byte of data register). l KBSR[15] (Ready Bit) is set to 1. l Keyboard is locked until CPU reads KBDR. l The CPU sees Ready Bit, reads KBDR, and clears the Ready Bit, unlocking the keyboard. l Monitor –When CPU is ready to output a character l CPU checks DSR[15] (Ready Bit) until it is set to 1 l CPU writes character to DDR[7:0] l Monitor sets DSR[15] to 0 while it is busy displaying the character, then sets it back to 1 to indicate readiness for next character.

12 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly Simple Polling Routines STARTLDIR1, A;Loop if Ready not set BRzpSTART LDIR0, B;If set, load char to R0 BRNEXT_TASK A.FILLxFE00;Address of KBSR B.FILLxFE02;Address of KBDR Input a character from keyboard STARTLDIR1, A;Loop if Ready not set BRzpSTART STIR0, B;If set, send char to DDR BRNEXT_TASK A.FILLxFE04;Address of DSR B.FILLxFE06;Address of DDR Output a character to the monitor

13 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly Keyboard Echo: combine the above START LDI R1,KBSR ;Loop if KB not ready BRzp START LDI R0,KBDR ;Get character ECHO LDI R1,DSR ;Loop if monitor not ready BRzp ECHO STI R0,DDR ;Send character BR NEXT_TASK KBSR.FILL xFE00 ;Address of KBSR KBDR.FILL xFE02 ;Address of KBDR DSR.FILL xFE04 ;Address of DSR DDR.FILL xFE06 ;Address of DDR

14 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly 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 LP2 LDI R3, DSR ;Loop until MON is ready BRzp LP2 STI R0, DDR ;Write next character ADD R1, R1, #1 ;Set address to next char BR LOOP STR.STRINGZ "Char String" DONE HALT

15 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly There’s got to be a better way! l In a later chapter, we will talk about how Interrupt Driven I/O can be used to make this entire process much more processor efficient.

16 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly What about my PC? PCs use Memory Mapped I/O With Interrupts

17 College of Charleston, School of Science & Math Dr. Anderson, Computer Science CS 250 Comp. Org. & Assembly Practice problems l 8.7, 8.13, 8.14, 8.16