Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computers in the real world Objectives Understand what role the CPU plays in a computer Understand how CPU performance is measured Look at the different.

Similar presentations


Presentation on theme: "Computers in the real world Objectives Understand what role the CPU plays in a computer Understand how CPU performance is measured Look at the different."— Presentation transcript:

1 Computers in the real world Objectives Understand what role the CPU plays in a computer Understand how CPU performance is measured Look at the different parts of a CPU Explore the idea of an instruction set and run simple programs in an assembly code emulator.

2 Computers in the real world What is a CPU? Remember the term micro-processor? The CPU is the microprocessor! CPU stands for – Central Processing unit – It is referred to as micro as, errr, its small It is the brains of the computer – It co-ordinates all of the hardware by running software.

3 Computers in the real world What is a CPU? Remember the term micro-processor? The CPU is the microprocessor! CPU stands for – Central Processing unit – It is referred to as micro as, errr, its small It is the brains of the computer – It co-ordinates all of the hardware by running software.

4 Computers in the real world How the CPU communicates Hard drive CPU Memory Software 1. Software, like office, are stored on the hard drive. To run the software we must “load” it.

5 Computers in the real world How the CPU communicates Hard drive CPU Memory Software 2. The operating system (like windows) will be running on the CPU. When the user selects to load office up, it is the OS which starts it off.

6 Computers in the real world How the CPU communicates Hard drive CPU Memory Software 3. Software is loaded from the hard drive and stored in main memory

7 Computers in the real world How the CPU communicates Hard drive CPU Memory Software 4. The CPU then transfers instructions from memory into the CPU in order to run them. It does this ONE at a time!

8 Computers in the real world The bus CPU Memory The CPU is connected to other devices using a bus. This is a circuit which connects the devices together. It has 3 parts Address bus – where to find data Data bus – data is loaded/saved over this line Control bus – says if it is loading or saving

9 Computers in the real world What is an instruction? CPU A CPU can perform a set number of tasks such as adding, subtracting etc. One of these is known as an instruction. All of the instructions together is known as a instruction set. Different types of micro-processor will have different instructions sets.

10 Computers in the real world What does an instruction look like? CPU Instructions on the CPU are written in binary – A add instruction in binary 1 08 – The same instruction as a normal number ADD 8 – What the computer sees and understands

11 Computers in the real world Opcodes and data Instructions have two parts to them. ADD 8 Opcode The opcode tells the CPU what to do. ADD tells the CPU to add two numbers together. The data part of the instructions tells the CPU what to add. In this case 8. The question is what do we add to? How does it work! What is this opcode? All shall be revealed! Data

12 Computers in the real world Instruction set of a simple computer Below is a table showing the instructions of a simple computer called the LMC or little man computer. OpcodeNameDataExplanation 1xxADDThe number to addIt will add a value from a register to the current value of the ACC 2xxSUBThe number to subtractIt will subtract value from a register to the current value of the ACC 3xxSTAStores a value into a registerWill take the contents of the ACC 5xxLDALoads a value from a registerWill take a value from a register and store it in the ACC 6xxBRALine number to “jump” to.Unconditional branch. Will jump to the given instruction number. 7xxBRZLine number to “jump” to.Branch if zero. Will only jump if the ACC is zero 8xxBRPLine number to “jump” to.Branch if positive. Will only jump if the ACC has a positive value. 901INPInput from the userWill input a value and store it in the ACC 902OUTNoneWill output the contents of the ACC

13 Computers in the real world Real CPU’s Real CPU’s have different instruction sets. Programs written in one instruction set CAN NOT be run on the other ARM ARM processors tend to be found on devices such as mobile phones or other portable devices. They have the advantage of using less electricity than desktop CPU’s x86 Desktop and laptop computers use x86. This instruction set was created a long time ago. Companies such as Intel and AMD create these types of micro-processor. Each of these companies add their own special instructions in a attempt to speed things up.

14 Computers in the real world Think of instruction sets as... Instruction sets can be thought of as a language. A French speaker could not talk to a mandarin speaker as they would not understand each other

15 Computers in the real world Registers A register is a small block of FAST memory stored on the CPU. Instructions will use the registers when they run A CPU will have small blocks of memory called registers. These are used to store calculations as the processor runs. As a program runs it will load / store values into the registers until it comes to the final result. Think of it like a table in your notebook. Each register can hold a separate number! RegisterValue

