Elements of the Computer (How a processor works)

Slides:



Advertisements
Similar presentations
Computer Systems Nat 4/5 Computing Science Computer Structure:
Advertisements

The CPU The Central Presentation Unit What is the CPU?
Computer Architecture and the Fetch-Execute Cycle
INTRODUCTION OF COMPUTER
Using Computers CS French Chapter 1.
CHAPTER 4 COMPUTER SYSTEM – Von Neumann Model
Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
Chapter 5: Computer Systems Organization Invitation to Computer Science, C++ Version, Third Edition Added to by S. Steinfadt - Spring 2005 Additional source.
The processor and main memory chapter 4, Exploring the Digital Domain The Development and Basic Organization of Computers.
Hardware Overview CS French Chapter 11. Main Functional Elements of a Computer System Input / Output (I/O) –to give out information –to take in data and.
0 What is a computer?  Simply put, a computer is a sophisticated electronic calculating machine that:  Accepts input information,  Processes the information.
A-Level Computing#BristolMet Session Objectives#4 MUST describe the differences between the main types of primary memory SHOULD describe the function and.
The Computer Processor
Lecture 13 - Introduction to the Central Processing Unit (CPU)
CPU Fetch/Execute Cycle
Lesson 3 — How a Computer Processes Data
A-Level Computing#BristolMet Session Objectives#5 MUST identify different buses and registers used in a CPU SHOULD describe the use of buses to send information.
CS 1308 Computer Literacy and the Internet Computer Systems Organization.
Lesson 2 — How Does A Computer Process Data?
Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
Computer Architecture and the Fetch-Execute Cycle
Computer Architecture and the Fetch-Execute Cycle
Components of a Computer Prepared by: Mrs. McCallum-Rodney.
The CPU Central Processing Unit. 2 Reminder - how it fits together processor (CPU) memory I/O devices bus.
Advanced Computer Architecture 0 Lecture # 1 Introduction by Husnain Sherazi.
Chapter 4 The Von Neumann Model
Computer Architecture And Organization UNIT-II Structured Organization.
Von Neumann Machine Objectives: Explain Von Neumann architecture:  Memory –Organization –Decoding memory addresses, MAR & MDR  ALU and Control Unit –Executing.
CPU How It Works. 2 Generic Block Diagram CPU MemoryInputOutput Address Bus Data Bus.
Lesson 3 — How a Computer Processes Data Unit 1 — Computer Basics.
Computer Organization - 1. INPUT PROCESS OUTPUT List different input devices Compare the use of voice recognition as opposed to the entry of data via.
Intro to Computers Computer Applications. What is a Computer? Initially the term computer referred to an individual whose job it was to perform mathematical.
Model Computer CPU Arithmetic Logic Unit Control Unit Memory Unit
Chapter 5 Computing Components. 5-2 Chapter Goals List the components and their function in a von Neumann machine Describe the fetch-decode-execute cycle.
General Concepts of Computer Organization Overview of Microcomputer.
Computer Architecture Memory, Math and Logic. Basic Building Blocks Seen: – Memory – Logic & Math.
Fetch-execute cycle.
Computer Hardware A computer is made of internal components Central Processor Unit Internal External and external components.
Computer Studies/ICT SS2
Electronic Analog Computer Dr. Amin Danial Asham by.
CS 1308 Computer Literacy and the Internet. Objectives In this chapter, you will learn about:  The components of a computer system  Putting all the.
C HAPTER 4 OS: C OMPUTER O RGANIZATION TOPICS: The Von Neumann Architecture The CPU.
Question What technology differentiates the different stages a computer had gone through from generation 1 to present?
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
Structure and Role of a Processor
Introduction To Computers
Chapter 20 Computer Operations Computer Studies Today Chapter 20.
IC 3 BASICS, Internet and Computing Core Certification Computing Fundamentals Lesson 2 How Does a Computer Process Data?
Lec 4-2 Five operations of the machine cycle Fetch- fetch the next program instruction from memory. (PC+1); instruction to IR Decode- decode the instruction.
1 Chapter 1 Basic Structures Of Computers. Computer : Introduction A computer is an electronic machine,devised for performing calculations and controlling.
DIGITAL TECHNOLOGY. 20 Questions  Pair off with another student within your table.  Both of you are to think of your favorite in a specific category.
3.1.4 Hardware a. describe the function and purpose of the control unit, memory unit and ALU (arithmetic logic unit) as individual parts of a computer;
CPU Lesson 2.
Computing Science Computer Structure: Lesson 1: Processor Structure
Systems Architecture Keywords Fetch Execute Cycle
Chapter 4 The Von Neumann Model
Computer Architecture
Chapter 4 The Von Neumann Model
08/28/06 parts of the computer.
The Processor and Machine Language
Functional Units.
Systems Architecture I (CS ) Lecture 2: A Simplified Computer
Chapter 5: Computer Systems Organization
Chapter 4 The Von Neumann Model
The Stored Program Computer
GCSE OCR 1 The CPU Computer Science J276 Unit 1
Information Representation: Machine Instructions
Objectives Describe common CPU components and their function: ALU Arithmetic Logic Unit), CU (Control Unit), Cache Explain the function of the CPU as.
08/28/06 parts of the computer.
Chapter 4 The Von Neumann Model
Presentation transcript:

