Computer Organization PDF
Document Details
Uploaded by Deleted User
Tags
Related
- Computer Organization and Architecture Lecture Notes PDF
- Unit 1 Computer Organization And Architecture Structure and Function PDF
- Struttura dell'Elaboratore per Studenti PDF
- Computer Organization and Architecture PDF
- Cours de l’Architecture des Ordinateurs - PDF
- Computer Organization and Architecture Structure and Function PDF
Summary
This document provides an introduction to computer organization, covering the basics of how computers process data, different types of computers (analog, digital, hybrid), and the components of a computer system. It also explains the von Neumann architecture and various addressing modes in detail.
Full Transcript
# Computer Organization ## Basics Introduction A computer is a device that transforms data into meaningful information. It processes the input according to the set of instructions provided to it by the user and gives desired output. Computers are of various types. They are categorized in 2 ways:...
# Computer Organization ## Basics Introduction A computer is a device that transforms data into meaningful information. It processes the input according to the set of instructions provided to it by the user and gives desired output. Computers are of various types. They are categorized in 2 ways: 1. On the basis of size. 2. On the basis of data handling capability. ### On the basis of size * Based on size, computers are of these types: 1. Super computer 2. Mainframe computer 3. Mini computer 4. Workstation 5. Personal computer (PC) ### On the basis of Data Handling Capability Based on data handling capability, computers are of 3 types: 1. Analog Computer 2. Digital computer 3. Hybrid Computer ## Super Computer When we talk about speed, the first name that comes in our minds is a super computer. * They are the biggest and fastest computer in terms of speed processing. * Super computers are designed so that they can process a huge amount of data. Live processing of trillions of information throughout the set of instructions. * This is because of thousands of interconnected processors in super computers. * It is basically used in scientific and engineering applications such as weather forecasting, nuclear energy research, etc. * It was developed by Regens Carey in 1976. ## Mainframe Computer Mainframe computers are designed in such a way that it can support hundreds of thousands of user processes at a time. * It can support multiple programs simultaneously. So they can execute all processes at a time. * All these features make the mainframe computer ideal for large organizations like banking, telecom sectors, etc. * Howard Aiken is the inventor (1920). * 1st mainframe computer - Harvard Mark 1,1930. ## Mini Computer Mini computer is a medium size multiple processing computer. In the type of computer there are two or more processors after available. * Mini computers are used in the place of institute or departments for different working style. Like for billing of operations, accounting operations. * It is smaller than mainframe computer, larger than micro computer. ## Workstation Workstation is designed for technical or scientific applications. It consists of large amount of RAM and high speed 1st microprocessors with high speed graphics. * It is generally used to perform specific tasks with great accuracy. * It is a single user computer. ## Personal Computer (PC) * It's also known as micro computer. * It is basically a general-purpose computer and designed for a single user. * It consists of microprocessor such as CPU, memory unit, input unit, output unit. * This kind of computer is suitable for personal work such as making assignments, watching movies, or office work. * Ex: Laptop, Desktop. ## Analog Computer An analog computer is a type of computer that uses the continuous variation of physical phenomena such as physical, mechanical and electrical to model the problem being solved. * They do not use discrete values, but use continuous values. * Analog has less memory unit. * Useful machine to perform differential equations. * Accuracy is low and faster speed. * Ex: Electric Integrators. ## Digital Computer Digital Computer is any of a class of devices capable of solving problems by processing information in discrete form. * It operates on data including magnitudes, letters. * The first electronic digital computer was developed in late 1940s. And used for numerical computations. * Including IBM PC, Apple Macintosh as well as modern smartphones. ## Hybrid Computers In hybrid computers, a computer which performs both analog and digital operations simultaneously. * Hybrid computers are used in airlines services, weather forecasting services, cloud computing services. # Computer Organization || Von Neumann Architecture ## Fixed Program Computers: Their function is very specific and they couldn't be reprogrammed, e.g calculators. ## Stored Program Computers: These can be programmed to carry out many different tasks, applications are stored on them, hence the name. ## Modern Computers Modern computers are based on a stored program concept introduced by John Von Neumann. * In this stored program concept, program and data are stored in a separate storage unit called memories, and are treated the same. This novel idea meant that a computer built with this architecture would be much easier to reprogram. ### Von Neumann Architecture The architecture is based on the following components: 1. **Central Processing Unit (CPU):** It’s the brain of the computer, responsible for fetching instructions, decoding them, and executing them. 2. **Main Memory:** This is where the program and data are stored. 3. **Input/Output Devices:** These allow the computer to interact with the outside world. The CPU is further divided into three main components: 1. **Control Unit (CU):** Responsible for managing the flow of data and instructions. 2. **Arithmetic Logic Unit (ALU):** Responsible for performing arithmetic and logical operations. 3. **Registers:** Small, high-speed storage locations that hold data and instructions temporarily during processing. These components are connected by a bus, which is a set of electrical lines used for communication. There are three types of buses: 1. **Data Bus:** Carries data between the CPU, memory, and I/O devices. 2. **Address Bus:** Carries memory addresses to specify the location of data. 3. **Control Bus:** Sends control signals from the CPU to other components. ## Instruction Cycle An instruction is executed in four phases: 1. **Fetch:** An instruction is fetched from memory. 2. **Decode:** The instruction is decoded. 3. **Calculate Effective Address:** If the instruction has an indirect address, the effective address is calculated. 4. **Execute:** The instruction is executed. The following registers and signals are involved in the instruction cycle: * **AR - Address Register:** Holds the effective address of the instruction. * **PC - Program Counter:** Holds the address of the next instruction to be fetched. * **IR – Instruction Register:** Holds the current instruction. * **I – Instruction Format:** The binary representation of the instruction. * **D7 – Decoder Output:** The opcode of the instruction. * **SC – Sequential Counter:** Keeps track of the instruction cycle. * **TO, T1, T2, T3 – Clock Cycles:** These signals determine the time for each phase of the instruction cycle. ### Fetch and Decode Phase During this phase, the instruction is fetched from memory and decoded into the opcode and operand. ### Execute Phase During this phase, the instruction is executed by the ALU. ## Addressing Modes * Addressing mode refers to the way in which an operand of an instruction is specified. There are many types of addressing modes, each with its own advantages and disadvantages. ### Implied Addressing Mode * The operand is not explicitly mentioned in the instruction. The CPU implicitly knows what the operand is. * This mode is simple and efficient, but it is limited to operations that use an operand that is already known to the CPU. * Ex: Complement Accumulator (CMA) instruction, which replaces the current value of the accumulator with its complement. ### Immediate Addressing Mode * The operand is given as an immediate value in the instruction. * This mode is useful when the operand is a constant value. The CPU does not need to access the operand in memory. * Ex: `MOVE R1, #10`. ### Register Direct Addressing Mode * The operand is a register. * This mode is fast as the register can be accessed directly. * Ex: `ADD R1, R2`. ### Register Indirect Addressing Mode * The instruction specifies a register, and the content of that register contains the address of the operand, which is in memory. * This mode is useful when you need to access an operand whose address is stored in a register. * Ex: `ADD R1, (R2)`. ### Displacement Addressing Mode * The effective address of the operand is calculated by adding the content of a base register to the displacement value, a fixed offset. * This mode is useful when you need to access an operand that is located near a known base address. * Ex: `ADD R1, X(R2)`. * X is the displacement value, the operand is at `X` offsets from the `R2` register. ### Relative Addressing Mode * The effective address of the operand is calculated by adding the content of the program counter (PC) to the displacement value. * This mode is useful for accessing operands that are located near the current instruction. * Ex: `ADD R1, X(PC)`. ### Base Addressing Mode * The effective address of the operand is calculated by adding the content of a base register to the displacement value. * This mode is useful for accessing operands in a segment of memory, often used in segmented memory systems. * Ex: `ADD R1, X(RB)`. ### Index Addressing Mode * The effective address of the operand is calculated by adding the content of an index register to the displacement value. * This mode is useful for accessing data in arrays or tables. * Ex: `ADD R1, X(RX)`. ### Direct Addressing Mode * The operand is located at an address that is explicitly mentioned in the instruction. * This mode is simple and efficient, but it is limited to accesses to locations that are known at compile time. * Ex: `ADD R1, 500`. ### Indirect Addressing Mode The operand is indirectly accessed through a memory location, which contains the actual address of the operand. * This mode is useful when the address of the operand may not be known at compile time. ### Stack Addressing Mode * The stack is a data structure where data is added from the top (push) and removed from the top (pop), following a last-in, first-out (LIFO) order. * **The stack is often used for storing function call returns, parameters, and local variables.** ### Auto-Increment and Auto-Decrement Addressing Modes * In these modes, the address of an operand is incremented or decremented before or after it is accessed. * They effectively modify the address register used in the current instruction. ### Instruction Types * Instructions are broadly categorized into the following types: * **3-Address Instructions:** Have three operands, often useful for arithmetic operations with multiple inputs. * **2-Address Instructions:** Have two operands, frequently used in memory-to-memory data movement. * **1-Address Instructions:** Have one operand, commonly using the accumulator as an implicit second operand. * **Zero-Address Instructions:** Perform operations implicitly on the accumulator or top of the stack, often found in stack-oriented architectures. ## Processor Registers * Registers are small, high-speed storage locations within the CPU, primarily used for storing temporary data and instructions. * Registers are often used for optimization because they are faster to access compared to RAM. **Common Processor Registers:** * **Accumulator (AC):** A register that holds the intermediate results of arithmetic and logical operations. * **Program Counter (PC):** Holds the address of the next instruction to be fetched. * **Instruction Register (IR):** Holds the current instruction being executed. * **General Purpose Registers (GPRs):** Registers that can be used for holding various data values, including intermediate results of calculations, loop counters, and function parameters. **Register Transfer Notation (RTN)** * RTN is a symbolic notation used to represent the transfer of data between registers, memory locations, and I/O devices. **Common RTN Operations:** * `R1 ← R2` : Transfers the content of register R2 to register R1. * `R1 ← M[LOC]` : Transfers the data from memory location LOC to register R1. * `M[LOC] ← R1` : Transfers the content of register R1 to memory location LOC. ## Understanding the Operation of the computer To understand the operation of a computer, think of it as a machine that can perform a set of basic operations, or instructions. The CPU fetches an instruction from memory, decodes it, and then executes the instruction. This cycle continues until the program completes. ## Implementation of Variables and Constants * A variable is a named memory location that holds a value that can be changed. * A constant is a value that does not change. * To implement variables and constants, you need to allocate memory space to hold their values. * You can access the values of variables and constants by using their addresses. The addressing mode determines what memory location or register will be used to access the value. ## Addressing Modes * Addressing modes tell the computer how to access data during execution, either in registers or memory. They can be used for various purposes, for example, to optimize program performance, manage data storage, and manipulate stack operations. ### Example: A Simple Arithmetic Problem Let’s look at a simple arithmetic problem and see how addressing modes would work in this scenario: ``` int x = 10; int y = 20; int sum; sum = x + y; ``` * The instructions "int x = 10", "int y = 20" are used to define variables and set their initial values, 10 and 20 respectively. These instructions often involve the use of immediate addressing where the values 10 and 20 are directly incorporated into the instruction itself. * The instruction "sum = x + y" calculates the sum of x and y and stores the result in the variable sum. This instruction typically uses both register addressing and memory addressing. The x and y variables might be loaded into registers (register addressing) before the addition operation, and the calculated result would then be stored in the sum memory location (memory addressing). To understand different addressing modes better, let’s break down how the calculation would proceed: Let's assume: * The program counter `PC` - the address of the next instruction in memory - is 202. * The location of `x` is at memory address 300. * The location of `y` is at memory address 400. Consider these addressing mode examples: **Direct Addressing Mode:** * `LOAD x, AC` (Load the value of x into the accumulator). * `ADD y, AC` (Add the value of y to the accumulator). * `STORE sum, AC` (Store the result in the sum memory location). In this example, instructions explicitly specify the memory addresses of `x` and `y`. **Indirect Addressing Mode:** * `LOAD R1, (300)` (Load the content of the memory location with address 300 into register R1). * `LOAD R2, (400)` (Load the content of the memory location with address 400 into register R2). * `ADD R1, R2` (Add the contents of register R1 and R2). * `STORE sum, AC` (Store the result in the sum memory location). Here, the registers R1 and R2 are used as pointers that store the addresses of `x` and `y`. The addition operation is then performed on the values pointed to by these registers. **Immediate Addressing Mode:** * `LOAD AC, #10` (Load the immediate value 10 into the accumulator). * `ADD AC, #20` (Add the immediate value 20 to the accumulator). * `STORE sum, AC` (Store the result in the sum memory location). This example illustrates the use of immediate values directly included in the instruction. **The choice of addressing mode is crucial for optimizing program performance and memory utilization.** ## Instruction Execution Sequencing Instruction execution sequencing is about the order in which instructions are executed by the computer. * **Sequential Execution:** Common practice where instructions are executed in the order they appear in the program, effectively fetching the instruction from memory, decoding it, and then executing it. * **Conditional Execution:** The control flow may deviate depending on a specified condition. For example, "if the value of x is greater than 10, then execute a specific instruction" or "jump to a different location in the code" if the condition is met. * **Looping:** A block of code can be executed multiple times based on a specific criteria. The computer might repeatedly evaluate a condition and continue executing the loop's instructions until the criteria is met. ## Branching Branching is a mechanism or instruction that modifies the normal sequential flow of control in a program. It allows the program to jump to a different instruction, skipping over other instructions in-between. It is a fundamental concept that allows for conditional execution, looping, and subroutine calls. - There are different types of branches: - **Unconditional Branch:** Always jumps to a specified address, irrespective of any conditions. - **Conditional Branch:** Jumps to a specified address only if a certain condition is true. The condition is typically evaluated by comparing the value within a register with a value or checking the status of a special flag (conditional code). - **Subroutine Call:** A special type of branch used to transfer control to a subroutine. - A **subroutine** is a block of code designed to perform a specific task that can be called from different parts of the program. Branching is essential for enabling efficient and structured program execution. ## Instruction Set Completeness * An instruction set refers to the set of instructions that a computer can execute. * A complete instruction set should be capable of: - **Data Processing:** Performing operations on data, such as adding, subtracting, multiplying, dividing, and comparing. - **Control Flow:** Controlling the order in which instructions are executed, often accomplished through branching and looping capabilities. - **Data Transfer:** Moving data between memory, registers, and input/output devices. ## Instruction Types * **Functional Instructions:** Operations that directly manipulate data values using arithmetic, logical, or shift operations. - Example: `ADD`, `SUB`, `AND`, `OR`, `SHIFT`. * **Transfer Instructions:** Operations that move data between registers, memory locations, and input/output devices. - Example: `MOVE`, `LOAD`, `STORE`. * **Control Instructions:** Operations that affect the flow of control within the program, such as branching and looping. - Example: `JUMP`, `BRANCH`, `LOOP`, `CALL`. * **Input/Output Instructions:** Operations that allow the computer to interact with external devices, such as reading data from a keyboard or writing data to a display. - Example: `IN`, `OUT`, `READ`, `WRITE`. ## Processor Register * A "processor register" within the CPU acts as a high-speed temporary storage area. The CPU directly accesses data in registers, enabling fast data manipulation. Registers are crucial for efficient program execution, especially because they are faster to read and write compared to main memory. **Common Processor Registers:** * **Accumulator (AC):** Frequently used for storing data values in arithmetic operations. * **Instruction Register (IR):** Holds the currently fetched instruction, allowing for decoding and execution. * **Program Counter (PC):** Tracks the address of the next instruction to be fetched from memory. * **General-Purpose Registers (GPRs):** Often represent a flexible set of registers used for various purposes, including storing variables, intermediate results, and function arguments. * **Special-Purpose Registers:** Registers with dedicated functions, such as holding status conditions or flags, managing memory addressing, or supporting specific CPU features. **Register Transfer Notation (RTN)** * RTN is a symbolic notation for describing data movement between registers, memory locations, I/O devices, and other CPU components. ## Instruction Cycle The instruction cycle forms the core operation of any computer, representing the steps involved in executing a single instruction. - The cycle consists of four main phases: 1. **Fetch:** Retrieve the instruction from memory based on the program counter's value. 2. **Decode:** Interpret the instruction, identifying the operation to perform and the operands involved. 3. **Calculate Effective Address:** If the instruction utilizes memory addressing (not direct register access), determine the actual memory location needed for accessing the operand. 4. **Execute:** Perform the specified operation using the decoded instruction and the identified operands. - The instruction cycle involves several registers: * Program Counter (PC): Tracks the address of the next instruction to be fetched. * Instruction Register (IR): Holds the current instruction being processed. * Memory Address Register (MAR): Holds the address of the location in memory to be accessed. * Memory Data Register (MDR): Holds the data being transferred from memory to the CPU or vice-versa. * Accumulator (AC): A general-purpose register that often stores intermediate results of arithmetic operations. **The instruction cycle is essential for the computer to execute instructions one by one and carry out a complete program. The efficiency of this repetitive cycle is fundamental to computing.** ## The Von Neumann Architecture * This architecture is crucial to modern computers. It defines how the CPU (the brain of the computer) accesses instructions and data. Key components include: * **Central Processing Unit (CPU):** Processes instructions and performs arithmetic and logical operations. * **Memory (RAM):** Stores both instructions and data, enabling the CPU to access them. * **Input/Output (I/O) Devices:** Facilitate communication between the computer and its external environment. ## Indirection & Pointer * Indirection involves using a memory location to store the address of another memory location. * This offers indirect access to data, which is valuable when: - The address of the data might not be known beforehand or could change. - The address is accessed frequently and using indirection optimizes program performance. * **Pointer** is a variable that stores the address of a data location. ## Indexing & Arrays * Indexing refers to accessing elements within an array or a data structure. * The fundamental concept is to use an index (typically a number) to identify a specific element in the array. The index maps to a specific memory location, allowing the CPU to access the desired element. ## Address Modes * **Implied:** Operand(s) are implicit within the instruction. For example, a `CMA` (Complement Accumulator) instruction doesn't need to explicitly provide a source address since the accumulator is implied as the operand. * **Immediate:** The operand is provided directly within the instruction as a constant value. No additional memory access is needed. * **Direct:** The instruction directly provides the operand's memory address. * **Register-Direct:** The instruction uses a register, and the register's value holds the operand's address. * **Register-Indirect:** The instruction uses a register, but the register's content is a pointer to the address of the operand. * **Displacement:** An offset value (displacement) is added to a base register's address to calculate the operand's address. Useful for accessing data in arrays, tables, or near specific base addresses. * **Relative:** An offset is added to the current instruction's address (Program Counter) to calculate the operand's address. This is useful for accessing neighboring data relative to the current instruction. * **Base:** This mode uses a base register and a displacement value to calculate the operand's address. Commonly associated with memory segmentation or multi-dimensional arrays. * **Indexed:** An offset value (index) is added to an index register's content, calculating the operand's address. Helpful for efficiently working with arrays and tables. * **Indirect:** The instruction provides a memory address that points to the operand's address. The CPU indirectly accesses the data by first fetching the operand's address, then using that address to fetch the actual operand. * **Auto-Increment:** The address register is automatically incremented after the operand is accessed. * **Auto-Decrement:** the address register is automatically decremented after the operand is accessed. **Understanding addressing modes is a key aspect of programming and computer architecture. It allows for efficient manipulation of data and optimization of memory access, leading to better program performance.** ## Instruction Execution Instruction execution is the process of the computer's central processing unit (CPU) carrying out a single instruction. - The steps involved in instruction execution: 1. **Fetch:** The CPU fetches the instruction from memory. The program counter (PC) holds the address of the next instruction to be fetched. The instruction is loaded into the Instruction Register (IR). 2. **Decode:** The CPU decodes the instruction, breaking it down into its components: the opcode (the operation to be performed) and the operands (the data involved in the operation). 3. **Calculate Effective Address:** If the instruction uses memory addressing (not direct register access), the CPU calculates the effective address. This may involve adding an offset value to a base register, or an index register to access a specific location. 4. **Execute:** The CPU executes the instruction based on the decoded opcode and operands. This involves performing operations like adding, subtracting, comparing, or moving data to or from memory. **The instruction execution cycle is fundamental to how a computer executes a program. This cycle continues repeatedly for each instruction in the program, allowing the computer to carry out its tasks.**