16 Computers in the real world ACC register The ACC stands for accumulator. It is used in all calculations and answers are ALWAYS stored into the ACC. The ACC acts like the display on a calculator. What happens when you type in = The result is stored on the display! In fact the calculator also uses an accumulator and has it’s own micro-processor! Hopefully that is not too surprising!

17 Computers in the real world A sample program to add 2 numbers The program below will display the result of adding 2 numbers. INP STA 1 INP ADD 1 OUT ACC - Register 1 - Let us look at how this program works.

18 Computers in the real world A sample program to add 2 numbers The program below will display the result of adding 2 numbers. INP STA 1 INP ADD 1 OUT ACC - Register 1 - INP – The user will be asked to enter a number onto the computer. The user enters the value 12. ACC - 12 Register 1 -

19 Computers in the real world A sample program to add 2 numbers The program below will display the result of adding 2 numbers. INP STA 1 INP ADD 1 OUT ACC - 12 Register 1 - STA 1 – The ACC is then saved into register 1. If we did not then the next INP instruction would overwrite it. ACC - 12 Register

20 Computers in the real world A sample program to add 2 numbers The program below will display the result of adding 2 numbers. INP STA 1 INP ADD 1 OUT ACC - 12 Register INP – The user will be asked to enter a number onto the computer. The user enters the value 5. ACC - 5 Register

21 Computers in the real world A sample program to add 2 numbers The program below will display the result of adding 2 numbers. INP STA 1 INP ADD 1 OUT ACC - 5 Register ADD 1 – Will take the value in register 1 and add it to the ACC. It then stores the result into the ACC ACC - 17 Register

22 Computers in the real world A sample program to add 2 numbers The program below will display the result of adding 2 numbers. INP STA 1 INP ADD 1 OUT ACC - 17 Register OUT– Will display the contents of the ACC on the screen.

23 Computers in the real world parts of the CPU A CPU has a number of different parts inside it. CU ALU MU Registers CU – Control Unit ALU – Arithmetic logic unit MU – Memory unit

24 Computers in the real world Control unit The control unit will communicate to devices over the buses. For example the hard drive or the graphics card. It also manages the CPU to allow it to run instructions. CU

25 Computers in the real world ALU - The arithmetic logic unit (ALU) will perform any maths related operations and any comparisons. So instructions like ADD, SUB and BRZ will be run by the ALU. ALU

26 Computers in the real world MU The memory unit (MU) is responsible for communicating with memory. It allows data to be loaded and saved. It is also referred to as the Intermediate access store (or IAS) MU

27 Computers in the real world Activity Make notes on the following in your revision power point. The parts of a CPU What is a register? What does the ACC do?

28 Computers in the real world Clock cycle CPU’s are measured by something known as the clock speed. This is a number measured in hertz. This says how many CPU cycles can be run per second. The bigger the number the more clock cycles can be run per second. So a 2Ghz is technically slower than a 3Ghz processor. Clock cycles are used to synchronize the CPU to ensure that the next instruction is not run before the previous one has completed. The shorter the cycle means the more instructions we can run in a single second. However some instructions need more than one clock cycle!

29 Computers in the real world So higher clock rates are what we want? Sadly no. Sometimes a CPU with a high clock speed (3.3Ghz) may be slower than one with a lower clock speed (2.4Ghz). Although it does mean more instructions can be run per second on a higher clock speed there is a draw back to this. Most of the time the CPU is idle!!! The reason why is that clock speed is only one measure of a CPU and is certainly not the most important. Other things you need to consider are – The architecture of the CPU If it is 32bit or 64bit The speed of the buses. Are there any bottle necks in the system (eg slow hard drive) How many cores are on the CPU? How big is the cache?

30 Computers in the real world Architectures CPU’s are put together in different ways. As CPU’s improve so does the way they handle instructions and talking to hardware. Normally when companies like Intel release a new processor architecture it will run at a lower clock speed. They then will try to increase the clock speed until the next architecture comes along. For example in 1993 Intel released the Pentium processor. In 1997 they then released the Pentium II processor. These both connected to the motherboard using different slots. A motherboard can only accept a very limited number of different CPU architectures. As such when a new CPU architecture comes out it may require a brand new way of connecting it to the CPU.

