๐ Lecture 1 โ Introduction
๐ Overview: This lecture introduces the fundamental concepts of computer architecture, distinguishing it from computer organization and design. It establishes the definition of a general-purpose digital computer, explains the stored program concept and the fetch-execute cycle, and explores the different levels of abstraction in digital design. This foundational knowledge is essential for understanding how computers are designed and how they operate at various levels of detail.
๐๏ธ Topics Covered
This lecture covers the distinction between computer architecture, organization, and design; levels of abstraction in digital design from the PMS level down to the mask level; the definition and essential elements of a general-purpose digital computer; the stored program concept and the fetch-execute process; the concept of an Instruction Set Architecture (ISA); perspectives of different people about computers including users, programmers, computer architects, and logic designers; and tools and views relevant to each perspective.
๐ Lecture Summary
Introduction
This course is about Computer Architecture. The lecture begins by explaining key terms, starting with the definition of a computer for the purposes of this course.
The General Purpose Digital Computer
A computer is defined as "An electronic device, operating under the control of instructions stored in its own memory unit, that can accept data (input), process data arithmetically and logically, produce output from the processing, and store the results for future use." For this course, the term computer refers to a general-purpose digital computer that can perform a variety of arithmetic and logic tasks, as opposed to dedicated computers like those in automobiles.
The Computer as a System
A system is a collection of elements or components working together on one or more inputs to produce one or more desired outputs. Systems include chemical, optical, biological, electrical, and mechanical systems. Digital systems are a subset of electrical systems where inputs and outputs are digital quantities. General-purpose digital computers are a subset of digital systems, and this course focuses on them.
Essential Elements of a General Purpose Digital Computer
A modern general-purpose digital computer has three main components: a memory subsystem, an input/output subsystem, and a central processing unit (CPU) . Programs are stored in memory, instruction execution occurs in the CPU, and communication with the external world is achieved through the I/O subsystem.
Architecture
The word architecture means "the art or science of building" or "a method or style of building."
Computer Architecture
This term was first used in 1964 by Amdahl, Blaauw, and Brooks at IBM. They defined it as "The structure of a computer that a machine language programmer must understand to write a correct (time independent) program for that machine." By architecture, they meant the programmer-visible portion of the instruction set. The study of computer architecture includes:
- A study of the structure of a computer
- A study of the instruction set of a computer
- A study of the process of designing a computer
Computer Organization versus Computer Architecture
Architecture refers to the attributes of a computer that are visible to a programmer, including the instruction set, the number of bits used to represent various data types, I/O mechanisms, and memory addressing modes. Organization refers to the operational units of a computer and their interconnections that realize the architectural specifications, including control signals, interfaces between the computer and its peripherals, and the memory technology used. It is an architectural issue whether a computer will have a specific instruction, while it is an organizational issue how that instruction will be implemented.
Computer Architect
A computer architect is a person who designs computers.
Design
Design is defined as "The process of devising a system, component, or process to meet desired needs." In standard engineering usage, design is a processโa decision-making process (often iterative) in which basic sciences, mathematical concepts, and engineering sciences are applied to convert a given set of resources optimally to meet a stated objective.
Knowledge base of a computer architect
Computer design experts are familiar with the structure of a computer, the instruction set of a computer, and the process of designing a computer. It is not the job of a single person to design a computer from scratch; there are a number of levels of computer design, with domain experts carrying out the design activity for each level.
Digital Design: Levels of Abstraction
The design of a digital computer is viewed at several levels of abstraction:
Processor-Memory-Switch level (PMS level) This is the highest level, where an architect views the system. It is a description of the system components and their interconnections, specified in the form of a block diagram.
Instruction Set Level This level defines the function of each instruction, emphasizing the behavior of the system rather than the hardware structure.
Register Transfer Level Next to the ISA level, the hardware structure becomes visible. Basic elements at this level include registers, multiplexers, decoders, buses, and buffers. The above three levels relate to "system design."
Logic Design Level Also called the gate level, the basic elements are gates and flip-flops. Hardware structure predominates over behavior. This level relates to "logic design."
Circuit Level Key elements at this level are resistors, transistors, capacitors, and diodes.
Mask Level The lowest level, dealing with silicon structures and their layout that implement the system as an integrated circuit. The above two levels relate to "circuit design."
The focus of this course will be the register transfer level and the instruction set level, though it will also deal with the PMS level and the Logic Design Level.
Objectives of the course
This course will provide students with an understanding of the various levels of studying computer architecture, with emphasis on the instruction set level and register transfer level. Students will be able to use basic combinational and sequential building blocks to design larger structures like ALUs, memory subsystems, and I/O subsystems. It will help them understand the various approaches used to design CPUs of the RISC and CISC types, as well as the principles of cache memories.
Important topics to be covered
Topics include a review of computer organization, classification of computers and their instructions, machine characteristics and performance, design of a Simple RISC Computer (SRC), advanced topics in processor design, I/O subsystems, ALU implementation, and memory subsystems.
A brief review of Computer Organization Perceptions of Different People about Computers
There are various perspectives on a computer depending on the person viewing it. Generally, four views are considered for understanding the machine.
The Userโs View A user employs the computer to perform useful work through application software. At this level, one is only concerned with things like speed, storage capacity, and peripheral device behavior. The internal structure is made obscure by the operating system interface.
The Programmerโs View By "programmer," we imply machine or assembly language programmers responsible for implementing software.
Machine Language consists of all the primitive instructions a computer understands and can execute, expressed as strings of 1s and 0s. It is the computerโs native language and the lowest level language.
Instruction Set is a collection of all possible machine language commands a computer can understand and execute. Every processor has its own unique instruction set.
Assembly Language is a substitute symbolic representation using "English-like" key words called mnemonics. A pure assembly language has a one-to-one correspondence between machine instructions and statements in the assembly language, though there are exceptions.
๐ Definition โ Mnemonics: English-like keywords used in assembly language to represent machine instructions.
Users of Assembly Language include:
- The machine designer, who needs to understand trade-offs in instruction set design.
- The compiler writer, who must be familiar with the machine language to produce correct and optimized code.
- The writer of time or space critical code, as compilers may not always produce optimal code.
- Special purpose or embedded processor programmers, for whom higher-level languages may not be appropriate.
Useful tools for assembly language programmers include:
- The assembler: translates assembly language to machine language. A cross assembler runs on one processor and translates code for another processor.
- The linker: combines separate modules of functionality into a single module for loading and execution, enabling modularity.
- The debugger or monitor: a program used to aid in detecting runtime, syntax, or logical errors. It provides functionality like displaying/altering memory and registers, disassembly, single stepping, and breakpoints.
- The development system: a complete set of hardware and software tools including assemblers, linkers, loaders, debuggers, compilers, emulators, hardware-level debuggers, and logic analyzers.
Difference between Higher-Level Languages and Assembly Language: High-level languages are generally used to develop application software. There is a many-to-many mapping between HLL and assembly language constructs. HLLs provide primitive data types and type checking. At the machine level, there is generally no type checking; the machine only sees strings of bits, and instructions interpret these strings as types.
The Stored Program Concept This fundamental concept states that the program is stored with data in the computerโs memory, and the computer can manipulate it as data. The sequence of instructions to perform some useful task is called a program.
General Operation of a Stored Program Computer Machine language programs are brought into memory and executed instruction by instruction. The instruction to be executed is fetched from memory and temporarily stored in a CPU register called the instruction register (IR) . The program counter (PC) , also called the instruction pointer, holds the address of the next instruction to be executed.
When execution of an instruction is completed, the contents of the PC are placed on the address bus. The memory places the instruction on the data bus. The CPU puts this instruction into the IR to decode and execute. While this instruction is decoded, its length is determined and the PC is incremented by that length. In RISC machines, instruction length is fixed, so the PC is always incremented by a fixed number. For branch instructions, the PC contents are replaced by the address in the branch instruction. The current processor status is stored in a register called the Processor Status Word (PSW), also called the flag register. This entire process of reading memory, incrementing the PC, and decoding the instruction is known as the Fetch and Execute principle.
The Concept of Instruction Set Architecture (ISA) The programmerโs view is limited to the set of all assembly instructions a computer can understand, along with the resources these instructions help manage (memory space and programmer-accessible registers). This set of instructions and resources together form the instruction set architecture (ISA) . The ISA serves as an interface between the program and the functional units of a computer.
The Computer Architectโs View The computer architectโs view is concerned with designing the entire system and ensuring its optimum performance. The computer architect:
- Designs the ISA for optimum programming utility and performance
- Designs hardware for best implementation of instructions
- Uses performance measurement tools like benchmark programs
- Balances performance of building blocks (CPU, memory, I/O, interconnections)
- Strives to meet performance goals at the lowest possible cost
Useful tools include software models, simulators, emulators, performance benchmark programs, specialized measurement programs, data flow and bottleneck analysis, subsystem balance analysis, and cost analysis.
The Logic Designerโs View The logic designer is responsible for designing the machine at the logic gate level. This design process determines whether the computer architect meets cost and performance goals. The computer architect and logic designer must work collaboratively.
Useful Tools for the Logic Designer include CAD tools (logic design and simulation packages, PCB layout tools, IC design and layout tools), logic analyzers, oscilloscopes, and hardware development systems.
The Concept of the Implementation Domain The collection of hardware devices with which the logic designer works is termed the implementation domain. Logic gate implementation domains may include VLSI on silicon, TTL or ECL chips, Gallium arsenide chips, PLAs, or fluidic logic/optical switches. Interconnection domains may include poly-silicon lines in ICs, conductive traces on a PCB, electrical cable, or optical fiber.
Classical logic design versus computer logic design Traditional finite state machine design techniques are not suitable for designing a computer, even though a computer is a finite state machine, because the computer can assume hundreds of states.
Sequential Logic Circuit Design Traditional sequential circuit design involves creating a state diagram, eliminating redundant states, translating into a next state table, making state assignments, creating a transition table, completing excitation tables, determining excitation equations through minimization, and drawing the logic circuit.
Computer Logic Design Because there is a natural separation between the data path (storage cells, arithmetic/logic components, and interconnections) and the control path (circuitry managing data path information flow) in a digital computer, a modular approach can be used. Well-defined logic blocks such as multiplexers, decoders, and adders can be used repeatedly.
Two Views of the CPU Program Counter Register To a programmer, the program counter is just a register (e.g., 32 bits). To a logic designer, the program counter is implemented as an array of D flip-flops, with control signals like PCout (gating contents onto the address bus) and PCin (storing contents from the bus on the leading edge of the clock signal).
โญ Key Takeaways
The most critical concepts from this lecture are the clear distinction between computer architecture (programmer-visible attributes like instruction set) and computer organization (how those attributes are implemented with hardware). The stored program concept and the Fetch-Execute cycle (fetch instruction from memory, increment PC, decode, and execute) form the foundation of all general-purpose digital computers. The multiple levels of abstractionโfrom PMS level to mask levelโallow different experts to design different aspects of a computer. The ISA serves as the critical interface between software and hardware, defining what a programmer can access and control. Finally, understanding the different perspectives (user, programmer, computer architect, logic designer) is essential for grasping the full scope of computer system design.
๐ง Quick Revision Questions
- What is the difference between computer architecture and computer organization? Give two examples of each.
- Describe the Fetch-Execute cycle, including the roles of the Program Counter (PC), Instruction Register (IR), and Processor Status Word (PSW).
- What are the six levels of abstraction in digital design, and which levels are the primary focus of this course?
- What is the Stored Program Concept, and why is it fundamental to general-purpose digital computers?
- What is an Instruction Set Architecture (ISA), and what does it include from a programmer's perspective?
๐ Lecture 2 โ Instruction Set Architecture
๐ Overview: This lecture explores the fundamental aspects of computer architecture by classifying instruction set architectures based on CPU operand storage mechanisms. It provides a comprehensive analysis of instruction formats, addressing modes, and the contrasting philosophies of RISC and CISC architectures, essential for understanding how processors execute programs.
๐๏ธ Topics Covered
The lecture begins with a taxonomy of computers and their instructions, covering accumulator, stack, and general-purpose register machines. It then examines instruction set features including essential elements of instructions, classifications by address count (4-address to 0-address), and comparisons based on code size and memory accesses. Addressing modes are thoroughly explained, followed by a detailed comparison of RISC and CISC architectures with their respective advantages and disadvantages.
๐ Lecture Summary
CLASSES OF INSTRUCTION SET ARCHITECTURE:
Processors can be classified based on how the CPU stores instructions and data. There are three primary types: Accumulator based machines, Stack based machines, and General purpose register (GPR) machines.
ACCUMULATOR BASED MACHINES use special registers called accumulators to hold one source operand and the result of arithmetic or logic operations. Since the accumulator holds one operand, another register may hold the address of the second operand. Accumulator machines are also called 1-address machines. They employ a very small number of accumulator registers, generally only one. These were useful when memory was expensive, but their use is now severely limited for complex expressions.
๐ Definition โ Accumulator: A special register that collects (accumulates) data, holding one source operand and the result of an operation. ๐ Concept: Accumulator machines are 1-address machines because only the memory operand address needs to be specified; the accumulator is implicit. ๐ก Why this matters: Understanding accumulator-based design explains why early computers had limited computation capabilities and why modern processors use multiple registers.
STACK BASED MACHINES organize registers as a last-in-first-out (LIFO) structure. Operands stored first (via push) can only be accessed last (via pop). Arithmetic operations pick operands from the top-of-the-stack (TOS) and push results back. Since operand addresses need not be specified, these are called 0-address machines.
๐ Definition โ Stack: A group of registers organized as a LIFO structure where operands are accessed in reverse order of storage. ๐ Example: In a self-service cafeteria, plates are stacked; the last plate placed on top is the first one taken (pop).
GENERAL-PURPOSE-REGISTER MACHINES have multiple registers within the CPU without dedicated functions. A small number of bits identify registers (e.g., 6 bits for 64 registers). CPU registers are faster than cache memory and more effectively used by compilers. Registers can hold variables, addresses, and pointers, reducing memory traffic.
๐ Definition โ General Purpose Registers: CPU registers without dedicated functions that can be used for data, addresses, or pointers. ๐ก Why this matters: Modern processors use general-purpose registers because they significantly increase execution speed and reduce code size compared to memory-based operations.
INSTRUCTION SET
An instruction set is a collection of all possible machine language commands that a processor can understand and execute.
ESSENTIAL ELEMENTS OF COMPUTER INSTRUCTIONS:
There are four essential elements: the type of operation, the place to find source operands, the place to store results, and the source of the next instruction.
๐ Definition โ Op-code (Operation Code): The bit-pattern field in a machine language instruction that encodes the type of operation to be performed.
๐ Example: add cx, dx โ the op-code for add is 0000; contents of dx are added to cx, result stored in cx.
Source operands can be located in CPU registers, memory cells, I/O locations, or be part of the instruction itself (immediate operands). The result can be stored in CPU registers, memory cells, or I/O locations. The next instruction is implicitly the next-in-sequence unless a branch occurs (conditional/unconditional, subroutine call, or interrupt service routine).
CLASSIFICATIONS OF INSTRUCTIONS:
Instructions are classified based on the number of addresses specified: 4-address, 3-address, 2-address, 1-address, and 0-address instructions.
4-address instructions specify addresses of two source operands, one destination operand, and the next instruction address. They are not common because the next instruction is usually sequential; used in micro-coded control units.
3-address instructions specify addresses of two source operands and one destination operand.
2-address instructions have three fields: op-code, one field for both source and destination operand, and another field for the second source operand. One field serves two purposes.
1-address instructions use an implicit accumulator register, requiring only one field for a source/destination operand address.
0-address instructions use a stack implicitly; only the op-code field is needed.
COMPARISON OF INSTRUCTION FORMATS:
Basis for comparison includes code size (affects storage requirements) and number of memory accesses (affects execution time).
Assumptions: 1 byte for op-code (256 instructions), 16 Mbyte memory address space, byte-addressable memory, 24-bit operand size, 24-bit address bus, 8-bit data bus.
| Format | Code Size | Memory Accesses |
|---|---|---|
| 4-address | 13 bytes (1+3+3+3+3) | 22 bytes |
| 3-address | 10 bytes (1+3+3+3) | 19 bytes |
| 2-address | 7 bytes (1+3+3) | 16 bytes |
| 1-address | 4 bytes (1+3) | 7 bytes |
| 0-address | 1 byte | 10 bytes |
HALF ADDRESSES
Half addresses refer to CPU register addresses, which require fewer bits than memory addresses. An instruction specifying one memory address and one CPU register is called a 1ยฝ-address instruction.
๐ Example: mov al, [34h]
THE PRACTICAL SITUATION
Real machines mix 3, 2, 1, 0, and 1ยฝ-address instructions. For example, the VAX 11 includes instructions from all classes.
CLASSIFICATION OF MACHINES ON THE BASIS OF OPERAND AND RESULT LOCATION:
Machines are classified based on whether ALU instructions use data from memory. Load-store machines (also called register-to-register machines) use only CPU registers for operands and results. Other machines may have register-memory or memory-memory instructions.
Load-Store Machines: Only load and store instructions access memory. Load fetches data into CPU registers; other instructions use these registers; store writes results back. Most RISC computers use this type.
Advantages: Instructions are simple and fixed in length, code generation is simple, all instructions take similar clock cycles.
Disadvantages: Higher instruction count (separate load/store instructions needed), fixed instruction size wastes bits for instructions not needing all fields.
Register-Memory Machines: Some operands in memory, some in registers. Typically use 1 or 1ยฝ address format.
Advantages: No need to load memory operands first; easier encoding; better instruction bit usage.
Disadvantages: Operands not equivalent (one may have two functions); different size encoding may restrict register count; variable clock cycles per instruction.
Memory-Memory Machines: All three operands (2 source, 1 destination) in memory. Use 2-address or 3-address formats.
Advantages: Most compact instruction encoding; no CPU registers wasted.
Disadvantages: Variable instruction size makes decoding complex; varying cycles per instruction; slow memory accesses degrade performance.
๐ Example 1: Evaluate a = (b+c)*d โ e with different address machines.
๐ Example 2: Evaluate z = 4(a+b) โ 16(c+58) with different address machines.
FUNCTIONAL CLASSIFICATION OF INSTRUCTION SETS:
Instructions are classified into four categories: Data processing (ALU operations), Data storage (main memory access), Data movement (I/O), and Program flow control (branches, conditional/unconditional).
ADDRESSING MODES:
Addressing modes are the different ways the CPU generates the address of operands. The effective address is the binary bit pattern issued by the CPU to the memory.
Immediate Addressing Mode: Data is part of the instruction; no address calculation needed. Used only for source operands. Range for n-bit field: -2^(n-1) to +(2^(n-1)-1).
๐ Example: lda 123 โ immediate operand 123 loaded into accumulator.
Direct Addressing Mode: The address of the operand is specified as a constant in the instruction. Address space limited by operand field size (2^operand field size locations).
๐ Example: lda [123] โ operand fetched from memory address 123.
Indirect Addressing Mode: The instruction contains the address of a memory location that holds the address of the operand. Two memory accesses required. Useful for implementing pointers.
๐ Example: lda [[123]] โ first access gets address from memory at 123, second access gets operand.
Register (Direct) Addressing Mode: Operand is in a CPU register; register address encoded in instruction. No memory access needed. Limited by number of CPU registers.
๐ Example: lda R2 โ operand fetched from register R2.
Register Indirect Addressing Mode: A CPU register contains the address of the memory location holding the operand. Large address space (2^register size locations). Fewer memory accesses than indirect.
๐ Example: lda [R1] โ register R1 holds memory address of operand.
Displacement Addressing Mode (also called based or indexed addressing): Effective address = constant (part of instruction) + value in CPU register. Useful for accessing arrays. Called indexed when constant is base and register holds index; based when constant is offset and register holds base address.
๐ Example: lda [R1 + 8] โ R1 holds base address, 8 is added, operand fetched from effective address.
Relative Addressing Mode: Similar to indexed, but Program Counter (PC) holds the base address. Useful for 'short' jumps.
๐ Example: jump 4 โ constant 4 added to PC to form target address.
RISC AND CISC ARCHITECTURES:
RISC (Reduced Instruction Set Computers) is a design philosophy focusing on reducing the number and complexity of instructions, though modern RISC machines may have complex instructions.
Common features of RISC machines:
- One instruction per clock period โ achievable through pipelining
- Fixed size instructions โ typically 32 bits
- CPU accesses memory only for Load and Store operations โ all operands in CPU registers
- Simple and few addressing modes โ reduces complex decoding
- Less work per instruction โ allows reduced clock period T
- Improved usage of delay slots โ executing next instruction while waiting for load/store/branch
- Efficient usage of Pre-fetching and Speculative Execution Techniques
๐ Definition โ Delay slot: The waiting time for a load/store to access memory or a branch to access the target instruction. ๐ Definition โ Speculative execution: Issuing instructions before knowing whether a branch will be taken, discarding results if speculation is wrong.
CISC (Complex Instruction Set Computers) has no underlying philosophy; it resulted from efforts to efficiently utilize memory and minimize execution time by adding more instruction formats and addressing modes.
Common attributes of CISC machines:
- More work per instruction โ compact programs with more functionality
- Wide variety of addressing modes โ e.g., 14 in MC68000, 25 in MC68020
- Variable instruction lengths and execution times per instruction
- Attempt to reduce the "semantic gap" โ the gap between machine-level instructions and high-level language constructs
Disadvantages of CISC:
- Clock period T cannot be reduced beyond a certain limit due to complex circuits
- Complex addressing modes delay operand fetch from memory
- Difficult to make efficient use of speedup techniques like pipelining, pre-fetching, superscalar operation, and speculative execution
โญ Key Takeaways
The most critical concepts from this lecture are: (1) Instruction set architectures are fundamentally classified by how the CPU stores operandsโaccumulator, stack, or general-purpose registers, each with distinct address formats (1-address, 0-address, and multiple-address). (2) The number of addresses in an instruction directly impacts code size and memory accesses, with 0-address instructions being most compact but requiring more memory accesses, while 1-address instructions balance efficiency. (3) Addressing modes determine how effective addresses are computed, with immediate, direct, indirect, register, indexed, and relative modes each offering different trade-offs between flexibility, address space, and memory access overhead. (4) RISC and CISC represent opposing design philosophiesโRISC emphasizes simplicity, fixed instruction size, and register-to-register operations to enable pipelining and speculative execution, while CISC prioritizes instruction density and complex addressing to reduce the semantic gap between machine code and high-level languages. (5) The practical reality is that most modern processors incorporate features from multiple classifications, making it essential to understand the underlying trade-offs for performance analysis and compiler optimization.
๐ง Quick Revision Questions
-
What are the three main classes of instruction set architecture based on how the CPU stores instructions and data, and what address format does each use?
-
Compare the code size and number of memory accesses for 4-address, 2-address, 1-address, and 0-address instructions under the given assumptions (1-byte op-code, 3-byte addresses).
-
List and explain five commonly used addressing modes, providing an example for each and stating how many memory accesses are required.
-
What are the key differences between RISC and CISC architectures regarding instruction size, addressing modes, memory access patterns, and clock cycle characteristics?
-
Explain the concept of "delay slots" in RISC architecture and how "speculative execution" improves processor performance.
๐ Lecture 3 โ Introduction to SRC Processor
๐ Overview: This lecture introduces performance measurement techniques for computer systems and presents the SRC (Simple RISC Computer) as an example processor to understand architectural concepts. It covers benchmark programs, performance metrics like MIPS and MFLOPS, and details the SRCโs notation, features, and instruction formats.
๐๏ธ Topics Covered
The lecture begins by discussing measures of performance including execution time, MIPS, MFLOPS, Whetstones, Dhrystones, and SPEC benchmarks. It then introduces the SRC processor with its register set, memory organization, and notation. The lecture concludes with a detailed examination of the four SRC instruction formats: Type A (no operation and stop), Type B (relative addressing load/store), Type C (direct/indexed load/store and ALU instructions), and shift instructions.
๐ Lecture Summary
Measures of performance: Performance testing
To test or compare machine performance, programs are run and their execution times measured. However, execution speed depends on the particular program. Standard programs called โbenchmark programsโ approximate real workloads. Actual execution time is measured by running these programs on the machines.
Commonly used measures of performance
The basic measure of performance is time. Common measures include Execution time, MIPS, MFLOPS, Whetstones, Dhrystones, and SPEC.
Execution time
Execution time is the time a processor takes to execute a given program. It depends on factors like I/O waits, instruction fetch times, and pipeline delays.
๐ Formula: Execution Time = IC ร CPI ร T Where:
- IC = instruction count
- CPI = average number of system clock periods to execute an instruction
- T = clock period
๐ก Why this matters: This formula helps quantify processor performance, but using average CPI is a simplification.
MIPS (Millions of Instructions per Second)
MIPS measures millions of instructions executed per second.
๐ Formula: MIPS = IC / (ET ร 10โถ)
๐ก Why this matters: MIPS is not accurate for comparing different processors because architectural differences mean some machines require more instructions to perform the same job. For example, RISC machines have simpler instructions, so the same job requires more instructions.
MFLOPS (Millions of Floating Point Instructions per Second)
For computation-intensive applications, MFLOPS measures floating-point instruction execution. It has two advantages over MIPS:
- Floating point operations are complex, providing a better picture of hardware capabilities.
- Overheads (operand fetch, result storage) are effectively lumped with the floating point operations they support.
Whetstones
Whetstone was the first benchmark program, developed using statistics from the Whetstone Algol compiler. It tests floating point instructions. Performance is stated in MWIPS (millions of Whetstone instructions per second).
Dhrystones
Developed in 1984, Dhrystone is a small benchmark (about 100 high-level-language statements) that measures integer instruction performance, contrasting with Whetstoneโs floating point focus.
Disadvantages of using Whetstones and Dhrystones
Both are now considered obsolete because:
- Small, fit in cache
- Obsolete instruction mix
- Prone to compiler tricks
- Difficult to reproduce results
- Uncontrolled source code
๐ก Why this matters: Being small programs, they encourage โover-optimizationโ, and optimizing compilers can distort results.
SPEC
SPEC (System Performance Evaluation Cooperative) is an association defining standard benchmarks for fair processor evaluation. The suite includes:
- A compiler
- A Boolean minimization program
- A spreadsheet program
- Other programs stressing arithmetic processing speed
- Latest version: SPEC CPU2000
Advantages:
- Ease of publication
- Each benchmark carries the same weight
- SPEC ratio is dimensionless
- Not unduly influenced by long running programs
- Relatively immune to performance variation on individual benchmarks
- Provides a consistent and fair metric
An example computer: the SRC: โsimple RISC computerโ
The SRC (Simple RISC Computer) is introduced to facilitate understanding of design steps and concepts. It is simple yet complex enough to illustrate fundamentals.
SRC Introduction
Attributes of the SRC:
- 32 General Purpose Registers: R0, R1, ..., R31; each is 32 bits
- Two special purpose registers: Program Counter (PC) and Instruction Register (IR)
- Memory word size: 32 bits
- Memory space size: 2ยณยฒ bytes
- Memory organization: 2ยณยฒ ร 8 bits (byte aligned)
- Memory accessed in 32-bit words (4 byte chunks)
- Big-endian byte storage used
Programmerโs View of the SRC: The figure shows 32, 32-bit CPU registers, two additional CPU registers (PC & IR), and main memory as 2ยณยฒ 1-byte cells.
SRC Notation
Notation examples:
- R[3] means contents of register 3
- M[8] means contents of memory location 8
- A memory word at address 8 is the 32 bits at addresses 8,9,10,11
- Notation for 32-bit memory words: M[8]<31...0> := M[8] M[9] M[10] M[11] (concatenation)
Some more SRC Attributes
- All instructions are 32 bits long (1 word)
- All ALU instructions have three operands
- Memory is accessed only through load and store operations
- Only a few addressing modes are supported
SRC: Instruction Formats
Four types of instructions are supported: Type A, Type B, Type C, and shift instructions.
Encoding of the General Purpose Registers
A simple 5-bit encoding is used for fields ra, rb, and rc, representing any of the 32 registers. An exception is rb = 0, which means no operand.
Type A
Type A is used for only two instructions:
- nop (no operation), op-code = 0 โ useful in pipelining
- stop (stop operation), op-code = 31 Both are 0-operand instructions.
Type B
Type B format includes three instructions using relative addressing mode:
- ldr (load register from memory using relative address), op-code = 2
๐ Example:
ldr R3, 56โ loads R3 with contents of memory location M[PC+56] - lar (load register with relative address), op-code = 6
๐ Example:
lar R3, 56โ loads R3 with the relative address itself (PC+56) - str (store register to memory using relative address), op-code = 4
๐ Example:
str R8, 34โ stores R8 contents to M[PC+34]
The effective address is computed at run-time by adding a constant to the PC, making instructions โre-locatableโ.
Type C
Type C format has three load/store instructions and three ALU instructions.
Load/Store instructions:
- ld (load register from memory), op-code = 1
๐ Example 1 (direct addressing):
ld R3, 56โ loads R3 with M[56], rb field = 0 ๐ Example 2 (indexed addressing):ld R3, 56(R5)โ loads R3 with M[56+R[5]], rb โ 0 - la (load register with immediate data/address), op-code = 5
๐ Example 1 (immediate addressing):
la R3, 56โ loads R3 with immediate value 56 ๐ Example 2 (indexed addressing):la R3, 56(R5)โ loads R3 with 56+R[5] - st (store register contents to memory), op-code = 3
๐ Example 1 (direct):
st R8, 34โ stores R8 contents to M[34] ๐ Example 2 (indexed):st R8, 34(R6)โ stores R8 contents to M[34+R[6]]
ALU instructions:
- addi (immediate 2โs complement addition), op-code = 13
๐ Example:
addi R3, R4, 56โ R[3] โ R[4] + 56 (rb field = R4) - andi (immediate logical AND), op-code = 42
๐ Example:
andi R3, R4, 56โ R3 loaded with logical AND of R4 and 56 - ori (immediate logical OR), op-code = 23
๐ Example:
ori R3, R4, 56โ R3 loaded with logical OR of R4 and 56
Note about c2 field (17 bits):
- For direct addressing, only first 2ยนโถ bytes (or last 2ยนโถ if c2 is negative) can be accessed
- For
lainstruction, only constants with magnitudes less than ยฑ2ยนโถ can be loaded - During address calculation, sign extension to 32 bits must be performed before addition
Shift Instructions
Type C instructions, with modifications, may also be used for shift instructions. The four shift instructions are:
- shr (shift right), op-code = 26
๐ Example:
shr R3, R4, 7โ shift R4 right 7 times into R3 (immediate) - shra (arithmetic shift right), op-code = 27
๐ Example:
shra R3, R4, 7โ shift R4 right 7 times into R3 (immediate) - shl (shift left), op-code = 28
๐ Example:
shl R8, R5, 6โ shift R5 left 6 times into R8 (immediate) - shc (shift left circular), op-code = 29
๐ Example:
shc R3, R4, 3โ shift R4 circular 3 times into R3 (immediate)
โญ Key Takeaways
Execution time is the fundamental performance measure, calculated as IC ร CPI ร T. Benchmark programs like Whetstones (floating point) and Dhrystones (integer) are now considered obsolete due to size and optimization issues. SPEC provides a fair, standardized benchmark suite. The SRC processor has 32 general-purpose registers and uses big-endian byte storage with 32-bit instructions. There are four instruction formats: Type A (nop/stop), Type B (relative addressing with ldr, lar, str), Type C (direct/indexed load/store and ALU operations like addi, andi, ori), and shift instructions (shr, shra, shl, shc). The c2 field in Type C is 17 bits, requiring sign extension to 32 bits for address calculation.
๐ง Quick Revision Questions
- What is the formula for Execution Time, and what do IC, CPI, and T represent?
- Why are MIPS and MFLOPS considered problematic for comparing different processor architectures?
- List three disadvantages of using Whetstones and Dhrystones as benchmark programs.
- How does the SRC handle memory addressing in Type B instructions (ldr/lar/str), and what does "re-locatable" mean?
- What is the difference between direct and indexed addressing modes in the SRCโs Type C load instruction (ld)? Provide an example of each.