b5f2a6e5c015bc9e190ef8c7b7b19963.ppt
- Количество слайдов: 45
1
By the end of this lecture you should be able … To describe in general terms how computers function To describe the fetch-execute cycle To explain what an algorithm is To describe the basic properties of algorithms 2
Contents Computers and Algorithms How do computers work? Turing Machines Von Neumann architecture Fetch-execute cycle What is an algorithm?
Contents Computers and Algorithms How do computers work? Turing Machines Von Neumann architecture Fetch execute cycle What is an algorithm?
Historical perspectives – Turing's machine § Alan Turing – developed the abstract notion of a "Turing machine": – NOT a physical machine, but a mathematical model of one type of very simple abstract calculating device – He proved that there were Turing machines (Universal machines) that were capable of calculating anything and everything that any Turing machine could calculate (given enough time and enough memory) 5
The upshot of this result of Turing's: § Very simple devices can be designed that are as powerful computers as can be (if we don't have to worry about how much time it will take or how much memory is involved) § The practical lesson – make things that have larger and more efficient memory and faster speeds and we can do anything that a computer can do 6
Contents Computers and Algorithms How do computers work? Turing Machines Von Neumann architecture Fetch execute cycle What is an algorithm?
Historical perspectives: von Neumann's architecture § Von Neumann added in a number of ideas that made digital computing practical and his ideas remain those of most digital programming to this day § Key among those ideas: – Programmes themselves are really just like any other piece of data (0 s and 1 s) at least from the standpoint of the computer 8
Von Neumann architecture (simplified) Memory Arithmetic Logic Unit Control Unit Input Output 9
Von Neumann architecture Memory Stores the program and the data Arithmetic It has specific and discrete locations – each Logic Control (generally) 1 byte Unit Accumulator Each location has a specific address These addresses store values The total size of memory locations is limited Input Output 10
Diagram of computer memory- Each memory location is one byte size 0101 00101010 0011101001 11
Von Neumann architecture (simplified) Memory The Arithmetic Unit: Control Unit Input Logic Unit Executes instructions Output 12
Von Neumann architecture (simplified) Memory The ALU: Control Unit Does the logic and maths Input Arithmetic Logic Unit Output 13
Devices for both input and output Memory Arithmetic Logic Unit Control Unit Input Output Hard disk Floppy disk 14
Input devices Memory Arithmetic Logic Unit Control Unit Input Mouse Keyboard Output Scanner 15
Output devices Memory Arithmetic Logic Unit Control Unit Monitor Input Printer Speakers Output 16
Computers on the outside Input / output Slightly out-of-date back of computer: http: //facweb. northseattle. edu/tfiegenb/EET 131/GX 150 User/about. htm Accessed 17 -11 -08 17
RAM 18
Basic computer commands § Extremely limited set (nothing like the range of commands that we give to computers) § Designed to be simple, easy to execute but can be built up to do things that we want computers to do (like spellchecks) The power of a computer does not arise from complexity. Instead, the computer has the ability to perform simple operations at an extremely high rate of speed. These operations can be combined to provide the computer capabilities that you are familiar with. The Architecture of Computer Hardware and Systems Software. By Irv Englander 19
Contents Computers and Algorithms How do computers work? Turing Machines Von Neumann architecture Fetch execute cycle What is an algorithm?
The fetch/execute cycle. 21
Illustration of a single ADD 2000 2080 4000 instruction Results depend on the contents of the memory locations referenced in the instruction. 22
Computer before executing an ADD instruction. 23
The Program counter § This keeps track of what step needs to be executed next. It uses the address of the next instruction as its way of keeping track. This is called the program counter. (Here 'PC') § Some instructions change the Program counter (branch and jump instructions) 24
Computer before executing an ADD instruction - again 25
Instruction Fetch: Move instruction from memory to the control unit. 26
Instruction Decode: Pull apart the instruction, set up the operation in the ALU, and compute the source and destination operand addresses. 27
Data Fetch: Move the operands from memory to the ALU. 28
Execute: Compute the result of the operation in the ALU. 29
Result Return: Store the result from the ALU into the memory at the destination address. 30
Algorithms Contents How do Computers Work? What is an algorithm? Example
What is an algorithm? An algorithm is an ordered set of unambiguous, executable steps that defines a terminating process Brookshear Computer Science A step-by-step procedure for solving a problem http: //images. rbs. org/appendices/d_glossary_geometric. shtml A finite set of well-defined rules for the solution of a problem in a finite number of steps. http: //www. sabc. co. za/manual/ibm/9 agloss. htm 32
Algorithms for people § People will think things through § A general description may be enough § Nonetheless, it is important to avoid ambiguity and not to make too many assumptions 33
Everyday examples of algorithm-like procedures § Recipes § Flat-pack assembly instructions (sometimes – sometimes not) § Directions § Instructions on vending machines 34
Five properties of algorithms § § § Input-specified Output-specified Definiteness Effectiveness Finiteness Fluency with IT by Lawrence Snyder 35
Specifying the input and output § Input – what is going to be changed, used, transformed by the process § Output – the data that carries the results at the end of the process § What type (of data, of …) § How much 36
Definiteness § Each step – explicitly specified – each step in a specified order (so that at any stage it is possible to determine what the next step is § May apply in different ways to different sorts of problems 37
From the River go to the Street and turn right Approaching a street from different directions, resulting in the instruction “turn right” having different meanings. 38
Effectiveness § Can be executed without additional input, information from … or us or oracles or psychics, . . . 39
Finiteness § Comes to an end – it stops (specify when to stop a repetition Long division: 3. 3 3) 10. 0 9 1. 0 9 40
Algorithms Contents How do Computers Work? What is an algorithm? Example
Alphabetise and file your company's correspondence Input: A stack of folders. Each folder contains a letter to your company. At the moment, there is no order to the folders. Output: The same folders in the stack, but in alphabetical order This is an example of sorting – Sorting is a very common algorithmic process for computers. (Here we have alphabetical sorting for example. With any of these, the efficiency of the process is important, but that's for later for now. . . ) 42
Your problem § In groups, devise an algorithm for sorting CDs into alphabetical order. § What operations can you do? (For us, what verbs – For machines what procedures or methods) § What does alphabetical order mean? 43
Exam questions from 2009 Describe the fetch execute cycle. [4 marks] Draw a flow diagram or write in pseudo-code an algorithm for alphabetising a collection of CDs. [4 marks]
45
b5f2a6e5c015bc9e190ef8c7b7b19963.ppt