© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. CPUs Input and output. Supervisor mode, exceptions, traps. Co-processors. 1.

Slides:



Advertisements
Similar presentations
IO - 1Embedded Systems Lab./Honam University CPUs zInput and output. zSupervisor mode, exceptions, traps. zCo-processors.
Advertisements

I/O Organization popo.
Chapter 3 Basic Input/Output
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
INPUT-OUTPUT ORGANIZATION
ECE 353 Introduction to Microprocessor Systems
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
Interrupts Disclaimer: All diagrams and figures in this presentation are scanned from the book “Microprocessors and Programmed Logic” authored by Kenneth.
I/O Unit.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
1 中斷 Interrupt. 2 謂何需要 Interrupt I/O  Busy/wait I/O is very inefficient. CPU can ’ t do other work while testing device. Hard to do simultaneous I/O.
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Chapter 3 CPUs 金仲達教授 清華大學資訊工程學系 (Slides are taken from the textbook slides)
6-1 I/O Methods I/O – Transfer of data between memory of the system and the I/O device Most devices operate asynchronously from the CPU Most methods involve.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
Introduction An interrupt is an event which informs the CPU that its service (action) is needed. Sources of interrupts: internal fault (e.g.. divide by.
Computer System Organization S H Srinivasan
Introduction to Interrupts
GURSHARAN SINGH TATLA PIN DIAGRAM OF 8085 GURSHARAN SINGH TATLA
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
INPUT-OUTPUT ORGANIZATION
Interrupts. 2 Definition: An electrical signal sent to the CPU (at any time) to alert it to the occurrence of some event that needs its attention Purpose:
Exception and Interrupt Handling
Introduction to Embedded Systems
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
CPUs Input and output. Supervisor mode, exceptions, traps. Co-processors.
MICROPROCESSOR INPUT/OUTPUT
© 2000 Morgan Kaufman Overheads for Computers as Components CPUs zInput and output mechanisms zInterrupts zMemory management unit (MMU) zCache mechanism.
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
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,
I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU.
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.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
© 2000 Morgan Kaufman Overheads for Computers as Components CPUs zInput and output. zSupervisor mode, exceptions, traps. zCo-processors.
80386DX functional Block Diagram PIN Description Register set Flags Physical address space Data types.
Computer Organization CDA 3103 Dr. Hassan Foroosh Dept. of Computer Science UCF © Copyright Hassan Foroosh 2002.
© 2000 Morgan Kaufman Overheads for Computers as Components CPUs zInput and output. zSupervisor mode, exceptions, traps. zCo-processors.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
ECE 353 Introduction to Microprocessor Systems Michael J. Schulte Week 11.
بسم الله الرحمن الرحيم MEMORY AND I/O.
9/20/6Lecture 3 - Instruction Set - Al1 Exception Handling.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Multiplex of Data and Address Lines in 8088 Address lines A0-A7 and Data lines D0-D7 are multiplexed in These lines are labelled as AD0-AD7. –By.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Lab 2 Microprocessor MPC430F2274 MSP-430 Architecture.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Transmitter Interrupts Review of Receiver Interrupts How to Handle Transmitter Interrupts? Critical Regions Text: Tanenbaum
Lecture 2 Interrupts.
Timer and Interrupts.
Computer Architecture
Interrupts In 8085 and 8086.
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
I/O Interface and Interrupt Systems
Interrupts Interrupt is a process where an external device can get the attention of the microprocessor. The process starts from the I/O device The process.
Overheads for Computers as Components 2nd ed.
X1 & X2 These are also called Crystal Input Pins.
Interrupts.
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
COMP3221: Microprocessors and Embedded Systems
Chapter 13: I/O Systems.
Presentation transcript:

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. CPUs Input and output. Supervisor mode, exceptions, traps. Co-processors. 1

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. I/O devices Usually includes some non-digital component. Typical digital interface to CPU: CPU status reg data reg mechanism 2

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Application: 8251 UART Universal asynchronous receiver transmitter (UART) : provides serial communication functions are integrated into standard PC interface chip. Allows many communication parameters to be programmed. 3

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Serial communication Characters are transmitted separately: time bit 0bit 1bit n-1 no char start stop... 4

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Serial communication parameters Baud (bit) rate. Number of bits per character. Parity/no parity. Even/odd parity. Length of stop bit (1, 1.5, 2 bits). 5

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed CPU interface CPU 8251 status (8 bit) data (8 bit) serial port xmit/ rcv 6

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Programming I/O Two types of instructions can support I/O: special-purpose I/O instructions; memory-mapped load/store instructions. Intel x86 provides in, out instructions. Most other CPUs use memory-mapped I/O. I/O instructions do not preclude memory- mapped I/O. 7

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. ARM memory-mapped I/O Define location for device: DEV1 EQU 0x1000 Read/write code: LDR r1,#DEV1 ; set up device adrs LDR r0,[r1] ; read DEV1 LDR r0,#8 ; set up value to write STR r0,[r1] ; write value to device 8

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Peek and poke Traditional HLL interfaces: int peek(char *location) { return *location; } void poke(char *location, char newval) { (*location) = newval; } 9

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Busy/wait output Simplest way to program device. Use instructions to test when device is ready. current_char = mystring; while (*current_char != ‘\0’) { poke(OUT_CHAR,*current_char); while (peek(OUT_STATUS) != 0); current_char++; } 10

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Simultaneous busy/wait input and output while (TRUE) { /* read */ while (peek(IN_STATUS) == 0); achar = (char)peek(IN_DATA); /* write */ poke(OUT_DATA,achar); poke(OUT_STATUS,1); while (peek(OUT_STATUS) != 0); } 11

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Interrupt I/O Busy/wait is very inefficient. CPU can’t do other work while testing device. Hard to do simultaneous I/O. Interrupts allow a device to change the flow of control in the CPU. Causes subroutine call to handle device. 12

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Interrupt interface CPU status reg data reg mechanism PC intr request intr ack data/address IR 13

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Interrupt behavior Based on subroutine call mechanism. Interrupt forces next instruction to be a subroutine call to a predetermined location. Return address is saved to resume executing foreground program. 14

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Interrupt physical interface CPU and device are connected by CPU bus. CPU and device handshake: device asserts interrupt request; CPU asserts interrupt acknowledge when it can handle the interrupt. 15

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Example: character I/O handlers void input_handler() { achar = peek(IN_DATA); gotchar = TRUE; poke(IN_STATUS,0); } void output_handler() { } 16

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Example: interrupt-driven main program main() { while (TRUE) { if (gotchar) { poke(OUT_DATA,achar); poke(OUT_STATUS,1); gotchar = FALSE; } 17

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Example: interrupt I/O with buffers Queue for characters: headtail headtail a 18

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Buffer-based input handler void input_handler() { char achar; if (full_buffer()) error = 1; else { achar = peek(IN_DATA); add_char(achar); } poke(IN_STATUS,0); if (nchars == 1) { poke(OUT_DATA,remove_char(); poke(OUT_STATUS,1); } } 19

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. I/O sequence diagram :foreground:input:output:queue empty a b bc c 20

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Debugging interrupt code What if you forget to change registers? Foreground program can exhibit mysterious bugs. Bugs will be hard to repeat---depend on interrupt timing. 21

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Priorities and vectors Two mechanisms allow us to make interrupts more specific: Priorities determine what interrupt gets CPU first. Vectors determine what code is called for each type of interrupt. Mechanisms are orthogonal: most CPUs provide both. 22

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Prioritized interrupts CPU device 1device 2device n L1 L2.. Ln interrupt acknowledge 23

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Interrupt prioritization Masking: interrupt with priority lower than current priority is not recognized until pending interrupt is complete. Non-maskable interrupt (NMI): highest- priority, never masked. Often used for power-down. 24

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Example: Prioritized I/O :interrupts:foreground:A:A:B:B:C:C B A,B C A 25

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Interrupt vectors Allow different devices to be handled by different code. Interrupt vector table: handler 0 handler 1 handler 2 handler 3 Interrupt vector table head 26

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Interrupt vector acquisition :CPU:device receive request receive ack receive vector 27

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Generic interrupt mechanism intr? N Y Assume priority selection is handled before this point. N ignore Y ack vector? Y Y N timeout? Y bus error call table[vector] intr priority > current priority? continue execution 28

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Interrupt sequence CPU acknowledges request. Device sends vector. CPU calls handler. Software processes request. CPU restores state to foreground program. 29

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Sources of interrupt overhead Handler execution time. Interrupt mechanism overhead. Register save/restore. Pipeline-related penalties. Cache-related penalties. 30

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. ARM interrupts ARM7 supports two types of interrupts: Fast interrupt requests (FIQs). Interrupt requests (IRQs). Interrupt table starts at location 0. 31

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. ARM interrupt procedure CPU actions: Save PC. Copy CPSR to SPSR. Force bits in CPSR to record interrupt. Force PC to vector. Handler responsibilities: Restore proper PC. Restore CPSR from SPSR. Clear interrupt disable flags. 32

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. ARM interrupt latency Worst-case latency to respond to interrupt is 27 cycles: Two cycles to synchronize external request. Up to 20 cycles to complete current instruction. Three cycles for data abort. Two cycles to enter interrupt handling state. 33

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. C55x interrupts Latency is between 7 and 13 cycles. Maskable interrupt sequence: Interrupt flag register is set. Interrupt enable register is checked. Interrupt mask register is checked. Interrupt flag register is cleared. Appropriate registers are saved. INTM set to 1, DBGM set to 1, EALLOW set to 0. Branch to ISR. Two styles of return: fast and slow. 34

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Supervisor mode May want to provide protective barriers between programs. Avoid memory corruption. Need supervisor mode to manage the various programs. SHARC does not have a supervisor mode. 35

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. ARM supervisor mode Use SWI instruction to enter supervisor mode, similar to subroutine: SWI CODE_1 Sets PC to 0x08. Argument to SWI is passed to supervisor mode code. Saves CPSR in SPSR. 36

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Exception Exception: internally detected error. Exceptions are synchronous with instructions but unpredictable. Build exception mechanism on top of interrupt mechanism. Exceptions are usually prioritized and vectorized. 37

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Trap Trap (software interrupt): an exception generated by an instruction. Call supervisor mode. ARM uses SWI instruction for traps. SHARC offers three levels of software interrupts. Called by setting bits in IRPTL register. 38

© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Co-processor Co-processor: added function unit that is called by instruction. Floating-point units are often structured as co-processors. ARM allows up to 16 designer-selected co- processors. Floating-point co-processor uses units 1, 2. C55x uses co-processors as well. 39

C55x image/video hardware extensions Available in 5509 and Equivalent C-callable functions for other devices. Available extensions: DCT/IDCT. Pixel interpolation Motion estimation. © 2008 Wayne Wolf Overheads for Computers as Components 2nd ed.40

DCT/IDCT 2-D DCT/IDCT is computed from two 1-D DCT/IDCT. Put data in different banks to maximize throughput. block Column DCT interim DCT Row DCT © 2008 Wayne Wolf Overheads for Computers as Components 2nd ed.41

C55 DCT/IDCT coprocessor extensions Load, compute, transfer to accumulators: ACy=copr(k8,ACx,Xmem,Ymem) Compute, transfer, mem write: ACy=copr(k8,ACx,ACy), Lmem=ACz Special: ACy=copr(k8,ACx,ACy) © 2008 Wayne Wolf Overheads for Computers as Components 2nd ed.42

Software pipelined load/compute/store for DCT Iteration i-1 Dual_load 8 compute 4 Long_store 4 empty 3 Dual_load empty Iteration i Dual_load 8 compute 4 Long_store 4 empty 3 Dual_load empty Iteration i+1 Dual_load 8 compute 4 Long_store 4 empty 3 Dual_load empty op_i(0), load_i+1(0,1) op_i(1), store_i-1(0,1) op_i(2), store_i-1(2,3) op_i(2), store_i-1(4,5) op_i(2), store_i-1(6,7) op_i(2), load_i+1(2,3) … © 2008 Wayne Wolf Overheads for Computers as Components 2nd ed.43

C55 motion estimation Search strategy: Full vs. non-full. Accuracy: Full-pixel vs. half-pixel. Number of returned motion vectors: 1 (one 16x16) vs. 4 (four 8x8). Algorithms: 3-step algorithm (distance 4,2,1). 4-step algorithm (distance 8,4,2,1). 4-step with half-pixel refinement. © 2008 Wayne Wolf Overheads for Computers as Components 2nd ed.44

Four-step motion estimation breakdown d = {8,4,2,1}; for (i=0; i<4; i++) { compute 3 upper differences for d[i]; compute 3 middle differences for d[i]; compute 3 lower differences for d[i]; compute minimum value; move to next d; } X © 2008 Wayne Wolf Overheads for Computers as Components 2nd ed.45

C55 motion estimation accelerator Includes 3 16-bit pixel data paths, 3 16-bit absolute differences (ADs). Basic operation: [ACx,ACy] = copr(k8,ACx,ACy,Xmem,Ymem,Coeff) K8 = control bits (enable AD units, etc.) ACx, ACy = accumulated absolute differences Xmem, Ymem = pointers to odd, even lines of the search window Pointer to two adjacent pixels from reference window © 2008 Wayne Wolf Overheads for Computers as Components 2nd ed.46

C55 pixel interpolation Given four pixels A, B, C, D, interpolate three half-pixels: AB CD U MR © 2008 Wayne Wolf Overheads for Computers as Components 2nd ed.47

Pixel interpolation coprocessor operations Load pixels and compute: ACy=copr(k8,AC,Lmem) Load pixels, compute, and store: ACy=copr(k8,AACx,Lmem) || Lmem=ACz © 2008 Wayne Wolf Overheads for Computers as Components 2nd ed.48