Computer Systems CS 208 Major Components of a

  • Slides: 33
Download presentation
Computer Systems CS 208

Computer Systems CS 208

Major Components of a Computer System n n n Processor (CPU) n Runs program

Major Components of a Computer System n n n Processor (CPU) n Runs program instructions Main Memory n Storage for running programs and current data Secondary Storage n Long-term program & data storage (hard disk, CD, etc) Input Devices n Communication from the user to the computer(e. g. keyboard, mouse) Output Devices n Communication from the computer to the user (e. g. monitor, printer, speakers)

Parts of a PC n n System Unit - the metal box that houses

Parts of a PC n n System Unit - the metal box that houses the processor, main memory, and secondary storage devices. Input and output devices - attached to the system unit via a device controller. n n The terms "input" and "output" tell you if data flow is into or out of the system unit. Abbreviated to “I/O”

Computer Systems System Unit Output device Input device

Computer Systems System Unit Output device Input device

The Processor § The processor is the "brain" of the computer system. § Main

The Processor § The processor is the "brain" of the computer system. § Main processor is called the Central Processing Unit (CPU). § A particular computer will have a particular type of processor, such as a Pentium or a SPARC chip. § Co-processors assist the CPU with some of the processing functions. Examples: § Math co-processors handle heavy duty math processing § Graphics coprocessors speed up the display of graphics onto the monitor

Component Interaction The CPU controls all of the other resources within the system, in

Component Interaction The CPU controls all of the other resources within the system, in order to accomplish a task.

The CPU n. The CPU is a silicon chip that contains millions of tiny

The CPU n. The CPU is a silicon chip that contains millions of tiny electrical components. n. The CPU’s three main parts are: n Control Unit n Arithmetic Logic Unit (ALU) n Registers

Central Processing Unit (CPU) Arithmetic / Logic Unit Control Unit Registers Performs calculations and

Central Processing Unit (CPU) Arithmetic / Logic Unit Control Unit Registers Performs calculations and decisions Coordinates processing steps Small, fast storage areas for instructions and data

Registers § Registers are small, fast memory within the CPU § Different registers hold

Registers § Registers are small, fast memory within the CPU § Different registers hold different things § instructions and addresses of instructions § data (operands) § results of operations

Special Purpose Registers contain specific information the CPU needs. n. Instruction Register (IR) contains

Special Purpose Registers contain specific information the CPU needs. n. Instruction Register (IR) contains the actual instruction which is currently being executed by the CPU. n. The Program Counter (PC) contains the address of the next instruction to be executed by the program.

General Purpose Registers §General Purpose Registers hold: § the operands for arithmetic and logical

General Purpose Registers §General Purpose Registers hold: § the operands for arithmetic and logical operations (ie. the values on which the operation will be performed) § the results of such operations §So General Purpose Registers are used for holding and manipulating data used by the CPU

Computer Systems Not All Processors Are Created Equal Newer machines use specialized processor chips

Computer Systems Not All Processors Are Created Equal Newer machines use specialized processor chips that have been developed to speed up the processing of data. n CISC ‑ Complex instruction set computer n Large instruction set, many formats RISC ‑ Reduced instruction set computer n Small instruction set, single or small variations in format n MPP ‑ Massive parallel processing n n Many CPUs working in parallel

Memory Computer Memory - millions/billions of on/off charges Divided into: n Bits 0 or

Memory Computer Memory - millions/billions of on/off charges Divided into: n Bits 0 or 1 n Bytes Groups of 8 bits A byte is the smallest unit of storage. (Can hold one text character) n Words Groups of bits/bytes (8, 16, 32, 64 -bits)

Memory Storage is usually too large to be expressed in bytes or words. Instead

Memory Storage is usually too large to be expressed in bytes or words. Instead we use: n n Kilobyte (KB) = 1024 bytes (210 bytes) Megabyte (MB) = 1024 x 1024 bytes or one million bytes (220 bytes) Gigabyte (GB) = 1024 x 1024 bytes or one trillion bytes (230 bytes) Terabyte (TB) = 1024 x 1024 bytes one quadrillion bytes (240 bytes)

Main Memory n n Each computer has a specific word size n Word sizes

Main Memory n n Each computer has a specific word size n Word sizes vary from computer to computer. n Word size is an even multiple of a bytes. Each word within memory can hold either n data or n program instructions

Main Memory Each memory cell has a numeric address, which uniquely identifies its location

Main Memory Each memory cell has a numeric address, which uniquely identifies its location 5248 5249 10011010 5251 5252 5253 5254 5255 5256 Each memory cell stores a set number of bits (some computers use 8 bits/one byte, others use words) A word is stored in consecutive memory bytes.

CPU and Memory n CPU can interact with main memory in two ways: n

CPU and Memory n CPU can interact with main memory in two ways: n It can write a byte/word to a given memory location. n The previous bits that were in that location are destroyed n The new bits are saved for future use. n It can read a byte/word from a given memory location. n The CPU copies the bits stored at that location and stores them in a CPU register n The contents of the memory location are NOT changed.

Main Memory Characteristics § Very closely connected to the CPU. § Contents are quickly

Main Memory Characteristics § Very closely connected to the CPU. § Contents are quickly and easily changed. § § § Holds the programs and data that the processor is actively working with. Interacts with the processor millions of times per second. Nothing permanent is kept in main memory.

