Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Introduction to Computers CS1100 Dr. Zhizhang Shen Chapter 9: How does a.

Similar presentations


Presentation on theme: "Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Introduction to Computers CS1100 Dr. Zhizhang Shen Chapter 9: How does a."— Presentation transcript:

1 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Introduction to Computers CS1100 Dr. Zhizhang Shen Chapter 9: How does a computer do it?

2 1-2 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-2 What about it? Once the data is brought in, how does the computer process them? We will check out the basic structure of a computer and A basic process a computer goes through to process the data

3 1-3 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-3 What can it do and can’t do? (CS3780) What computers can do –Deterministically perform or execute instructions to process information –The computer must have instructions to follow What computers can't do –Have no imagination or creativity –Have no intuition –Have no sense of irony, subtlety, proportion, decorum, or humor –Are not vindictive or cruel –Are not purposeful –Have no free will –It only does whatever it is told

4 1-4 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-4 A general mode of any computer(CS2200, CS4250) Computers have five basic parts or subsystems –Memory, control unit, arithmetic/logic unit (ALU), input unit, output unit

5 1-5 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-5 How does the computer do it? A program consists of a sequence of instructions. For each instruction so kept in the memory, the computer bring it into the processor and get it executed. It starts with the first instruction. The computer keeps on doing it until there is nothing left.

6 1-6 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-6 The Fetch/Execute Cycle For any instruction, it goes through the following steps: 1.Instruction fetch (IF): what to do? 2.Instruction decode (ID): what is it? 3.Data fetch (DF) / Operand Fetch (OF): how? 4.Instruction execution (EX): do it! 5.Result return (RR) / Store (ST): put it back.

7 1-7 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-7

8 1-8 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-8 Memory Memory stores the program running and the data on which the program operates (von Neumann architecture) Properties of memory: –Discrete locations. Each location consists of a fixed amount of space. Recall the computer word stuff –Addresses. Every memory location (byte) has an address (whole numbers starting with zero). Rounds 206 –Values. Memory locations record or store values. –Finite capacity. Limited size—programmers must remember that the data may not "fit" in the memory location. N bits keep 2^N things.

9 1-9 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-9 Byte-size memory location A commonly used diagram of computer memory represents the discrete locations as boxes with fixed capacity. (Super 8 motel) Address of location is displayed above the box. Value or contents of location is shown in the box.

10 1-10 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-10

