240 likes | 247 Views
Learn about the components and purpose of a computer CPU, and the factors that affect its performance. Explore the Fetch/Execute Cycle and techniques to improve CPU performance.
E N D
What’s going on here? Can you think of a generic way to describe both of these?
Lesson Objectives Aims • To understand what a computer is • To understand the role and purpose of a CPU • To be able to describe the Fetch/Execute Cycle • To be able to discuss factors affecting CPU performance A note about notes: We will not be holding your hands in lessons. You are more than capable of working out when you should be making a note of things as we go through a lesson. If something is truly essential to copy down you will see this symbol: Otherwise, use your common sense, make notes on things and ask questions to fill out the gaps in your understanding.
Before we start What IS a computer? What is its purpose?
What IS a computer? • A machine which performs calculations • A general purpose or “stored program” machine • A device capable of processing and manipulating data from inputs to provide useful output • What is its purpose? • To provide automation • To be used as a problem solving tool • To carry out tasks accurately • To perform repetitive tasks
What is a computer? A “computer” need only consist of a few important components: This generic structure is known as the Von Neumann Architecture He was a total nutter and we’ll learn more about him later
In context… Ports for input and output devices: Keyboards Mice Speakers Microphones Network Cables Memory Unit/Storage (HDD) Central Processing Unit Motherboard – Physical connectivity, buses etc Memory Unit (RAM)
The purpose of a CPU • It’s job is to: • Fetch instructions • Decode what they mean • Carry them out • Store the result somewhere • These four things are “processing”
CPU instructions Get used to this! You will be making “assembly language” programs using these instructions and more very soon! • ALL software is simply a long list of instructions • A CPU will have a set list of instructions it understands. By combining these we can make it produce useful output. • Instructions are SIMPLE: • ADD • BRP • STA
The endless cycle CPU Data Bus (wires for data to travel down)
Task – in pairs Place the following parts of the fetch execute cycle in order: Fetch The PC is incremented so that it points to the next instruction to be fetched. The Program Counter (PC) contains the address of the next instruction to be fetched. The entire instruction is copied from the MBR and placed in the Current Instruction Register (CIR). The instruction is copied from the memory location contained in the MAR and placed in the Memory Buffer Register (MBR). The address contained in the PC is copied to the Memory Address Register (MAR). Execute The processor checks for interrupts (signals from devices or other sources seeking the attention of the processor) and either branches to the relevant interrupt service routine or starts the cycle again. The instruction is decoded and executed. The address part of the instruction is placed in the MAR.
Answers Fetch The Program Counter (PC) contains the address of the next instruction to be fetched. The address contained in the PC is copied to the Memory Address Register (MAR). The instruction is copied from the memory location contained in the MAR and placed in the Memory Buffer Register (MBR). The entire instruction is copied from the MBR and placed in the Current Instruction Register (CIR). The PC is incremented so that it points to the next instruction to be fetched. Execute The address part of the instruction is placed in the MAR. The instruction is decoded and executed. The processor checks for interrupts (signals from devices or other sources seeking the attention of the processor) and either branches to the relevant interrupt service routine or starts the cycle again.
Questions What is software? What role does the CPU play in a computer system? What are the three core components of any computer system? Give examples where appropriate What is the purpose of RAM in a computer system?
Back to our factory machines… How could we improve these situations to get more done in the same amount of time?
Improvements • Speed • Simple? The faster you work, the faster it gets done! • Number of machines • Parallel working means simultaneous output • Many hands make light work! • Problems? • Need more raw materials close to hand (working cache)
Improving CPU performance Increase the number of Cores Increase the clock speed Increase the Cache size There are three main methods
Task Increase the number of Cores Increase the clock speed Increase the Cache size “Improving CPU Performance” For each featureanswer the following What is this feature and how does this increase performance? What trade offs/disadvantages are there? Are there any situations where this feature would not provide a significant increase in apparent speed to a user? Finally, use the following resource to find out what “pipelining” is and add this to your notes http://www.eastaughs.fsnet.co.uk/cpu/further-pipelining.htm
Compare notes… • The speed of the fetch-execute cycle is determined by an electronic clock chip. • Generally, a quartz crystal circuit is used to generate clock pulses at a constant rate. • The clock speed is measure in Hertz (Hz) or cycles per second. • 1hz = 1 cycle per second • 1Mhz = 1 million cycles per second • 1Ghz = 1 billion cycles per second • Simply, the higher the clock speed, the more cycles per second, the more instructions that can be processed. • However… The CPU is rarely used at full capacity. See Cache… Clock Speed
Cores • Modern CPU’s are actually many CPU’s in one chip. Each core is a CPU in it’s own right • More cores mean the CPU can: • Split a problem between cores • Run multiple programs at once • However as you will learn, four cores does not always mean the computer will work four times faster! Scheduling instructions to run in parallel and writing software that can be split in to “threads” is extremely challenging.
Cache CPU’s are faster than all other components in a system RAM is much slower, usually half speed This means a CPU could waste potentially 50% of its processing power simply doing nothing whilst waiting for instructions Cache memory helps solve this problem by keeping a store of frequently used instructions/data on chip L1 Cache runs at the same speed as the CPU There can be L2 and L3 cache that runs slightly slower (a few clock cycles!) this is generally bigger, but the trade off is always speed Cache is only as useful as the prediction and pre-fetch algorithms the CPU uses. Often when programs “branch” or act in an unpredictable manner, the cache is useless and has to be flushed/refreshed.
Cache • Fast access speeds • Local store of data or instructions • Can drastically reduce read/idle times • Less need to access RAM/Frequency • Can use predictive algorithms to fill • Limited capacity • One “miss” means a cache flush and then idle time • Prediction can be difficult
Pipelining Linear v’s Pipelined: http://www.eastaughs.fsnet.co.uk/cpu/further-pipelining.htm
Review/Success Criteria You should now be confident that you know: • What the main components of a computer are • What the “Von Neumann Architecture” is (we will revisit this later) • What a CPU is, does and what simple CPU instructions look like • Four factors that affect CPU performance. For next lesson you must: • Find out what a “register” is in a CPU • What a “Data Bus” is and some examples of these