0% found this document useful (0 votes)
3 views20 pages

5 Computer Architecture and Organization

The document covers the fundamentals of computer architecture, focusing on the differences between Von Neumann and Harvard architectures, and the performance of processors. It explains concepts such as locality of reference, execution time, and the importance of cache memory in optimizing performance. Additionally, it discusses metrics for measuring CPU time and the impact of various optimizations on processor performance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views20 pages

5 Computer Architecture and Organization

The document covers the fundamentals of computer architecture, focusing on the differences between Von Neumann and Harvard architectures, and the performance of processors. It explains concepts such as locality of reference, execution time, and the importance of cache memory in optimizing performance. Additionally, it discusses metrics for measuring CPU time and the impact of various optimizations on processor performance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Computer Architecture and Organization

(CSE2003)

05/03/2025 1
Contents
2

UNIT I: Introduction to Computer Architecture


 Organization of the von Neumann machine and Harvard architecture
 Performance of processor

05/03/2025 2
Session Objectives
3

After this session students will be able to:


 Understand the difference between Organization of the Von Neumann machine and Harvard
architecture.
 Define the Performance of Processor.

05/03/2025 3
4 Understanding the Instruction Execution

 Pictorial representation of these set of instructions


LOAD A1 TO R1
LOAD A2 TO R2
R3 = R1 + R2
STORE R3 TO A3

05/03/2025 4
5

1. It is a type of memory located inside the CPU. Can hold single piece of data and that Data is
useful for both control functions and data processing itself.
2. Registers name of CPU.
3. The operations on the data in registers are called……….
4. The basic operations like add, subtract are implemented in computer using ……….

05/03/2025 5
Answers: 3. The operations on the data in registers are
5 Register
1. called register operations or register-
based operations.
2. Registers name of CPU.
 4. The basic operations like add, subtract are
Program Counter (PC)
 Accumulator (AC) implemented in computer using
 General Purpose Registers (GPRs) Arithmetic and Logic Unit (ALU).
 Data Register (DR)
 Instruction Register (IR)
 Status Register / Flag Register
 Stack Pointer (SP)
 Control Registers
 Index Registers
 Memory Address Register (MAR)
 Memory Buffer Register (MBR)
 Memory Data Register (MDR)
 Instruction Pointer (IP)
 Interrupt Register
 Debug Registers

05/03/2025 6
Locality of reference.
6
Locality of reference refers to the tendency of a program to access a relatively small portion of its
address space at any given time. It is a fundamental concept in computer architecture, specifically
in memory management and optimization, because it helps improve the performance of systems,
particularly in terms of cache utilization and virtual memory.

There are two main types of locality of reference:

1. Temporal Locality

Definition: If a particular memory location (or data) was accessed recently, it is likely to be
accessed again in the near future.

Example: In a loop, where a variable is repeatedly accessed multiple times (e.g., accessing an
array element inside a loop).

Impact: Temporal locality is exploited by keeping recently accessed data in faster memory (like a
CPU cache), so that the next access can be served quickly without needing to go back to slower
main memory.
05/03/2025 7
Locality of reference.
6
Example:
int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int sum = 0;
for (int i = 0; i < 10; i++)
{
sum += arr[i]; // Repeated access to arr[i], An example of temporal locality.
}

The comment mentioning “repeated access to arr[i]” is a valid observation of temporal locality, as
the same memory location (arr[i]) is being accessed repeatedly inside the loop.

2. Spatial Locality

Definition: If a memory location is accessed, nearby memory locations are likely to be accessed
soon.
Example: Accessing array elements in sequential order or traversing through elements in a matrix.
Impact: Spatial locality is exploited by preloading adjacent memory blocks into cache or
prefetching nearby data into memory before it is needed.
05/03/2025 8
Locality of reference.
6
Example:
int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int sum = 0;
for (int i = 0; i < 10; i++)
{
sum += arr[i]; //Accessing adjacent elements in the array, An example of spatial locality.
}

The comment mentioning “accessing adjacent elements in the array arr[i]” is a valid observation of
spatial locality, as the adjacent memory locations (arr[i]) are being accessed repeatedly inside the
loop.

05/03/2025 9
Locality of reference.
6
3. Importance of Locality of Reference

Cache Memory Efficiency:


Memory hierarchies (such as L1, L2, and L3 caches) rely heavily on locality to keep frequently
accessed data close to the CPU. The CPU can access data from the cache much faster than
from main memory.

Improved Performance:
When programs exhibit good locality of reference, fewer memory accesses are required, reducing
the time spent fetching data from slower storage (like main memory or disk).

Prefetching:
The CPU can use locality to predict and preload data into cache before it is needed, minimizing
waiting times.

05/03/2025 10
Difference between Von Neumann and Harvard
7 Architecture
 In the Harvard architecture (used by most  In Von Neumann architecture all memory
PIC microcontrollers), program code space is on the same bus and instruction and
(instructions) and data are on separate buses data use the same bus.
and this allows the program code and data to
be fetched simultaneously, resulting in an
improved performance.
 It improves the speed of the processor