11 1-11 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-11 Memory (cont'd) 1-byte memory locations can store one ASCII character, or a number less than 256 (0 - 255) Programmers use a sequence of memory locations together, ignoring the fact that they all have different addresses –Blocks of four bytes are used as a unit so frequently that they are called memory "words“ –It is different in the 64 bit machine.

12 1-12 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-12 Random access memory (RAM) " Random access" means the computer can refer to (access) the memory locations in any order, and it takes the same time no matter where it is kept. Often measured in megabytes (MB) – millions of bytes or gigabytes (GB) – billions of bytes Large memory is preferable because there is more space for programs and data (less I/O)

13 1-13 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-13 Control unit Hardware implementation of the Fetch/Execute Cycle Its circuitry fetches an instruction from memory, decodes the instruction, and fetches the operands used in it –A typical instruction might have the form ADD 4000, 2000, 2080op dest, src1, src2 –This instruction asks that the numbers stored in locations 2000 and 2080 be added together in CPU, and the result stored in location 4000[4000] = [2000] + [2080] –Data/Operand Fetch step must get these two values and after they are added, Result Return/Store step will store the answer in location 4000

14 1-14 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-14

15 1-15 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-15 Arithmetic/Logic Unit (ALU) Performs the math and logic operations such as AND, NOT. Generally does the work during the Instruction Execute step of the Cycle A circuit in the ALU can add two number, and other stuff such as multiplication and comparison, etc. Instructions that just transfer data usually don't use the ALU Data/Operand Fetch step of the Cycle gets the values that the ALU needs to work on (operands) When the ALU completes the operation, Return Result/Store step moves the answer from the ALU to the destination memory address specified in the instruction

16 1-16 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-16 Input Unit and Output Unit (I/O) The wires and circuits through which information moves into and out of a computer It is perhaps the most complex part since there are so many of them. The peripherals: Connect to the computer input/output ports. They are not considered part of the computer, but specialized gadgets that encode or decode information between the computer and the physical world. KB, mouse, scanner, camera, mic, printer, storage, cable modem,…

17 1-17 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-17 The Peripherals Keyboard encodes keystrokes we type into binary form for the computer Monitor decodes information from the computer's memory and displays it on a lighted, colored screen Disks drives are used for both input and output— storage devices where the computer puts away information when it is not needed, and can retrieve from when it is needed again

18 1-18 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-18 A Device driver for every peripheral "Dumb" devices provide basic physical translation to or from binary signals. Additional information from the computer is needed to make it operate intelligently. e.g., computer receives information that user typed shift and w at the same time. It converts to a capital W. The software that converts is called the device driver.

19 1-19 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-19 The Program Counter: Where am I? How does the computer determine which step to execute next? Address of the next instruction is stored in the control part of the computer. It is called the program counter (PC). Because instructions use 4 bytes of memory, the next instruction must be at PC + 4, 4 bytes further along in the sequence (in general). Computer adds four to the PC, so when the F/E Cycle gets back to Instruction Fetch step, the PC is "pointing at" the next instruction.

20 1-20 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-20 Branch and Jump Instructions The program typically goes in a sequence: get up, have class, have lunch, have class, have dinner, go to bed. It can also go to somewhere else. This changes the PC, so instead of going to PC +4 automatically, the computer “jumps” or “branches” to the specified location.

21 1-21 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Loop instructions Beside sequential and branch, the computer also needs a loop structure that will keep on doing something until a condition turns true. Various loop structures –Keep on drinking until drunk –While not drunk keep on drinking –Drink exactly 4 bottles 9-21

22 1-22 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-22 Instruction interpretation Process of executing a program –There are at least two languages: one for us, one for the machine. –Computer is interpreting our commands, but in its own language Before the F/E Cycle begins, some of the memory locations and the PC are visible in the control unit

23 1-23 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-23

24 1-24 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-24 Step 1 Execution begins by moving instruction at the address given by the PC from memory to control unit

25 1-25 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-25 Step 2 Every instruction is cut into two pieces: what to do and where to get the data. The what to do part of instruction are placed into the decoder circuit of the CU Then, it goes there to get the data Once instruction is fetched, the PC can be readied for fetching the next instruction

26 1-26 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-26 Step 3 In Instruction Decode step, ALU is set up for the operation as required Decoder will find the memory address of the instruction's data (source operands) –Most instructions operate on two data values stored in memory (like ADD), so most instructions have addresses for two source operands –These addresses are passed to the circuit that fetches them from memory during the next step, Data Fetch Decoder finds destination address for the Result Return step, and places it in RR circuit Decoder determines what operation the ALU will perform, and sets it up appropriately

27 1-27 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-27

28 1-28 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-28 Step 4 Instruction Execution: The actual computation is performed. In this case, get out the data kept in (428) and (824) and put it back in (800) For ADD instruction, the addition circuit adds the two source operands together to produce their sum

29 1-29 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-29

30 1-30 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-30 Step 5 Result Return: result of execution is returned to the memory location specified by the destination address. In this case, the result 54 is put in (800). Once the result is returned, the cycle begins again.

31 1-31 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-31

32 1-32 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-32 Lots of simple operations Addition is only one of them Computers can only perform about 100 different instructions –About 20 different kinds of operations (different instructions are needed for adding bytes, words, decimal numbers, etc.) Everything computers do must be reduced to some combination of these primitive, hardwired instructions

33 1-33 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-33 What are the others? Besides ADD, MULT (multiply) and DIV (divide), other instructions include: –Shift the bits of a word to the left or right, filling the emptied places with zeros and throwing away bits that fall off the end –Compute logical AND (test if pairs of bits are both true), and logical OR (test if at least one of two bits is true) –Test if a bit is zero or non-zero, and jump to new set of instructions based on outcome –Move information around in memory –Sense signals from input/output devices

34 1-34 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-34 Cycling the F/E Cycle Computers get their impressive capabilities by executing many billions of these simple instructions per second The Computer clock: Determines rate of F/E Cycle –Measured in gigahertz (GHz), or billions of cycles per second

35 1-35 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-35

36 1-36 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-36 Clock speed? Modern computers try to start an instruction on each clock tick Pass off finishing instruction to other circuitry (pipelining) –Five instructions can be in process at the same time –Pipeline: different phase is done at different time –Average time goes up. Instead of 10, it now goes down to 10/7 Does a 1 GHz clock really execute a billion instructions per second? –Not a precise measurement. Computer may not be able to start an instruction on each tick, but may sometimes be able to start more than one instruction at a time

37 1-37 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-37

38 1-38 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-38 Assembly languages (AL) –Machine language (ML) is the native language, consisting of only 0 and 1. ML is hard to read and understand for us, but the only language a machine understands. –AL is an alternative form of ML, using letters and normal numbers so people can understand it (mnemonic codes) –When scanning AL code, and seeing a word such as ADD, it looks them up in a table to convert it to binary. It also converts numbers to binary, then assembles the binary pieces into an instruction –It is now ready for the hardware to take over

39 1-39 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-39

40 1-40 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-40 High-level programming languages –Even AL is tough to crack for us, such as ADD 800 484 848 –Most modern software is written in a high-level notation, which is then compiled (translated) into assembly language, which is then assembled into binary code

41 1-41 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Something special… –Have special statement forms to help programmers give complicated instructions Example: Three-part if statement If (I am not drunk) Get me another one; Else lie on the floor 9-41

42 1-42 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-42

43 1-43 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-43

44 1-44 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-44 Operating systems (CS4310) Basic operations that are necessary for the effective use of computer, but are not built into the hardware Three most widely used Operating Systems: –Microsoft Windows –Apple's Mac OS X –Unix / Linux OS performs booting, memory management, device management, Internet connection, file management and provide a user interface.

45 1-45 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-45 Programming Programmers build on previously developed software to make their jobs easier (Software reuse) Example: GUI Software –Frame around window, slider bars, buttons, pointers, etc. are packaged for programmers and given with OS

46 1-46 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-46 Integrated Circuits Technically, we can build a machine with light switches, but it is too big. Miniaturization: –Clock speeds are so high because processor chips are so tiny (electrical signals can travel about 1 foot in a nanosecond) –Billions of transisters, tiny switches, are placed on 1 sq. inch chips.

47 1-47 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-47 Combining the Ideas  Start with information processing task  Task is performed by application, implemented as part of a large program in a high-level language like C or Java  Program performs specific operations; standard operations like print or save are done by OS  Program's commands are compiled into assembly language instructions

48 1-48 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Moore’s law In the past sixty years, the cost- performance ratio of sequential computing has improved about 100 billion times overall. This is done, during the last 20 years, mainly due to Moore’s observation that “The number of transistors that have been put onto a chip has been doubled every eighteen month”. 9-48

49 1-49 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley An example Intel 8086, a processor chip made by Intel in 1978, contained 29,000 transistors, and ran at 5 MHz. Intel Core 2 Duo, introduced in 2006, contained 291 million transistors and ran at the speed of 2.93 GHz. Thus, during those 28 years, the number of transistors has gone up by 10,034 times and, as a result, the speed goes up by 586 times. In this specific case, the number of transistors is doubled once every 24 months, or two years. 9-49

50 1-50 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley It all comes to an end…. Moore’s law will stay for another decade or two. We won’t put this many transistors into one processor. Instead, we will use them to come up with multiple processors. We are at a critical juncture of computer technology development. 9-50

51 1-51 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-51 Combining the Ideas  Assembly instructions are translated into binary code  Binary instructions are stored on hard disk (secondary memory)  Application instructions move into RAM (primary memory)  Fetch/Execute Cycle executes the instructions  All the computer's instructions are performed by the ALU circuits, using the transistor model previously described, under the control of the Control Unit

52 1-52 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 9-52 Homework Multiple choices: odd numbered Short answers: even numbered Complete Exercise 3, 4, 5, 9, and 12.


Download ppt "Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Introduction to Computers CS1100 Dr. Zhizhang Shen Chapter 9: How does a."

Similar presentations


Ads by Google