Comprehensive Study Notes on Computer Organization and Architecture
Introduction to Computer Organization and Architecture
- Computer Organization and Architecture Focus: The primary objective is to study the components of a digital computer to reduce program execution time and improve the performance of individual parts.
- Computer Architecture vs. Computer Organization:
- Computer Architecture: Refers to the structure and behavior of a computer from the programmer's perspective. It includes attributes that directly impact the logical execution of a program, such as the instruction set, information formats, number of bits for data types (numbers, characters), input/output mechanisms, and techniques for memory addressing.
- Computer Organization: Refers to the operational units and their interconnections that realize the specified architectural requirements. While an architecture may remain the same for many years, its organization can change as technology evolves.
- The IBM System/370 Example: This architecture demonstrates how a manufacturer can offer a family of computer models sharing the same architecture but having different internal organizations.
- Microcomputers: In microcomputers, the distinction between architecture and organization is very close. Technological changes often result in more powerful architectures, such as the Reduced Instruction Set Computer (RISC).
Classes of Computers Based on Size
- Supercomputers:
- Definition: These are the most powerful computers designed for extremely complex calculations and large-scale data processing.
- Characteristics: High-performance processors and memory; capable of performing billions or trillions of calculations per second; expensive; require controlled cooling environments.
- Applications: Scientific simulations, weather prediction, and modeling natural phenomena.
- Examples: IBM Blue Gene, Cray XT5.
- Mainframe Computers:
- Definition: Large-scale computers built for efficient processing of massive data volumes.
- Characteristics: Supports thousands of users simultaneously; known for reliability, scalability, and security; designed for continuous uptime.
- Applications: Transaction processing for banks, insurance companies, and government agencies.
- Examples: IBM Z Series, Unisys ClearPath.
- Minicomputers (Mid-range Computers):
- Definition: Smaller and less powerful than mainframes, yet capable of supporting multiple users.
- Characteristics: Capable of multitasking; supports hundreds of users simultaneously.
- Applications: Manufacturing control systems, research laboratories, and medium-sized organizations.
- Examples: DEC VAX, Digital Equipment Corporation (DEC).
- Microcomputers (Personal Computers):
- Definition: Computers designed for individual use, built around a single-chip microprocessor.
- Characteristics: Compact, cost-effective, and easy to use; designed for general-purpose tasks.
- Examples: Desktop PCs, laptops, tablets, smartphones.
- Embedded Computers:
- Definition: Specialized computers built into other devices to perform specific functions.
- Characteristics: Minimal user interaction; low power consumption; limited resources; often perform real-time processing.
- Examples: Smart TVs, washing machines, car control systems, microwave ovens.
- Functionality-Based Classification:
- Analog Computers: Handle continuous data representing physical quantities like voltage, current, or mechanical motion (e.g., speedometers, thermometers, radar systems).
- Digital Computers: Process data in discrete binary form (0s and 1s). They are versatile and used in PCs, servers, and smartphones.
- Hybrid Computers: Combine the real-time processing of analog systems with the precision of digital systems (e.g., hospital patient monitoring systems, industrial control systems).
- Purpose-Based Classification:
- General-Purpose Computers: Flexible systems capable of running various software for personal or business use, such as laptops and workstations.
- Special-Purpose Computers: Engineered for specific, limited tasks and are not typically reprogrammed, such as gaming consoles, calculators, traffic signal controllers, and ATM machines.
- Performance-Based Classification:
- Workstations: Powerful computers for professional, technical, or scientific applications requiring high-performance multi-core processors, large RAM, and advanced GPUs (e.g., CAD workstations, video editing systems).
- Servers: Optimized for reliability and continuous operation to provide resources to clients over a network. Features include high processing power, large storage capacity with redundancy (RAID), and scalability (e.g., web servers like Apache/Nginx, database servers like MySQL).
Functional Units of a Digital Computer
- Definition: A digital computer is a fast electronic calculating machine that accepts digitized input, processes it based on internally stored program instructions, and produces output.
- The Five Basic Functional Units:
- Input Unit: Accepts coded information from human operators or electromechanical devices (keyboards, scanners, mice, magnetic disks) and converts it into electronic signals for the CPU.
- Memory Unit: Responsible for storing programs and data.
- Primary Storage: High-speed semiconductor cells. Any location can be reached in a fixed amount of time (RAM), ranging from a few nanoseconds (ns) to approximately 100ns.
- Cache Memory: Small, fast RAM units integrated with the processor to improve performance.
- Main Memory: The largest but slowest portion of primary memory.
- Secondary Storage: Cheaper, non-volatile storage for large volumes of data accessed infrequently (e.g., magnetic disks, tapes, optical disks like CD-ROMs).
- Arithmetic and Logic Unit (ALU): Performs operations such as addition, subtraction, multiplication, division, and logical comparisons. Operands are brought from memory into high-speed registers within the processor for the ALU to operate on them.
- Control Unit: The "nerve center" that sequences the computer's operations. It interprets instructions and generates timing signals (timing and synchronization) to direct data transfers and the actions of other units.
- Output Unit: Records results and presents them to the outside world via video monitors, printers, speakers, or magnetic tape devices.
Hardware and Software Interface
- Hardware Components: The CPU (executive), memory (storage), I/O devices (communication), and the motherboard/buses (interconnects).
- Software Types:
- System Software: Operating systems, drivers, and compilers.
- Application Software: User programs such as browsers and word processors.
- Instruction Set Architecture (ISA): The abstract model serving as the boundary where software communicates with hardware. It includes the instruction set, registers, data types, addressing modes, and memory organization. Examples include x86, ARM, and RISC−V.
Operation and Operands of MIPS Hardware
- Operations: MIPS assembly notation uses rigid formats like
add a, b, c where the sum of b and c is placed in a. Arithmetic instructions require exactly three variables. - Design Principle 1: Simplicity favors regularity. Regularity in instruction format (always three operands) keeps hardware simple.
- Operands: Operands are stored in a limited number of 32-bit registers, known as a "word."
- Design Principle 2: Smaller is faster. MIPS is limited to 32 general-purpose registers because a larger number would increase signal travel distance and clock cycle time.
- MIPS Registers Mapping:
- r0 (zero): Always 0.
- r1 (at): Reserved for the assembler.
- r2−r3 (v0−v1): Result values.
- r4−r7 (a0−a3): Arguments.
- r8−r15 (t0−t7): Temporaries (not saved).
- r16−r23 (s0−s7): Saved temporaries.
- r24−r25 (t8−t9): More temporaries.
- r28 (gp), r29 (sp), r30 (fp), r31 (ra).
- Memory Operands: Since registers are limited, complex structures like arrays are kept in memory.
- Spilling Register: Placing less frequently used data into memory (the stack) is called spilling registers.
- Data Transfer Instructions:
lw (load word) copies data from memory to register; sw (store word) copies data from register to memory.
Memory Addressing and Alignment
- Byte Addressing: Memory is viewed as a single-dimension array of 8-bit bytes. However, a word in MIPS is 32 bits (4 bytes).
- Alignment Restriction: Word addresses must start at multiples of 4. For example, to access array element
A[8], the offset is calculated as 8×4=32. - Endianness:
- Big Endian: The high-order byte (the "big end") is stored at the lowest memory address. MIPS, IBM 360/370, and Motorola 68K use Big Endian.
- Little Endian: The low-order byte is stored at the lowest address. Intel 80x86 and DEC VAX use Little Endian.
- Design Principle 3: Make the common case fast. MIPS includes "Immediate" operands where constants are part of the instruction (e.g.,
addi $s3, $s2, 25), avoiding extra memory loads.
RISC vs. CISC Architectures
- Reduced Instruction Set Computer (RISC):
- Characteristics: Small, highly-optimized set of simple instructions; large number of registers; fixed-length instruction format; single-cycle execution; hardwired control.
- Pipelining: Instructions are split into stages (fetch, decode, execute) that run in parallel.
- Advantages: Faster processing times; lower power consumption (ideal for mobile).
- Disadvantages: Programs require more instructions; higher memory usage.
- Complex Instruction Set Computer (CISC):
- Characteristics: Complex instructions that can perform multiple operations (e.g., load and add) in one step; variable-length instructions; many addressing modes; microprogrammed control.
- Advantages: Reduced code size (compact); better memory efficiency.
- Disadvantages: Slower execution per instruction; complex hardware design; high power consumption.
Addressing Modes
- Immediate: Operand is part of the instruction: Operand=Value.
- Direct (Absolute): Effective Address (EA) is given directly in the instruction: EA=LOC.
- Indirect: Effective Address is the contents of a memory location or register specified in the instruction: EA=[LOC] or EA=[Ri].
- Register Addressing: Operand resides in a register: EA=Ri.
- Register Indirect: Effective Address is the contents of a register: EA=[Ri].
- Index Addressing: EA is generated by adding a constant offset to a register: EA=X+[Ri].
- Relative Addressing: Often used for branches; EA is calculated relative to the Program Counter: EA=[PC]+X.
- Auto-increment/Decrement: The register is incremented/decremented automatically after/before accessing the operand.
Programming and Translation
- Assembly Language: A low-level, machine-dependent language using mnemonics (MOV, ADD, SUB). It requires an Assembler to translate it into machine code (object code).
- High-Level Language (HLL) Translation:
- Compiler: Translates the entire source code at once into an executable file (e.g., C, C++). Faster execution but slower initial translation.
- Interpreter: Translates and executes code line by line (e.g., Python). Easier debugging but slower execution.
- Compilation Phases: Lexical Analysis, Syntax Analysis, Semantic Analysis, Optimization, Code Generation, Linking and Loading.
- MIPS (Millions of Instructions Per Second):MIPS=Execution Time×106Instruction Count
- MFLOPS (Millions of Floating-point Operations Per Second): Specifically measures floating-point computation rates.
- CPI (Cycles Per Instruction): Average clock cycles per instruction.
CPI=Instruction CountTotal Clock Cycles
- CPU Time Formula:CPUTime=Instruction Count×CPI×Clock Cycle Time
- Throughput: The amount of work (tasks/transactions) completed per unit of time.
Throughput=Total Time TakenTotal Work Done
- Benchmarks: Standard test programs like SPEC (Standard Performance Evaluation Corporation) suites (SPECint for integers, SPECfp for floating-point) used to compare architectures.
Transition from Uniprocessor to Multiprocessors
- The Power Wall: Around the early 2000s, designers hit a limit where increasing the clock speed of a single processor generated excessive heat, making further single-core scaling impractical.
- The Shift: Performance focus moved from reducing response time of one program to increasing system throughput via parallel processing.
- Multiprocessor Systems: Systems with two or more CPUs that share memory and cooperate.
- Multicore: Multiple cores on a single chip.
- Challenges: Synchronization, Cache Coherence (ensuring all CPUs see consistent values), and software complexity in writing parallel code.