Elements of the Computer (How a processor works) C.S. French Chapter 19 The purpose of this lecture is to give you a little understanding about how computers actually work. At this point you should know how computers store information as either (i) numbers in binary or (ii) letters in binary using the ASCII or ANSI coding system. Now we need to see how computers can take that data, follow a set of instructions and create new information from the data. If you would like to know the key points from this lecture they are the following: The computer’s memory is used to store two things: instructions and data. The instructions are bunched together in sequences known as programs. The processor is the part of the computer that executes these program by obeying the instructions one by one. The processor obeys each instruction in a 2 stage method: first it FETCHES an instruction from memory, then it EXECUTES the instruction. Most times when it is executing an instruction it needs to fetch some data from memory to work on. As it works through a program if fetches, executes, fetches, executes and so on. This is known as the fetch/execute cycle. Now read the lecture and see how a simple Central Processing Unit does this. Although it seems a little complicated, it is the principles that I’d like you to understand (you don’t have to remember detailed terms). It is quite short.

The Computer itself. Processor 1 2 3 4 5 6 7 8 9 10 11 12 Data Bus Memory Control Unit ALU 1 2 3 4 5 6 7 8 9 10 11 12 CIR Accumulator SCR Input Output Unit Peripheral Devices MAR MDR Although this diagram looks quite different, it is actually similar to one you’ve seen before: The memory, Processor and Input/Output unit all connected to each other via the data bus. The difference here is that (I) the memory is divided up into individual numbered compartments and (ii) some details of the insides of the processor are show. You should take down a sketch of this for your notes and refer to that sketch as you read the following pages. Note how the data bus is connected into the memory. It’s not really physically built like this, but it works in such a way that it is like having a switch that can swivel around and connect to any of the memory compartments (locations). At the moment it is connected to location 4, but it can easily be changed to connect to another location. These memory locations are really very small, consisting of 8 or maybe 16 cells that can store ones or zeros (bits). This diagram only shows 12 but really there can be millions of them. Data Bus

