Topic 2 - The CPU and Primary Memory PDF
Document Details
Uploaded by Deleted User
NCC
Tags
Summary
This document covers the CPU and Primary Memory topic in computer science. Topics discussed include components, functions, and the fetch-execute-decode cycle.
Full Transcript
Introduction to Computer Science Topic 2: The CPU and Primary Memory © NCC Education Limited The CPU and Primary Memory Topic 2 - 2.2 Scope and Coverage This topic will cover: The purpose of a computer processor...
Introduction to Computer Science Topic 2: The CPU and Primary Memory © NCC Education Limited The CPU and Primary Memory Topic 2 - 2.2 Scope and Coverage This topic will cover: The purpose of a computer processor Components of a CPU The functions of a CPU How components of a CPU communicate with each other The fetch-execute-decode cycle Primary Memory: RAM and ROM Primary Memory: Cache and Registers The CPU performance The CPU and Primary Memory Topic 2 - 2.3 Learning Outcomes By the end of this topic students will be able to: Describe the purpose of a CPU, its components and their functions Describe the stages and components involved in the Fetch Decode Execute Cycle Describe the role of primary memory (RAM, ROM, registers and cache memory) Describe a range of factors that affect the CPU performance The CPU and Primary Memory Topic 2 - 2.4 The Unit Roadmap There are 12 Introduction to Computer Systems CPU and Primary Memory lessons/topics in this Secondary Storage unit. Application Software The topic for today is System Software CPU and Primary Data Representation – Numbers and Text Memory. Data Representation – Images and In the next topic, you Sound Logic Gates will look at Secondary Computer Networks Storage. Network Security Computer Ethics Summary and Exam Preparation The CPU and Primary Memory Topic 2 - 2.5 Terminology Terminology will be explained in the lectures and tutorials on computer systems and computer hardware You should make notes Ask questions if you there is anything that you don’t understand 2.1 The purpose and components of a CPU The CPU and Primary Memory Topic 2 - 2.7 A Processor A processor is also referred to as a microprocessor or a central processing unit (CPU). It is the main chip in a computer system. It is located on an integrated circuit (IC), a silicon chip on a motherboard. Multi-core processors have two, three or four processors on a single chip. The CPU and Primary Memory Topic 2 - 2.8 Functions of a CPU A processor performs the following functions: Mathematical operations - addition, subtraction, multiplication and division Logic operations – it compares data and makes decisions Processes data Exchanges data with other components and peripherals Moves data from one memory location to another The CPU and Primary Memory Topic 2 - 2.9 Von Neuman Architecture The architecture shown below is the design that most modern CPUs follow. It is called the Von Neumann Architecture. The CPU and Primary Memory Topic 2 - 2.10 Components of a CPU The main elements of a processor are: Arithmetic and logic unit (ALU) Control unit (CU) Clock and Decode Registers The CPU and Primary Memory Topic 2 - 2.11 Arithmetic and Logic Unit Where the computer processes instructions It consists of two sections: Arithmetic section performs calculations on data e.g. addition Logic section deals with logic and comparisons, e.g. it works out if a value is greater, less than or equal to another value The CPU and Primary Memory Topic 2 - 2.12 Control Unit Performs three main tasks: Controls and monitors hardware attached to a computer system to ensure commands given to it by application software are used, e.g. checks that instructions are sent to a printer accurately Controls input and output of data so instructions are sent accurately to the correct component at the correct time Controls the flow of data within the processor the fetch-execute-decode cycle It contains a clock and a decoder unit The CPU and Primary Memory Topic 2 - 2.13 Clock Found on a microchip that regulates the timing and speed of all a computer’s functions – also known as the internal clock or real-time clock (RTC) Faster clock speeds result in more operations being performed in a set time A clock’s speed is measured in Megahertz (MHz) or Gigahertz (GHz) Typical clock speeds are 3 GHz - three thousand million times a second The clock rate influences the performance of CPU, making some CPUs work faster than others Some powerful processors are superscalar – this means that they can execute more than one instruction per clock cycle The CPU and Primary Memory Topic 2 - 2.14 Decoder Responsible for interpreting and decoding machine- level instructions fetched from memory. These instructions are encoded in binary and represent the operations that the CPU needs to perform. The CPU and Primary Memory Topic 2 - 2.15 Registers A register is a small temporary storage and part of a CPU. May hold instructions, storage addresses or bit sequences or characters. The CPU and Primary Memory Topic 2 - 2.16 Registers A processor based on Von Neumann architecture has five registers which it uses for processing: program counter - holds the memory address of the next instruction to be fetched from primary memory memory address register (MAR) - holds the address of the current instruction that is to be fetched from memory, or the address in memory to which data is to be transferred memory data register (MDR) - holds the contents found at the address held in the MAR, or data which is to be transferred to primary memory current instruction register (CIR) - holds the instruction that is currently being decoded and executed accumulator (ACC) – holds the data being processed and the results of processing The CPU and Primary Memory Topic 2 - 2.17 Cores A core contains an ALU, a CU and registers. Multiple programs can run simultaneously if a computer has multiple cores. Each core is capable of fetching, decoding and executing its own instructions. The more cores a CPU has, the greater the number of instructions it can process in a given space of time. Many modern CPUs are dual (two) or quad (four) core processors. This provides vastly superior processing power. The CPU and Primary Memory Topic 2 - 2.18 The Role of Buses A bus connects a CPU to other components. It moves instructions and data. A bus speed is measured in MHz. It sends 8, 16 or 32 bits at a time. The system bus or front-side bus (FSB) connects a CPU to memory. CPU cores share L2 and L3 cache across the FSB. L2 cache is also connected via the back-side bus (BSB). The BSB is faster than the FSB. The CPU and Primary Memory Topic 2 - 2.19 Address Bus and Data Bus The FSB contains two types of bus: An address bus - sends data in one direction only, from the CPU to RAM and sends an address of the location where data needs to be sent A data bus - sends data in two directions either to memory or receives data from memory 2.2 The Fetch Decode Execute Cycle The CPU and Primary Memory Topic 2 - 2.21 Von Neuman Architecture The CPU and Primary Memory Topic 2 - 2.22 The Fetch-Decode-Execute Cycle The basic steps a central processing unit (CPU) takes to execute an instruction. This cycle is the core process that enables a computer to carry out instructions from a program. Software commands are executed in the fetch-execute- decode cycle: Each instruction is sent to the CPU from RAM An instruction is decoded and processed by the CPU This is performed until each instruction is executed The CPU and Primary Memory Topic 2 - 2.23 The Fetch-Decode-Execute Cycle Fetch 1. Copy memory address from the program counter to the MAR 2. Copy the instruction stored in the MAR address to the MDR 3. Increment the program counter to point the address of the next instructions, ready for the next instructions. Decode 4. The instruction in the MDR is decoded by the Control Unit 5. The Control Unit then prepares for the next step, e.g. by loading values into the MAR or MDR The CPU and Primary Memory Topic 2 - 2.24 Execute Execute 1. An instruction is executed in the CPU’s ALU 2. The result of the processing is stored in a register called the accumulator 3. Then it is stored in RAM or used in another CPU operation 4. Once the execution is complete, the CPU begins another cycle The CPU and Primary Memory Topic 2 - 2.25 The Fetch-Decode-Execute Cycle 2.3 Primary Memory The CPU and Primary Memory Topic 2 - 2.27 Memory Primary memory includes the following types: Random Access Memory (RAM) Read Only Memory (ROM) Firmware Virtual memory Complementary metal-oxide-semiconductor (CMOS) The CPU and Primary Memory Topic 2 - 2.28 RAM RAM serves as your system's momentary memory, holding data temporarily when your computer engages in calculations. This short-term storage is volatile, disappearing once the computer is powered off. Its data and instructions can be accessed in any order, which is why it’s given the name ‘random access’ To prevent data loss, especially when working on documents, spreadsheets, or other files, it is crucial to save them, transferring the data to the hard drive, which functions as long-term storage. The CPU and Primary Memory Topic 2 - 2.29 RAM The capacity of RAM is measured in megabytes (MB) or gigabytes (GB). Having more RAM enables your computer to handle multiple tasks simultaneously. Insufficient RAM may result in sluggish performance when running several programs concurrently. Consequently, many individuals opt to augment their computer's RAM to enhance overall system performance. RAM can be extended by adding strips of RAM as extension packs The CPU and Primary Memory Topic 2 - 2.30 Virtual Memory A technique used to manage memory and simulate RAM. A computer might have 2Gb of RAM available for the CPU to use, however, that amount of RAM might not be enough to run all the programs that a user wants to run simultaneously. Part of secondary storage, e.g. hard disk is set aside by the operating system as a temporary memory store - this frees up space in RAM to load another program. Less expensive than buying more RAM but can slow down a computer if virtual memory begins to fill up. The CPU and Primary Memory Topic 2 - 2.31 ROM Used to store instructions and information permanently. Information stored in ROM is read-only and cannot be changed. It is fast, non-volatile memory. Instructions stored in ROM include ordering a computer to start up (boot-up) and loading a computer’s operating system. Instructions needed during booting-up are referred to as firmware. The CPU and Primary Memory Topic 2 - 2.32 Firmware Firmware is software that is stored in a computer or other hardware device's ROM. It is written directly onto a hardware component. It provides instruction on how a component should operate. The CPU and Primary Memory Topic 2 - 2.33 CMOS Battery CMOS is a small amount of RAM supplied by a battery located on a motherboard. It stores information about a computer’s components, passwords, date and time and boot settings. As RAM chips lose the information stored in them when a computer’s power is switched off, the CMOS battery supplies constant power to the CMOS chip and the information contained in CMOS is retained. The CPU and Primary Memory Topic 2 - 2.34 Expansion Slots Motherboards contain expansion slots that various components can be slotted into. Components can include: – RAM chips – Expansion cards such as: Network interface cards (NICs) Graphics cards/video display cards Sound cards The above are used to upgrade/enhance a computer system’s functions There is a range of different slots that internal and external devices can connect to and different computers have different types and numbers of slots, therefore, care must be taken to use a card that matches a particular slot. 2.4 Performance Factors The CPU and Primary Memory Topic 2 - 2.36 Performance Factors of a CPU Three factors affect a CPU’s performance: – Clock speed – Cores – Cache size The CPU and Primary Memory Topic 2 - 2.37 Clock Speed The speed of a CPU is referred to as the clock rate and this controls how fast instructions are performed. It is measured in megahertz (MHz) or Gigahertz (GHz). 1 MHz - 1 million cycles a second 1 GHz - 1 billion cycles a second The CPU and Primary Memory Topic 2 - 2.38 Clock speed The higher the frequency, the more instructions can be performed in any given moment of time. The more pulses per second, the more FDE cycles can be performed and the more instructions that are processed in a given space of time. Today, processors commonly run at a rate of 3 gigahertz (GHz) to 5 GHz, which is 3 billion to 5 billion pulses or cycles per second. The CPU and Primary Memory Topic 2 - 2.39 Number of Cores The more cores a CPU has, the greater the number of instructions it can process in a given space of time. Many modern CPUs are dual (two) or quad (four) core processors. This provides vastly superior processing power. Be careful not to say it can do double the number of instructions because some operations require to be run on one processor, so having 2 cores increases the amount of FDE cycles but not doubles. The CPU and Primary Memory Topic 2 - 2.40 Cache Size Cache is a small amount of high-speed random access memory (RAM) built directly within the processor. It is used to temporarily hold data and instructions that the processor is likely to reuse. This allows for faster processing as the processor does not have to wait for the data and instructions to be fetched from the RAM. The CU checks cache for instructions before it requests data from RAM. The CPU and Primary Memory Topic 2 - 2.41 Cache Size The more cache memory a computer has, the faster it runs. However, because of its high-speed performance, cache memory is more expensive to build than RAM. Cache memory tends to be very small in size. To get around this issue, different types of cache exist: L1 cache has extremely fast transfer rates, but is very small in size. The processor uses L1 cache to hold the most frequently used instructions and data. L2 cache is bigger in capacity than L1 cache, but slower in speed. It is used to hold data and instructions that are needed less frequently. The CPU and Primary Memory Topic 2 - 2.42 Review of Lecture Two In this lecture, we have discussed: The role of a computer processor Types of processor Components of a CPU The functions of a CPU How components of a CPU communicate with each other The fetch-execute-decode cycle The CPU and Primary Memory Topic 2 - 2.43 References Microprocessors http://www.economist.com/topics/microprocessors Explaining Computers, Christopher Barnatt, 2014 http://www.explainingcomputers.com/hardware.html#processors The CPU and Primary Memory Topic 2 - 2.44 Do You Know This? CPU clocks can sometimes be sped up slightly by the user. This process is known as overclocking. Overclocking can cause long term damage to the CPU as it is working harder and producing more heat. The CPU and Primary Memory Topic 2 - 2.45 Topic 2 Exam questions / Quiz Q1. State three factors that influence the performance of a processor. Q2. Explain the function and purpose of the Control Unit. Q3. Describe the ‘decode’ part of the FDE cycle. Q4. Give two differences between RAM and ROM. Q5. What is virtual memory? The CPU and Primary Memory Topic 2 - 2.46 Topic Summary You can now: Describe the purpose of a CPU, its components and their functions Describe the stages and components involved in the Fetch Decode Execute Cycle Describe the role of primary memory (RAM, ROM, registers and cache memory) Describe a range of factors that affect the CPU performance The CPU and Primary Memory Topic 2 - 2.47 References Microprocessors http://www.economist.com/topics/microprocessors Explaining Computers, Christopher Barnatt, 2014 http://www.explainingcomputers.com/hardware.html#processors Topic 2 – The CPU and Primary Memory Any Questions?