Introduction to Computing Systems: From Bits and Gates to C and Beyond 2 nd Edition Yale N. Patt Sanjay J. Patel Slides prepared by Gregory T. Byrd, North Carolina State University Modified by Chao Gong, UMHB 1-1 Chapter 1 Welcome Aboard 1
Introduction to the World of Computing 1.1 Computer: electronic genius? NO! Electronic idiot! Does exactly what we tell it to, nothing more. Goal of the course: You will understand what s going on underneath inside computer Approach: Build understanding from the bottom up. Bits Gates Processor Instructions C Programming 1-3 Two Recurring Themes 1.3 Abstraction Productivity enhancer don t need to worry about details We can drive a car without knowing how the internal combustion engine works. until something goes wrong! Where s the dipstick? What s a spark plug? Important to understand the components and how they work together. Hardware vs. Software It s not either/or both are components of a computer system. Even if you specialize in one, you should understand capabilities and limitations of both. 1-4 2
Computer System 1.4 Central Processing Unit (CPU) or Processor: the hardware directing the processing of information, and performing the processing of information Computer System: including Hardware Software 1-5 Two Important Ideas 1.5 1. All computers, given enough time and memory, are capable of computing exactly the same things. 2. Computers carry out computational tasks through a sequence of systematic transformations. 1-6 3
Idea #1: Universal Computing Device 1.6 All computers, given enough time and memory, are capable of computing exactly the same things. = = Smart Phone Workstation Supercomputer 1-7 Turing Machine Mathematical model of a device that can perform any computation Alan Turing (1937) ability to read/write symbols on an infinite tape state transitions, based on current state and symbol Every computation can be performed by some Turing machine. (Turing s thesis) a,b T add a+b a,b T mul ab Turing machine that adds For more info about Turing machines, see http://www.wikipedia.org/wiki/turing_machine/ Turing machine that multiplies For more about Alan Turing, see http://www.turing.org.uk/turing/ 1-8 4
Universal Turing Machine A machine that can implement all Turing machines -- this is also a Turing machine! inputs: data, plus a description of computation (other TMs) T add, T mul a,b,c U c(a+b) Universal Turing Machine Universal TM is programmable so is a computer! instructions are part of the input data a computer can emulate a Universal Turing Machine A computer is a universal computing device. 1-9 From Theory to Practice In theory, computer can compute anything that s possible to compute given enough memory and time In practice, solving problems involves computing under constraints. time weather forecast, next frame of animation,... cost cell phone, automotive engine controller,... power cell phone, handheld video game,... 1-10 5
Idea #2: Transformations Between Layers 1.7 Problems Algorithms Language Instruction Set Architecture Microarchitecture Circuits Devices 1-11 How do we solve a problem using a computer? A systematic sequence of transformations between layers of abstraction. Problem Algorithm Program Instr Set Architecture Software Design: choose algorithms and data structures Programming: use language to express design Compiling/Interpreting: convert language to machine instructions 1-12 6
Deeper and Deeper Instruction Set Architecture Microarch Circuits Devices Processor Design: choose structures to implement ISA Logic/Circuit Design: gates and low-level circuits to implement components Process Engineering & Fabrication: develop and manufacture lowest-level components 1-13 Descriptions of Each Level Problem Statement stated using "natural language" may be ambiguous, imprecise Algorithm step-by-step procedure, guaranteed to finish definiteness, effective computability, finiteness Program express the algorithm using a computer language high-level language, low-level language Instruction Set Architecture (ISA) specifies the set of instructions the computer can perform data types, addressing mode 1-14 7
Descriptions of Each Level (cont.) Microarchitecture detailed organization of a processor implementation different implementations of a single ISA Logic Circuits combine basic operations to realize microarchitecture many different ways to implement a single function (e.g., addition) Devices properties of materials, manufacturability 1-15 Many Choices at Each Level Solve a system of equations Computer design is an exercise in Tradeoffs: cost, performance, power (etc.) Red-black SOR Gaussian elimination Jacobi iteration Multigrid FORTRAN C C++ Java PowerPC Intel x86 Atmel AVR Centrino Pentium 4 Xeon Ripple-carry adder Carry-lookahead adder CMOS Bipolar GaAs 1-16 8
Content Outline 1.2 Bits and Bytes (ch2) How do we represent information using electrical signals? Digital Logic (ch3) How do we build circuits to process information? Processor and Instruction Set (ch4 ~ 5) How do we build a processor out of logic elements? What operations (instructions) will we implement? Assembly Language Programming (ch6 ~ 7) How do we use processor instructions to implement algorithms? How do we write modular, reusable code? (subroutines) I/O, Traps, and Interrupts (ch8 ~ 10) How does processor communicate with outside world? C Programming (ch11 ~18) How do we write programs in C? How do we implement high-level programming constructs? 1-17 Exercises 1.13 Two computers, A and B, are identical except for the fact that A has a subtract instruction and B does not. Both have instructions that can take a value and produce the negative of that value. Which computer is able to solve more problems, A or B? Prove your result. 1.17 Briefly describe the difference between an ISA and a microarchitecture. 1.21 Say you buy some word processing software. What form is the software actually in? Is it in a high-level programming language? Is it in the ISA of the computer on which you will run it? Justify your answer. 1.23 Why is an ISA unlikely to change between successive generations of microarchitectures that implement it? For example, why would Intel want to make certain that the ISA implemented by the Pentium III is the same as the one implemented by the Pentium II? 1-18 9
Exercises 1.14 Suppose we wish to put a set of names in alphabetical order. We call the act of doing so sorting. One algorithm that can accomplish that is called the bubble sort. We could then program our bubble sort algorithm in C, and compile the C program to execute on an x86 ISA. The x86 ISA can be implemented with an Intel Pentium IV microarchitecture. Let us call the sequence Bubble sort, C program, x86 ISA, Pentium IV microarchitecture one transformation process. Assume we have available 4 sorting algorithms and can program in C, C++, C#, Java, and Python. We have available compilers that can translate from each of these to either x86 or SPARC, and we have available 3 different microarchitectures for x86 and 3 different microarchitectures for SPARC. a. How many transformation processes are possible? b. Write 3 examples of transformation processes. Hints: Rule of Product http://en.wikipedia.org/wiki/rule_of_product 1-19 10