Terms Memory main memory (RAM), electronic, fast, volatile, expensive, holds data currently in use. made up of many general purpose storage locations. may hold data or instructions. locations referred to by their ‘addresses’. Data Bus a set of wires for transmitting data. Processor controls the computer and carries out processing. Register a special purpose storage location in the processor. Control Unit controls the loading and execution of instructions. MDR (Memory Data Register) holds data temporarily as it enters and leaves the processor. Memory refers to the working storage where we temporarily keep data and programs we are working on as opposed to the auxilliary sorage on hard discs, floppies, zips, CDROMs. Each location can be referred to by a number, called it’s address. You’ll notice that the processor has rectangles with 3 letter codes on them. These represent areas for storing bits (ones and zeros) for particuclar purposes and are called registers. Each of them has a different name and purpose – we’ll look at these now. The Contrul Unit is really the most central part of a computer. It knows how to follow all the instructions in a computer program (eg MS Word). The instructions in these programs are stored in the memory when the program is operating. The control unit organises to read in the instructions on at a time from memory and then figure out what has to be done to obey each instruction. In order to oney these instructions, it must be able to control everything else in the processor. It may have to delegate by sending further instructions to the other parts of the processor. Memory Data Register: data moves from memory to the processor via the switch, down onto the databus ond into the processor. The MDR holds the data (ones and zeros) as they come in and also as they go out if they are being transferred the other way.

More Terms ALU (Arithmetic and Logic Unit) carries out arithmetic and logic operations. (add, subtract, AND, NOT etc) Accumulator holds the result of the last operation carried out by the ALU. CIR (Current Instruction Register) holds the instruction that is currently being interpreted and executed by the Control Unit. MAR (Memory Address Register) holds the address of the memory location which is currently connected to the data bus. (controls access to memory) SCR (Sequence Control Register) holds the address of the memory location of the instruction that is to be executed after the current one is finished. this is ‘incremented’ by 1 each time it is copied to the MAR. The Arithmetic and Logic Unit (ALU) does all sorts of calculations. The control unit organises data for it and then tells it to carry out a particular calculation. When it has carried out a particular calculation, the result of the calculation is stored in the register called the Accumulator (It’s a bit like your small screen on your calculator) This result can then be used for further calculations (just like on your calculator also) The sequence of instructions that makes up a computer program is stored in memory. However, at any particular point in time, the processor can only be carrying out one of the instructions in that program. The Current Instruction Register (CIR) stores a copy of the instruction that the processor is trying to obey just at that time. The processor needs to keep track of where it is in that program, otherwise it won’t know which instruction to carry out next after the one it is working on. The Sequence Control Register (SCR) holds a number indicating where in memory to get the next instruction to be executed after the current on is finished. How does it go and get the next instruction. It copies this number in the SCR over to the Memory Address Register (MAR). So the MAR now should hold the number of the location in memory where the processor is supposed to get the next instruction to be obeyed. Now the MAR is directly connected to that swivelling switch and it is it’s job to control what it is connected to in memory, so it turns the switch to point at the correct memory location. The computer can now copy the contents of that memory location down onto the data bus and into the processor.

Peripheral Devices Input keyboard, mouse, bar-code readers, camera, microphone etc Output screen, printer, plotter, mechanical device etc. Communications modem, ISDN adaptor, network card etc. Backing Storage slow, non-volatile, usually mechanical, cheap. floppy disk, hard disk, CDROM, magnetic tape, zip disk You were asked to categorise these peripheral devices yourself before. Did you get them right?

How the computer works. Machine instructions and data are stored in memory in binary format. A machine instruction consists of 2 parts: Operation code: holds the binary code for the operation that is to be carried out by the processor. Operand address: this is the address in memory where the processor may find the data that is to be operated on. Machine instructions are ‘fetched’ from memory and then ‘executed’ by the processor. The types of instructions that a computer’s processor (control unit) can obey are called: “machine instructions” (and a sequence of these is called a program). When running a program (eg. MS Word) the sequence of instructions is loaded into memory and stored in a series of contiguous (beside each other) memory locations as ones and zeros. Data (numbers and text) that the program needs to work on (eg. The letters of the alphabet in a report that you might be writing), are stored somewhere else in the memory. The processor has a fixed vocabulary of types of instructions that it can understand (eg an instruction to add 2 numbers, or to copy a number from somewhere in memory into the processor). Each type of instruction that it can understand has a short binary code to represent it ( eg: 0011 might represent ADD) – this is called the operation code. However, each instruction needs some data to work (operate) on. The first part of any instruction holds the code needed to specify what type of an instruction it is (operation code), but the second part holds the address in memory of the location that holds the data that the instruction has to work on (operand address). So an instruction that looked like 0011000010 would mean: ADD (0011) the contents of memory location 2 (000010) to whatever is already in the Accumulator. Now it is the Control Unit that will actually obey this instruction. In order to do this the instruction has to be loaded into the Current Instruction Register, so it is copied from wherever it is in memory via the databus, into the Memory Data Register and then up into the Current Instruction Register. This is called “fetching” the instruction. The instruction can then be obeyed by the control unit. This is called “Executing” the instruction. From this slide and the next, 1st years would be expected to be able to describe the principle of the fetch/execute cycle as opposed to the details of how this cycle is implemented.

