DOC PREVIEW
UCSC CMPE 012 - Input and Output

This preview shows page 1-2-3-23-24-25-26-47-48-49 out of 49 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 49 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CMPE12 Cyrus BazeghiInput and OutputHow things get into and out of the CPU(ch 8)CMPE12 Cyrus Bazeghi2Computer SystemCMPE12 Cyrus Bazeghi3I/O: Connecting to Outside World•So far, we‟ve learned how to:– compute with values in registers– load data from memory to registers– store data from registers to memory•But where does data in memory come from?•And how does data get out of the system so thathumans can use it?CMPE12 Cyrus Bazeghi4I/O: Connecting to the Outside WorldTypes of I/O devices characterized by:– behavior: input, output, storage• input: keyboard, motion detector, network interface• output: monitor, printer, network interface• storage: disk, CD-ROM– data rate: how fast can data be transferred?• keyboard: 100 bytes/sec• disk: 30 MB/s or more• network: 1 Mb/s - 1 Gb/sCMPE12 Cyrus Bazeghi5I/O Devices Keyboard• User presses „A‟ key -> „a‟• ASCII code is 0x61• Keyboard sends this on wires• 1 for start, 8-bits of data, 0 for stop• „a‟ is: 1011000010• Buffer at computer catches these bitsCMPE12 Cyrus Bazeghi6Displays• Character display works with the reverse process (sort of)• Most displays today are “bit mapped”I/O Devices Printers• Just like a display but now being “printed” to paper, not a screen.• Again, most printers are now “bit mapped” verses character.CMPE12 Cyrus Bazeghi7I/O Devices Hard Disk•A spinning disk (4600, 5200, 7200, 10000+ RPM)•20 – 400 GB and growing FAST•Magnetic and read/write (like tape)•Both sides •Usually a stack of platters•Disk access•Electronic speeds are in the nanoseconds (10-9 sec)•Disk speeds are in the milliseconds (10-3 sec)•Why use a disk?Queuing Seek Rotation TransferDepends 10ms 10ms 1msCMPE12 Cyrus Bazeghi8I/O Devices Questions• How does CPU ask for a char to be printed?• Which printer?• Which display? Who‟s?• When is printer ready for the next char?• When does keyboard have the next char?• What about the million times slower?CMPE12 Cyrus Bazeghi9LC-3 I/OUses the “TRAP” instruction to invoke the Operating System, which in turns talks to the hardware.User specifies the type of operation desired by giving a code to the OS.Ex. “TRAP x20” gets a character from the keyboard.CMPE12 Cyrus Bazeghi10LC-3 I/O •Don‟t use “JSR” because•OS doesn‟t trust user to provide the correct address•Want to switch into OS mode, where more thingsare allowed•CPU sees the “TRAP” instruction and uses the trap vector to determine where to go in the OS code.•OS will not allow (or should not)•Users to read each other‟s keyboards•Users to access all memory or disk locationsCMPE12 Cyrus Bazeghi11I/O ControllerControl/Status Registers– CPU tells device what to do -- write to control register– CPU checks whether task is done -- read status registerData Registers– CPU transfers data to/from deviceDevice electronics– performs actual operation• pixels to screen, bits to/from disk, characters from keyboardGraphics ControllerControl/StatusOutput DataElectronicsCPUdisplayCMPE12 Cyrus Bazeghi12Programming InterfaceHow are device registers identified?– Memory-mapped vs. special instructionsHow is timing of transfer managed?– Asynchronous vs. synchronousWho controls transfer?– CPU (polling) vs. device (interrupts)CMPE12 Cyrus Bazeghi13Memory-Mapped vs. I/O InstructionsSpecial Instructions– designate opcode(s) for I/O– register and operation encoded in instructionMemory-mapped– assign a memory address to each device register– use data movement instructions (LD/ST)for control and data transferCMPE12 Cyrus Bazeghi14Which is better?• What is the problem with having special instructions for IO?• What happens if a new device is created?Memory mapped is much more flexibleand expandable.Memory-Mapped vs. I/O InstructionsCMPE12 Cyrus Bazeghi15Memory Mapped IO• Idea is to place devices other than RAM chips at physical address locations.• This way to access IO devices you use the same load and store instructions.CMPE12 Cyrus Bazeghi16Memory Mapped I/O Design hardware and software to recognize certain addressesReal Memory - RAM0x000000000xffff00000xffff00080xffff0010From keyboardTo displayCMPE12 Cyrus Bazeghi17Memory Mapped I/O CPU MEMKeyboard Buffer0xffff0008Display Buffer0xffff0010•Devices on bus watch for their address•But is there a new char to read?•But is the display done with the last char?System busCMPE12 Cyrus Bazeghi18Need I/O device status to coordinate0x000000000xffff00000xffff00080xffff000cDATA from keyboardSTATUS from keyboard0xffff00100xffff0014DATA to DisplaySTATUS from DisplayReal Memory - RAMMemory Mapped I/OCMPE12 Cyrus Bazeghi19Transfer TimingI/O events generally happen much slower than CPU cycles.Synchronous– data supplied at a fixed, predictable rate– CPU reads/writes every X cyclesAsynchronous– data rate less predictable– CPU must synchronizewith device, so that it doesn‟t miss data or write too quicklyCMPE12 Cyrus Bazeghi20Transfer ControlWho determines when the next data transfer occurs?Polling– CPU keeps checking status register until new dataarrives OR device readyfor next data– “Are we there yet? Are we there yet? Are we there yet?”Interrupts– Device sends a special signal to CPU when new dataarrives OR device readyfor next data– CPU can be performing other tasks instead of polling device.– “Wake me when we get there.”CMPE12 Cyrus Bazeghi21LC-3 Memory-mapped I/O (Table A.3)Asynchronous devices– synchronized through status registersPolling and Interrupts– the details of interrupts is in chapter 10Location I/O Register FunctionxFE00Keyboard Status Reg (KBSR)Bit [15] is one when keyboard has received a new character.xFE02Keyboard Data Reg (KBDR)Bits [7:0] contain the last character typed on keyboard.xFE04Display Status Register (DSR)Bit [15] is one when device ready to display another char on screen.xFE06Display Data Register (DDR)Character written to bits [7:0] will be displayed on screen.CMPE12 Cyrus Bazeghi22Input from KeyboardWhen a character is typed:– its ASCII code is placed in bits [7:0] of KBDR (bits [15:8] are always zero)– the “ready bit” (KBSR[15]) is set to one– keyboard is disabled -- any typed characters will be ignoredWhen KBDR is read:– KBSR[15] is set to zero– keyboard is enabledKBDR15 8 7 0KBSR1514 0keyboard dataready bitCMPE12 Cyrus Bazeghi23Basic Input Routinenewchar?readcharacterYESNOPollingPOLL LDI R0, KBSRPtrBRzp


View Full Document

UCSC CMPE 012 - Input and Output

Download Input and Output
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Input and Output and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Input and Output 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?