operation because data and addresses do
not have to share the same bus lines. The
reduced size of the instruction set also
speeds up decoding and the short data path
length in a single chip design reduces data
transmission time.

05/03/2025 11
Performance and Speed

 Performance for a program on a particular machine is given as

Performance (X) = 1
Execution (X)
Performance (X) Execution (Y)
= = n
Performance (Y)
Execution (X)

 X is n times faster than Y.

05/03/2025 12
Measuring Time
 Execution time is the amount of time taken by the program to execute.

Time (computers do several tasks!):

In computing, time is an essential metric to measure the performance of a program or system.


Understanding the different types of time involved in executing tasks on a computer is crucial for
optimizing performance and resource usage.

Here are three important types of time to understand:


1. elapsed time based on a normal clock.
2. CPU time is the time spent on executing the program.
3. excluding waiting for I/O, or other programs.

05/03/2025 13
Measuring Time
1. elapsed time based on a normal clock.

Definition: Elapsed time is the total time it takes from the start to the end of the program's execution,
as measured by a real-world clock (like the clock on the wall).

What it includes:
CPU execution time: The actual time the CPU spends processing the program.

I/O time: Time waiting for input/output operations (disk read/write, network communication, etc.).

System time: Time spent by the operating system managing processes and switching between tasks.

Usefulness: Elapsed time is useful when you want to measure the overall user experience. For
example, if you're timing how long it takes for a web page to load from the user’s perspective, you’re
measuring elapsed time. It includes everything, from the CPU's time to waiting for data to be fetched
from a server.

Example: If you start a program at 10:00 AM and it finishes at 10:03 AM, the elapsed time is 3
minutes.
05/03/2025 14
Measuring Time
2. CPU time is the time spent on executing the program.

Definition: CPU time refers to the time spent by the CPU actually executing the instructions of the
program. It excludes the time spent waiting for I/O operations (like disk access or waiting for user
input) and other system-level processes.

What it includes:
 Time spent executing instructions directly related to the program's computation.
 It does not include the time spent waiting for the operating system to manage tasks,
waiting for data to be read from the disk, or waiting for user input.

Usefulness: CPU time is a more focused metric, especially when evaluating the efficiency of a
program's algorithm or computational workload. It provides insight into how much time the CPU
spends on actual computation, excluding external delays like I/O or system management overhead.

Example: If the program runs for 3 minutes (elapsed time) but spends 1 minute waiting for a file to
be loaded, the CPU time might only be 2 minutes.

3. excluding waiting for I/O, or other programs.


05/03/2025 15
The time to execute a given program can be computed as
10
 CPU time = CPU clock cycles x clock cycle time
 Since clock cycle time and clock rate are reciprocals
 CPU time = CPU clock cycles / clock rate

1. CPU clock cycles:


 This is the number of clock cycles the CPU needs to execute the instructions of a program. A
clock cycle is the time taken for one basic operation in the CPU (like adding two numbers,
moving data, etc.).
 The total number of clock cycles required to execute a program depends on various factors,
including the program’s complexity and how well it maps to the CPU’s instruction set.

2. Clock rate (also called Clock frequency):


 This is the speed at which the CPU’s clock oscillates, typically measured in Hertz (Hz). A clock
rate of 1 Hz means one cycle per second.
 The clock rate determines how many clock cycles the CPU can perform per second. For
example, if the CPU has a clock rate of 2 GHz (Gigahertz), it completes 2 billion cycles per
second.
05/03/2025 16
Why is this important?
1. The CPU time is a measure of how long the CPU spends processing the program. It's essential
for performance optimization.
2. Clock rate is a critical factor in how fast a CPU can execute instructions. A CPU with a higher
clock rate can complete more clock cycles per second, thus reducing the CPU time for a given
number of clock cycles.
3. However, clock cycles depend on the program's complexity and the type of instructions it
needs to execute. More complex programs might require more cycles, even if the clock rate is
high.
Example: Let assume that a benchmark has 100 instructions:
 25 instructions are loads/stores (each take 2 cycles)
 50 instructions are adds (each takes 1 cycle)
 25 instructions are square root (each takes 50 cycles)
 What is the CPI (Cycles Per Instruction) for this benchmark?
 CPI = ((0.25 * 2) + (0.50 * 1) + (0.25 * 50)) = 13.5

05/03/2025 17
Execution Time

Elapsed Time (real time)

CPU time for this program I/O waiting & other programs

Example: (UNIX)
11.099s 8.659s 10:43.67
(user) (system) (elapsed)
user (direct) system (time in OS)
(seconds) (seconds) (min: secs)
CPU time = 3.0% of elapsed time.

05/03/2025 18
Performance of Processor
13

 Pipelines - improve performance


 Programs - must be optimized
 Caches - improve performance
 Benchmarks - measure performance
 Device Fabrication - improves performance
 Various optimizations are possible

05/03/2025 19
Performance of Processor
13

 Do numerical from the book on this topic.

05/03/2025 20

You might also like