The Fetch/Execute cycle. The address of the next instruction to be executed is copied from the SCR to the MAR. The SCR is incremented by 1. The information is copied from memory to the MDR. The contents of the MDR is copied to the CIR. The operation code part of the instruction in the MDR is copied to the control unit. The control unit recognises the instruction and executes it (the execution will vary depending on the instruction). In order to carry out a whole program of instructions, the processor needs to fetch each one and execute it, one after the other after the other. So it is constantly fetching one, executing it, fetching the next one then executing it and so on. This is called the “fetch/execute cycle”. The diagram above shows the same procedure being followed over and over like going around a wheel. The processor has one neat little trick that keeps it doing this over and over again. Remember that we said that the Sequence Control Register(SCR) holds the address of the next instruction that has to be fetched. If we need to get this from memory, then we will have to swivel the memory switch to the correct location. If we copy the number in the SCR over to the MAR, this will automatically happen (as the MAR controls the swivel switch). Now when this copy is done, the SCR is automatically increased (incremented) by 1. This neat little trick means that the next time around, when the SCR is copied over to the MAR, the number will be one more than the last time and so it will automatically get the next instruction after the last one. Now after the SCR is copied over (and increased) the swivel switch moves, the memory location containing the instruction is copied via the databus into the processor through the MDR and up into the Current Instruction Register (Fetched). The first part of the instruction (the operation code) is examined by the Control Unit. It works out what type of instructions it is, then sends whatever instructions it needs to to other parts of the processor in order that the instruction be obeyed (Executed). Once the instruction has been obeyed, it then goes back around the cycle again and fetches the next instruction and then obeys it, and so on, and so on.

The LOAD instruction. (Not required for 1st years) Purpose: to load data from memory to the accumulator. The operation address part of the CIR is copied to the MAR. The location in memory is copied to the MDR. The MDR is copied to the accumulator. No more of this lecture is required for first year students. Go back to the very first slide and read the key points of the lecture.

The STORE instruction (Not required for 1st years) Purpose: to copy the contents of the accumulator to a location in memory. The operation address part of the CIR is copied to the MAR. The accumulator is copied to the MDR. The MDR is copied to the location in memory .

The ADD instruction (Not required for 1st years) Purpose: to add the contents of a memory location to the contents of the accumulator. The operand address in the CIR is copied to the MAR. The contents of memory is copied to the MDR. The MDR contents are copied to the ALU which adds it to the accumulator, placing the result in the accumulator.

The JUMP instruction. (Not required for 1st years) Purpose: to transfer control in a program to an instruction other than the next one. The contents of the operand address are copied to the SCR. Variations: JUMP NEGATIVE JUMP ZERO JUMP POSITIVE The contents of the operand address are only copied to the SCR if the accumulator is in the correct condition.

Machine language exercises (Not required for 1st years) Given the binary codes for these machine instructions write the programs described below. LOAD 0001 STORE 0010 ADD 0011 JUMP 0100 JUMP + 0101 JUMP - 0110 JUMP 0 0111 Program to add together the contents of memory locations 10 and 11 and store the result in location 12. Program to count down from 9 to zero.