450 likes | 468 Views
Learn how computers work, from Turing Machines to the Von Neumann architecture, and understand the concept of algorithms. Explore the fetch-execute cycle and how computers execute instructions. Gain insight into the power of simple operations performed at high speeds.
E N D
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
Contents How do computers work? Turing Machines Von Neumann architecture Fetch-execute cycle What is an algorithm? Computers and Algorithms
Contents How do computers work? Turing Machines Von Neumann architecture Fetch execute cycle What is an algorithm? Computers and Algorithms
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)
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
Contents How do computers work? Turing Machines Von Neumann architecture Fetch execute cycle What is an algorithm? Computers and Algorithms
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 (0s and 1s) at least from the standpoint of the computer
Input Output Von Neumann architecture (simplified) Memory Control Unit ArithmeticLogicUnit
Control Unit ArithmeticLogicUnit Accumulator Input Output Von Neumann architecture Memory Stores the program and the data It has specific and discrete locations – each (generally) 1 byte Each location has a specific address These addresses store values The total size of memory locations is limited
Diagram of computer memory- Each memory location is one byte size
Input Output Von Neumann architecture (simplified) Memory The Control Unit: Executes instructions Control Unit ArithmeticLogicUnit
Input Output Von Neumann architecture (simplified) Memory The ALU: Does the logic and maths Control Unit ArithmeticLogicUnit
Input Output Devices for both input and output Memory Control Unit ArithmeticLogicUnit Hard diskFloppy disk
Input Output Input devices Memory Control Unit ArithmeticLogicUnit Mouse KeyboardScanner
Input Output Output devices Memory Control Unit ArithmeticLogicUnit Monitor Printer Speakers
Computers on the outside Input / output Slightly out-of-date back of computer: http://facweb.northseattle.edu/tfiegenb/EET131/GX150User/about.htmAccessed 17-11-08
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 spell-checks) 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
Contents How do computers work? Turing Machines Von Neumann architecture Fetch execute cycle What is an algorithm? Computers and Algorithms
Illustration of a single ADD 2000 2080 4000 instruction Results depend on the contents of the memory locations referenced in the instruction.
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)
Instruction Fetch: Move instruction from memory to the control unit.
Instruction Decode: Pull apart the instruction, set up the operation in the ALU, and compute the source and destination operand addresses.
Result Return: Store the result from the ALU into the memory at the destination address.
Contents How do Computers Work? What is an algorithm?Example Algorithms
What is an algorithm? An algorithm is an ordered set of unambiguous, executable steps that defines a terminating processBrookshear 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/9agloss.htm
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
Everyday examples of algorithm-like procedures • Recipes • Flat-pack assembly instructions (sometimes – sometimes not) • Directions • Instructions on vending machines
Five properties of algorithms • Input-specified • Output-specified • Definiteness • Effectiveness • Finiteness Fluency with IT by Lawrence Snyder
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
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
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.
Effectiveness • Can be executed without additional input, information from … or us or oracles or psychics, ...
Finiteness • Comes to an end – it stops (specify when to stop a repetition Long division: 3.3 3) 10.0 9 1.0 9
Contents How do Computers Work? What is an algorithm?Example Algorithms
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 ...)
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?
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]