Secondary Storage Characteristics § § Connected to main memory through a bus and a

Secondary Storage Characteristics § § Connected to main memory through a bus and a device controller. Contents are easily changed, but access is very slow compared to main memory. § Only occasionally interacts with CPU. § Used for long-term storage of programs and data. § Much larger than main memory (GBs vs. MBs).

Program Instructions n n Programs instructions are stored in secondary storage (hard disks, CD-ROM,

Program Instructions n n Programs instructions are stored in secondary storage (hard disks, CD-ROM, DVD). To process data, the CPU requires a working area n n n Uses Main Memory Also called: RAM (random access memory), primary storage, and internal memory. Before a program is run, instructions must first be copied from the slow secondary storage into fast main memory n Provides the CPU with fast access to instructions to execute.

Instructions n n An instruction is a sequence of bits. A simple instruction format

Instructions n n An instruction is a sequence of bits. A simple instruction format may consist of an operation code (op code) and an address or operands. Op Code n Operands / Address Instructions tell the computer’s CPU what to do.

Instructions n n The operation code specifies the operation the computer is to carry

Instructions n n The operation code specifies the operation the computer is to carry out (add, compare, etc) The operand/address area can store an operand or an address n n n An operand is a specific value or a register number An address allows the instruction to refer to a location in main memory The CPU runs each instruction in the program, starting with instruction 0, using the fetch-decodeexecute cycle.

Fetch-Decode-Execute Cycle n During the fetch part, the CPU fetches the next instruction from

Fetch-Decode-Execute Cycle n During the fetch part, the CPU fetches the next instruction from the address contained in the Program Counter and places the instruction in the Instruction Register. n n When a program starts, the program counter contains 0, so the instruction at address 0 is fetched. As soon as an instruction is fetched, the CPU adds 1 word to the contents of the Program Counter, so that it will contain the address of the next sequential instruction.

Fetch-Decode-Execute Cycle n n n The decode unit within the CPU deciphers the instruction

Fetch-Decode-Execute Cycle n n n The decode unit within the CPU deciphers the instruction in the Instruction Register and determines what operations need to be done and what type of operands will be used (decode part). During the execution part, the specified operation is performed (add, compare, etc). After execution of the instruction has been completed the cycle starts all over again (unless the instruction terminates the program).

Fetch-Decode-Execute Diagram CPU Fetch Program Counter (PC) Main Memory Get instruction and increment PC

Fetch-Decode-Execute Diagram CPU Fetch Program Counter (PC) Main Memory Get instruction and increment PC 3024 3023 Instruction Register add r 3, r 1, r 2 General Purpose Registers 33 r 1 45 r 2 78 r 3 Decode Determine what the instruction is (add) Execute In this case add r 1 and r 2 and put result in r 3. … 3020 3021 3022 add r 3, r 1, r 2 3023 3024 3025 3026 3027 3028 … Then begin again by Fetching the instruction in 3024….

Clocks § Computer systems have an internal clock, which is used to synchronize their

Clocks § Computer systems have an internal clock, which is used to synchronize their activities. § Processors run at a particular clock speed. § Clock speed is measured in Hertz § One Hertz is one clock tick per second. § MHz means mega Hertz §One MHz is one million clock ticks per second. §The clock speed determines how fast instructions can be run

Access to Instructions The hard disk is too slow to provide instructions to the

Access to Instructions The hard disk is too slow to provide instructions to the CPU. So programs are first loaded into main memory, which is much faster. The CPU can then access the instructions more quickly.

Cache Memory n n But as CPU speeds became faster, the main memory couldn’t

Cache Memory n n But as CPU speeds became faster, the main memory couldn’t provide the CPU with the instructions at a fast enough rate. So even faster memory ( cache memory) is now placed between the CPU and main memory to provide the instructions at an quicker rate to the CPU.

Cache Memory When an instruction or data is accessed from main memory, it is

Cache Memory When an instruction or data is accessed from main memory, it is placed in the cache. Second and subsequent use of the same instruction/data will then be faster, since it is accessed directly from the cache.

Primary and Secondary Cache Memory n n Most modern CPUs now have a cache

Primary and Secondary Cache Memory n n Most modern CPUs now have a cache memory (L 1), on the same silicon wafer as the CPU, to provide the CPU with instructions at the same clock speed as the CPU. An additional off-the-chip secondary cache (L 2) may also interact with the CPU at a slower speed.

L 1 and L 2 Cache Memory

L 1 and L 2 Cache Memory

User view of Computer Systems Applications e. g. Word, Netscape, etc Operating System –

User view of Computer Systems Applications e. g. Word, Netscape, etc Operating System – - the user interface Software that controls the hardware devices

How Programs Are Run n n The operating system presents an interface to the

How Programs Are Run n n The operating system presents an interface to the user (e. g. Windows Desktop) The user double clicks on an icon to run a program (e. g. Microsoft Word) n n n The operating system copies the program (or at least the first part of it) from the hard disk into main memory The CPU runs the instructions in the program, and presents the initial Word screen Within Word, the user uses the menu to open a document n n The application software (Word) asks the Operating System to open the file. The Operating System communicates with the hardware to open the file on the hard disk.