31 Computers in the real world 32 or 64 bit Most CPU’s run in 64bit currently. However there are still a LOT of processors still running in 32bit. So what does this mean? Computers store numbers and other data in binary. 32 bits mean that we can store up to 2,147,483,647 while in 64 bit we can store 9,223,372,036,854,775,807. (signed integers). That means that we can deal with bigger numbers more efficiently. This is great for doing things like – Academic research (universities) Decoding/encoding movies and music Games! IMPORTANT! Each piece of software must be compiled to work on 64bit. You can buy windows 64 bit but it does not mean your other programs will also be 64bit!

32 Computers in the real world Front side bus Remember that buses connect the CPU to each of the other devices on the computer. The bus is part of the motherboard. Buses transfer data to and from the CPU. The rate at which data can travel across this is measured in hertz. CPU’s are built to handle different front side bus speeds. The faster the speed the faster data can be transferred to/from the CPU. IMPORTANT! The CPU will spend most of it’s time waiting for devices to transfer data. Anything which can speed this up will greatly improve the speed of the system.

33 Computers in the real world Core blimey! A dual or quad core processor essentially means that it can run multiple instructions at the same time. Dual can run 2 and quad can run 4. Each core acts like a separate processor. This speeds up multitasking. Essentially it means that different processes can be run on different cores. Reducing the load on a individual core. However a single program gains NOTHING from extra cores unless it has been programmed specifically to use them. Having more cores will not improve the speed of a system unless you are running lots of different programs which require a large amount of CPU time. Normally you are still restricted by bottle necks such as the hard drive or the internet.

34 Computers in the real world Speed mismatch – the true cause of a slow system! This graph shows the speed difference between how long it takes to perform a task. The longer the bar the slower the device. As you can see the CPU is much faster than the internet or even the hard drive.

35 Computers in the real world Bottlenecks in the system So will a faster computer make your internet faster? The answer is unlikely. It would be faster creating the page but the CPU would still have to wait for the data to be sent over the telephone lines. Your hard drive is also a big bottle neck. When you load a program or load a file it needs to be transferred from the hard drive to memory. While this is happening the CPU will not be doing much!

36 Computers in the real world Really? Yeah really! Look at the graph below - This shows how busy the CPU is as a program is loaded (in this case Microsoft publisher). The CPU is used for very short bursts then not much else happens until another big burst. The CPU is idle for most of the loading. This shows that the hard drive is slowing the CPU down!

37 Computers in the real world I like Cache!! The cache is a small block of FAST memory stored either in the CPU or in-between the CPU and memory. Anything stored in the cache can be accessed MUCH faster than if it was accessed from main memory. If you turned the cache off your computer would run at about 10% of it’s current speed. Yes cache has that much of a impact on your system! So why do computer manufactures not tell you how big / last the cache is? Well they think you guys are dumb and need things simple! Next time your in PC world ask how much cache is in each laptop you see. That will confuse them. Now you know what I do with my weekends

38 Computers in the real world How does cache speed things up? When programs are fetched from memory the are stored in the cache. The CPU will look at the cache first for an instruction. If it is not in cache then the CPU will access it from main memory which is much slower. This is known as a cache miss. Cache ADD SUB BRA Fetch instruction Cache miss – Have to access from memory

39 Computers in the real world The 80/20 rule A computer spends 80% of its time in only 20% of the instructions. Later you will find out why this is! Cache takes advantage of this by putting that 20% of the code into the fast cache. That reduces the amount of cache misses and thus increases the speed of the system as whole! Cache ADD SUB BRA Fetch instruction Cache miss – Have to access from memory

40 Computers in the real world Why not make memory our of the same stuff as cache? Eventually they do! However there is some huge hurdles to overcome for that and it takes memory manufacturers to make cache bigger and enable it to act as main memory. Also there is a big cost factor. Cache memory is very expensive so the more we use the more expensive the system will be. Bright computer science type people have worked out that the speed increase you would get is very small over just having cache. This is mainly due to the 80/20 rule.

41 Computers in the real world Activity Explain in as much detail as you can – What effects the speed of a CPU? Focus on the following ONLY Cache Cores Clock speed These are the main ones you need for the exam. The others I have included for completeness.


Download ppt "Computers in the real world Objectives Understand what role the CPU plays in a computer Understand how CPU performance is measured Look at the different."

Similar presentations


Ads by Google