Computer Architecture Assignment 1
Computer Architecture Assignment 1
ASSIGNMENT COVER
REGION: HARARE
MAILING ADDRESS:[email protected]
MARKER’S COMMENTS:
______________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
OVERALL MARK: _____________ MARKER’S NAME: ________________________
(a) With an aid of a diagram, discuss the Memory Hierarchy in computer system
regarding Speed, Size and Cost [10 Marks]
The Memory Hierarchy in a computer system organizes memory components based on their
speed size and cost
Registers: These are small, high speed memory units located within the CPU. Registers Store
frequently used data and instructions. They have the fastest access time but limited storage
capacity(16-64 bit)
Cache Memory: Cache memory is small fast memory unit close to the CPU which stores
recently accessed data from main memory, cache memory is more expensive and has limited
size.
Main memory (Random Access Memory) is the primary memory of a computer system. It has
larger storage capacity than cache memory but slower. Random Access Memory holds data
and instructions currently in use by the CPU
Secondary Storage (Hard Disk Drive , Solid State Drive): Secondary storage provides non
volatile memory with even larger capacity. Access time is slower compared to Main memory.
(b) What is Virtual Memory? Explain the need for Virtual Memory [10 Marks]
Virtual memory is a memory management technique used by operating systems which
allows a computer to temporarily increase the capacity of its main memory (Random Access
Memory) by utilizing secondary memory, such as a hard drive or solid-state drive.
Address Translation .In virtual memory, the addresses used by a program are distinct from
the addresses used by the memory system to identify physical storage locations .The virtual
memory manager dynamically translates logical addresses into physical addresses during
runtime. Virtual memory creates an illusion of a memory space larger than the actual
physical memory. It allows processes to operate with only some portions of their address
space in memory at any given time.
(c) Sketch the internal organization of CPU out with its functionalities and block diagram
[10 Marks]
1.Input Unit:
The input unit receives data from devices like keyboards, mice, and scanners. It processes user-
provided data, converting it into binary format for computer comprehension. Transformed data is
then transmitted to the computer's main memory.
2.Memory Unit:
The memory unit stores instructions, data, and intermediate results. It plays a crucial role in data
storage and processing.
6.Input Unit: Receives user data, converts it to binary, and transmits it to memory.
9. CPU: Accesses relevant data from primary storage, performs operations using the ALU, and
ensures seamless functionality.
(d) Describe the role of the 5 registers of the simple machine [10 Marks]
1.Memory Data Register:
The MDR stores data that is either sent to or fetched from memory. When the CPU needs to
read data from memory or write data to memory, it interacts with the MDR. It acts as a
temporary buffer for data during memory operations.
3.Accumulator :
The accumulator serves as a central point for arithmetic and logical operations within the
CPU. It fetches data from memory and stores intermediate results during calculations.
Common arithmetic operations (addition, subtraction, multiplication, division) take place in
the accumulator. The final result may be stored in the accumulator or transferred to other
registers or memory locations.
4. Interrupt Register :
The IR manages requests from input or output devices. When an input or output device
needs attention it triggers an interrupt. The CPU responds by saving the current state of
execution and handling the interrupt request.
Question 2
(a) With an aid of a diagram, explain what the term “pipelining” means. In your explanation,
outline the benefits and basic operation of a pipelined architecture compared with a non-
pipelined architecture. [10 Marks]
2. Instruction Decode :
In this stage, the opcode (operation code) of the instruction is decoded. Operand addresses
are determined.
3. Address Generation :
The AG stage calculates memory addresses for data access. It prepares to fetch operands.
4. Data Fetch :
Operands (data) are fetched from memory or registers. These operands are needed for the
execution phase.
5. Execution :
The actual operation specified by the instruction like addition and subtraction takes place.
ALU (Arithmetic Logic Unit) performs the computation.
Benefits of Pipelining:
1. Increased Instruction Throughput:
Pipelining allows multiple instructions to be in different stages simultaneously. As a result,
more instructions are executed per clock cycle, improving overall throughput.
2.Faster Execution:
Although individual instruction execution time remains the same, pipelining reduces the
overall program execution time. Instructions overlap, leading to better utilization of CPU
resources.
3. Higher Clock Frequencies:
Pipelined CPUs can operate at higher clock frequencies than non-pipelined ones. This boosts
overall performance.
Pipelined Architecture Non-Pipelined Architecture
Increased instruction throughput Instructions are executed sequentially
without overlapping stages
Faster ALU design No concurrency, resulting in lower
throughput
Overall performance improvement Longer execution time for programs
Higher clock frequencies
(b) Explain Daisy-Chaining priority and Parallel priority Interrupt with its hardware diagram.
[10 Marks]
Daisy-Chaining Priority Interrupts
The daisy-chaining method, the devices that can request an interrupt are connected in a serial
manner. The arrangement is governed by the priority of these devices. It works as illustrated
below
1. Configuration:
Devices are connected one after the other, forming a chain. The device with the highest
priority is placed first, followed by the second highest priority device, and so on. The lowest
priority device is placed at the end of the chain.
3. CPU Acknowledgment :
The CPU acknowledges the interrupt request from the line. It then enables the interrupt
acknowledge line in response.
2.Priority Encoding:
Devices are assigned unique priority levels. The device with the highest priority has its
interrupt line activated first.
3. Interrupt Acknowledgment:
When an interrupt occurs, the CPU acknowledges the highest-priority interrupt line. The
corresponding device's service routine is executed.
Device 1 (Highest)
CPU
Device 2
Device 3 (Lowest)
2. Synchronization:
Synchronization ensures that processes or threads execute in a coordinated manner,
adhering to specific order or timing constraints. It is Important because synchronization
prevents race conditions, deadlocks, and other concurrency related issues. It ensures
mutually exclusive access to shared writable data by the use of tools such locks and
semaphores ,Barriers ,Monitors and clock synchronisation. Locks and Semaphores allow
processes to acquire and release locks, ensuring exclusive access to critical sections. Barriers
synchronize processes at specific points, ensuring they all reach a common point before
proceeding. Monitors encapsulate shared data and provide synchronized access methods.
Clock Synchronization ensures that clocks across processors are consistent.
Inter Processor communication and synchronization are essential for efficient operation in
shared multiprocessor systems, ensuring coordinated communication and preventing
conflicts
(d) Illustrate the mapping process involved in transformation of data from main to Cache
memory. [10 Marks]
. Cache mapping refers to the technique used to bring data from the main memory into the cache
memory. It ensures that frequently accessed data resides in the cache, improving overall system
performance. The goal is to identify the cache line where a specific main memory block should be
placed .The main memory is divided into equal-sized partitions called main memory blocks then the
cache lines are divided into equal partitions called cache lines. The number of bytes or words in one
block is called the block size. The number of cache lines is determined by the ratio of cache size to
the block or line size.
Direct Mapping: In this method, each main memory block is mapped to exactly one cache line. The
cache line number is determined by the block number modulo the total number of cache lines.
Fully Associative Mapping : Here, any main memory block can be placed in any cache line. The
entire cache is considered a single set.
Set Associative Mapping: The cache is divided into multiple sets, and each set contains a fixed
number of cache lines. A main memory block can be placed in any line within a specific set.
Direct Mapping
Cache Line Number: Represents the cache line where the content is present.
Mapping Function:
To illustrate
For example we have a direct mapped cache with 8 cache lines indexed from 0 to 7. Each cache line
holds a 32-byte block.
The tag bits help identify which main memory block is present in cache line 1.
Question 3
(a) With examples, Explain four segment CPU pipeline and Timing of instruction
pipeline. [10 Marks]
A CPU pipeline is a technique that overlaps the execution phases of different instructions to improve
throughput. In a four-segment instruction pipeline, the instruction cycle is divided into four
segments, each handling specific tasks:
Decodes the fetched instruction. Calculates the effective address (if applicable).
3. Operand Fetch :
The four segments work in parallel, allowing multiple instructions to progress simultaneously.
However, pipeline efficiency can be affected by memory access conflicts or branch instructions.
The timing of an instruction pipeline depends on the duration of each segment. For example
Fetch: 10 ns
Decode: 6 ns
Execute: 8 ns
Write: 8 ns
Once the pipeline is full, the flow of instructions is determined by the longest stage duration (in this
case, 10 ns). The pipeline operates as follow
10 ns | 6 ns | 8 ns | 8 ns
--------------------------------
I7 | I6 | I5 | I4
: |: |: |:
I1 | out | |
d. Demonstrate the pipeline organisation for following example Ai*Bi+Ci for i =1,2,3,……
[10 Marks]
1. Instruction Fetch (IF):
Fetch the next instruction ( Ai) from memory. Store it in the FIFO buffer.
2. Instruction Decode and Effective Address Calculation . Decode the instruction ( Ai).
3.Operand Fetch :
Fetch operands (Bi and Ci) from memory and store them in appropriate registers.
4. Instruction Execution : Perform the multiplication (Ai * Bi). Add the result to Ci.
A1*B1=AB+C1=AB+C
A2*B2=2((AB)+C)
A3+B3=3((AB)+C))
References:
https://computersciencewiki.org/index.php/Registers_within_the_CPU