Part 1.pdf
Document Details
Uploaded by ExaltedNavy
Tags
Full Transcript
COMPUTER ORGANIZATION 1.PROCESSORS Instructor: Dr. Abrar Wafa OVERVIEW CLO2: Describe the role of each functional unit in performing the basic instruction execution cycle. CLO3: Describe the organization of the basic computer system and its major functional units. Outline: q Motherboard q CPU q D...
COMPUTER ORGANIZATION 1.PROCESSORS Instructor: Dr. Abrar Wafa OVERVIEW CLO2: Describe the role of each functional unit in performing the basic instruction execution cycle. CLO3: Describe the organization of the basic computer system and its major functional units. Outline: q Motherboard q CPU q Datapath q Registers q Instruction cycle q Parallel processing (Pipelining, CPU level) DIGITAL COMPUTER Ø A digital computer can perform arithmetic computations, manipulate strings of alphabetic characters, and be programmed to make decisions based on internal and external conditions. Ø The program and data prepared by the user are transferred into memory by means of an input device such as a keyboard. Ø Both program and data are stored in memory. Ø The control unit in the CPU retrieves the instructions, one by one, from the program stored in the memory. For each instruction, the control unit (in CPU) manipulates the data to execute the operation specified by the instruction. Ø An output device, such as screen, displays the results of the computations and presents them to the user. MOTHERBOARD X Ø A computer is an electronic device that processes the data with respect to the user’s requirements using I/O devices. Ø The data processing takes place in the CPU. The CPU is situated in a hardware circuit board called the motherboard or Printed Circuit Board(PCB). Ø A motherboard is made of plastic and silicon as well. It is a hub of a computer system. Ø A motherboard is a complex component with various kinds of ports, slots, cables connected to it. 4 MOTHERBOARD COMPONENTS Major components on a motherboard include: Basic input/output system (BIOS) chip: the program a computer's microprocessor uses to start the computer system after it is powered on Central Processing Unit (CPU) Random Access Memory (RAM): main memory. Chipset: manages the flow of data between components on a motherboard. Expansion slots: which connects components directly to the motherboard. COMPONENTS Interrupts & Executes instructions Digital computer consists of four main components: 1. Processor which is called Central Processing Unit (CPU) 2. Main Memory 3. Input / Output (I/O) Devices 4. All the above are interconnected by set of wires called Bus Stores programs & data (input, output, intermediate). 6 WHAT IS CPU? Ø The central processing unit (CPU) is responsible for interpreting and executing commands. Ø It is a small microchip that resides within a CPU package. Ø The CPU socket is the connection between the motherboard and the processor. CPU COMPONENTS The CPU consists of two main components: 1. Control Unit (CU) which is responsible for: a. Determining the sequence of operations to be performed. b. Fetching program instructions from main memory into the CPU and then determining what they do. 2. Datapath which is responsible for the actual data processing and performing Arithmetic and Logic operations. 8 DATAPATH Datapath consists of the following components: 1. Arithmetic and Logic Unit (ALU) a. Arithmetic unit which performs arithmetic operations like addition and subtraction and b. Logic unit performs logic operations such as AND, OR, NOT, etc. 2. Registers: a set of general-purpose registers and special purpose registers. 3. Interconnecting Bus: set of wires that connect the different CPU components together. Data Register General Register What are the registers? 9 THE CPU REGISTER FILE • A register is a high-speed memory of limited size located inside the CPU. • CPU registers have certain sizes for example (8, 16, 32, or 64-bit). • Registers can be read or written by the CPU. • Inside the CPU there are two types of registers categorized according to their functions: Ø General purpose registers and Ø Special purpose registers. Data Register General Register 10 THE CPU REGISTER FILE General purpose registers are used to store intermediate results and data needed to execute an instruction. Data Register General Register 11 THE CPU REGISTER FILE Special purpose registers store specific type of data. Some examples are: PC (program counter) or in Intel processors it is called IP (Instruction Pointer): it holds the memory address of the next instruction to be executed. Data Register General Register IR (Instruction Register) holds the instruction currently being executed. 12 THE CPU REGISTER FILE Memory Address Register (MAR): This register is connected to the address lines that connect the CPU and the main memory. It holds the address of the main memory location to be read from or written into main memory by the CPU. Memory Data Register (MDR): This register is connected to the data lines that connect the CPU and the main memory. It holds the data to be read from or written into main memory by the CPU. Data Register General Register 13 THE CPU REGISTER FILE Flag register: bits in this register are used to reflect the outcome of last arithmetic and logic operation performed by the CPU. Each bit is called a flag bit. When the bit is set (=1) it has a meaning that differs than when it is cleared (=0). 14 FLAG REGISTER Some of the important flags: ZF stands for Zero Flag. When ZF =1, it means that the result of the last operation is zero. When ZF =0, it means that the result of the last operation is not zero. SF stands for Sign Flag. When SF =1, it means that the result of the last operation is negative. When SF =0, it means that the result of the last operation is positive. CF stands for Carry Flag. When CF =1, it means that there is a carry out of the last operation. When CF =0, it means that there is no carry out of the last operation. 15 CPU INSTRUCTIONS Ø The CPU can execute only machine instructions in binary. Ø So, what is the format of such machine instructions? 16 FORMAT OF MACHINE INSTRUCTION Specify the type of operation Immediate data or address Usually, the machine instruction consists of two main fields: Ø Operation field (Opcode) contains the binary code that represents the operation to be performed. Ø Operand(s) field(s) specifies the actual data or the address of the data in main memory that are processed by the machine instruction. Some machine instructions take zero, one, two, or more operands. 17 INSTRUCTION EXECUTION CYCLE When a program is executed, 1. The operating system reads the program executable file stored on the hard disk 2. The operating system loads it into main memory at a specific memory location. 3. Then the operating system will tell the control unit the address where the first instruction is stored in memory. Ø This address is stored in the PC register. 18 INSTRUCTION EXECUTION CYCLE The execution of the instruction in the CPU is referred to as: Fetch > Decode > Execute > Store cycle 1. Fetch: Get the next instruction from RAM (Add two values) 2. Decode: Figure out what to do and gather the data needed to do it (5 + 2) 3. Execute: Do the operation (5 + 2 = 7) 4. Store: Save the result, and Repeat (billions of times/second)! 19 INSTRUCTION EXECUTION CYCLE In order for any instruction to be executed it has to go through the following steps: 1. Fetch instruction: a) the CPU reads the instruction from main memory at the location stored in PC. b) The instruction is then stored in IR. c) Also, the PC is incremented so that it will hold the address of the NEXT instruction to be executed. 2. Decode instruction: in this stage the control unit will determine the instruction type and what it performs based on its opcode field. 3. Fetch operands: the instruction operands are brought into CPU from memory if needed. 4. Execute the instruction 5. Store the result. 20 PROGRAM EXECUTION SPEED • When designing a processor the most important thing to consider is the program execution speed. • The program execution speed: is Time needed to execute a program Ø Number of instructions per program * Number of processor cycles needed to perform the instruction * Time of the processor cycle (period) 21 SYSTEM CLOCK Ø To synchronize all components on the motherboard, the computer needs to have a system clock, which means all computer components do their work only if the clock is high; never when it's low. Ø Every computer contains an internal or master clock that controls all the system operations. Ø The figure shows the clock which is repeated pulses of zeros and ones that form regular patterns called clock cycles. Ø The length of one clock cycle measured in units of time is called the clock period (T). Ø The inverse of the period (1/T) is called the clock rate or the clock frequency (F) which gives the number of cycles per second and measured in Hertz (Hz). Ø Hertz is one cycle per second. 1MHz = 1 Million cycles per second. 22 RISC VERSUS CISC PROCESSORS RISC AND CISC Sig : In order to increase the processor speed – reducing the time needed to execute an instruction – one can either: Reduce the number of machine instructions or Reduce number of clock cycles needed to execute an instruction. Processors designed using the first approach are called Complex Instruction Set Computers (CISC) processors. Processors designed using the second approach are called Reduced Instruction Set Computers (RISC) processors. 24 CISC PROCESSOR CISC reduces the number of machine instructions Ø In order to reduce the machine instructions per program, the machine instructions are designed so that one instruction can perform many simple tasks. Ø This requires complex hardware that is capable to perform many simple tasks in one complex machine instruction. Ø The instruction execution in this case usually need more than one clock cycle to be performed. Ø However, in this case, the number of machine instructions per program will decrease. Ø Intel Processors are CISC processor 25 RISC PROCESSOR RISC reduces number of clock cycles needed to execute an instruction Ø The machine instruction is very simple so that it takes on a single clock cycles to be executed by the hardware. Ø In this case, the number of machine instructions per program will increase. Ø Sun SPARCE, PowerPC, Compaq Alpha processors are RISC processors 26 EXAMPLE Suppose the following operation is to be performed A=A+5. Ø This operation needs first the value of A to be read from main memory then the value 5 is added to it and finally the result has to be stored back into memory. Ø On CISC processor, all the above steps can be done by a single complex machine instruction which is Add A, 5 Ø This instruction will be executed in more than a single clock cycle but the program size is one machine instruction. 27 EXAMPLE CONT. Risc On RISC processor, one machine instruction is needed for each of the steps needed to perform the instruction which are: Load R0, A Add R0, 5 Store A, R0 Ø Where R0 is one of the general purpose registers in the CPU Each step above needs only a single clock cycle to be performed but the overall program size in this case is 3 instructions. 28 RISC VERSUS CISC RISC CISC Instructions are simple Instruction are complex Instructions are executed in one clock cycle Instructions usually need more than a single clock cycle to execute Special instructions are needed to access memory for read or write operation (Load and Store) Any instruction can access memory More than one instruction can be executed on parallel Only a single instruction can be executed 29