Mada za sehemu hiiDemonstrate understanding of the principles of computer architecture and organisationMada 7
- Describe the classification of computer architecture (Von Neumann and Non Von Neumann, Harvard Architecture, Modified Harvard Architecture, Flynn's Taxonomy)
- Demonstrate understanding of Boolean algebra and logic gates (Logic expressions, standard logic gate symbols, logic circuits)
- Explore computer memory (Meaning, design principles, memory hierarchy and interfacing, cache memory, memory mapping, primary & secondary memory)
- Analyse instruction set architecture (Instruction set types, registers, instruction execution cycles, addressing modes, register transfer language, ARM and x86 architectures)
- Describe I/O system (Direct Memory Access, Interrupt and exception, privileged / non privileged instruction)
- Demonstrate function of memory and input-output system
- Develop understanding of pipelining (Basics, types, stalling & forwarding, throughput and speedup, hazards) and Instruction Level Parallelism (concept, compilation techniques, scalar versus superscalar pipelining, branch prediction, register renaming) and thread and data level parallelism
Function of Memory and Input-Output System
Memory and Input/Output (I/O) systems are fundamental components of computer architecture that work together to enable computers to store, retrieve, and process data. The memory system acts as the computer's "pantry" – storing ingredients (data) needed for processing – while the I/O system functions as the delivery entrance and exit, handling the flow of data between the computer and external devices. Understanding how these systems function is essential for designing efficient computer systems and troubleshooting performance issues.
1.1 Concept of Computer Memory
Computer memory is the internal storage of a computer system that holds data, instructions, and processed results during data processing. It enables the system to temporarily store and process data as needed. Memory is crucial for the proper functioning of a computer, similar to how a well-organized library shelf holds books for quick access.
Key Functions of Memory:
- Data Storage: Holds binary data (0s and 1s) representing information
- Data Retrieval: Quickly accesses stored data when needed by the CPU
- Program Execution: Stores instructions that the CPU executes
- Intermediate Results: Temporarily holds results of calculations
1.2 Memory Hierarchy
Memory hierarchy is an organization of different memory levels, each with distinct speed, size, and cost characteristics. The hierarchy exists because faster memories are more expensive and cannot be manufactured in large sizes.
The Hierarchy (from fastest to slowest):
| Level | Type | Speed | Size | Location |
|---|---|---|---|---|
| Level 1 | Registers | Fastest | Smallest | Inside CPU |
| Level 2 | Cache | Very Fast | Small | Near CPU |
| Level 3 | Main Memory (RAM) | Fast | Medium | Motherboard |
| Level 4 | Secondary Storage | Slowest | Largest | External devices |
Principles Behind the Hierarchy:
-
Principle of Locality: Programs access a relatively small portion of their data and instructions at any instant.
- Temporal Locality: Recently accessed data is likely to be accessed again soon
- Spatial Locality: Data near recently accessed data is likely to be accessed soon
-
Cost-Performance Ratio: Faster and smaller memories are more expensive per unit of storage. This balance ensures optimal performance at minimal cost.
1.3 Cache Memory
Cache memory is a smaller, faster memory that stores copies of data from frequently used main memory locations. It acts as a buffer between the CPU and main memory.
Cache Levels:
- L1 Cache: Closest to CPU, smallest but fastest (typically 32KB)
- L2 Cache: Larger than L1, slightly slower (typically 256KB-1MB)
- L3 Cache: Largest cache, shared among cores (typically 8MB or more)
Cache Operations:
- Cache Hit: Requested data is found in cache – fast access
- Cache Miss: Requested data is not in cache – must fetch from main memory
Example Calculation:
If a processor has a cache hit rate of 95%, a hit time of 4ns, and a miss penalty of 80ns:
1.4 Primary and Secondary Memory
Primary Memory (Main Memory):
- Includes RAM and cache memory
- Provides fast, temporary storage directly accessible by CPU
- Volatile: Loses data when power is turned off
- Example: RAM (Random Access Memory)
Secondary Memory:
- Includes hard drives, SSDs, flash memory
- Provides larger, permanent storage
- Non-volatile: Retains data without power
- Example: Hard Disk Drive (HDD), Solid State Drive (SSD)
1.5 Memory Technologies
| Technology | Type | Use | Characteristics |
|---|---|---|---|
| SRAM | Primary | Cache, Registers | Fast, expensive, uses transistors |
| DRAM | Primary | Main Memory | Slower than SRAM, uses capacitors, needs refresh |
| Flash | Secondary | SSDs, USB drives | Non-volatile, portable, reasonable speed |
| Magnetic Disk | Secondary | HDD | Cheapest per GB, mechanical, slowest |
2.1 I/O System Overview
The I/O system handles communication between the CPU and external devices such as keyboards, mice, printers, storage devices, and network cards. It manages data flow into and out of the computer system.
Key Functions of I/O System:
- Data Input: Receives data from external devices (keyboard, mouse, sensors)
- Data Output: Sends data to external devices (monitor, printer, speakers)
- Data Storage: Interfaces with secondary storage devices
- Communication: Manages network and communication interfaces
2.2 Direct Memory Access (DMA)
DMA is a technology that allows external devices to transfer data directly to/from memory without CPU involvement, improving system performance.
How DMA Works:
- CPU sends transfer details to DMA controller (address, size, direction)
- CPU suspends current task and saves its state
- DMA controller takes control of the bus (becomes bus master)
- DMA transfers data directly between memory and device
- DMA returns control to CPU when complete
Types of DMA Transfers:
- Burst Mode: Transfers entire data block before returning control to CPU
- Cycle Stealing: Transfers one byte at a time, alternating with CPU
- Transparent Mode: Transfers only when CPU is not using the bus
- Scatter-Gather: Transfers non-contiguous data blocks
Benefits of DMA:
- Reduced processor workload
- Improved system throughput
- Faster data transfer for bulk operations
- Better performance for video, audio, and disk operations
2.3 Interrupts and Exceptions
Interrupts: Signals generated by external devices that require immediate CPU attention (e.g., key pressed, data received)
Exceptions: Internal events generated by the processor during program execution (e.g., division by zero, invalid instruction)
How Interrupts Work:
- External device sends interrupt signal to CPU
- CPU finishes current instruction
- CPU saves current state (registers, program counter)
- CPU executes Interrupt Service Routine (ISR)
- CPU restores state and continues original program
Priority Levels: Different interrupts have different priorities – high-priority interrupts (like hardware failures) preempt lower-priority ones (like keyboard input)
2.4 Privileged and Non-Privileged Instructions
Privileged Instructions: Can only be executed by the operating system; control critical system functions
- Examples: Memory management, I/O operations, halt instruction
Non-Privileged Instructions: Can be executed by any program; perform basic operations
- Examples: Arithmetic operations, data movement, logical operations
This separation ensures system security and stability by preventing user programs from accessing critical hardware functions directly.
The memory and I/O systems function as an integrated unit:
-
Data Input Flow:
- External device → I/O system → Memory (RAM) → CPU processing
-
Data Output Flow:
- CPU processing → Memory → I/O system → External device
-
Storage Operations:
- CPU issues I/O command → DMA transfers data between storage and memory → CPU continues processing
-
Virtual Memory:
- Uses secondary storage to extend available memory
- Pages frequently used data in RAM, less-used data on disk
- Translation Lookaside Buffer (TLB) speeds up address translation
Scenario: A student opens a document on their computer.
Step-by-Step Process:
-
Request Received: CPU receives request to open "essay.docx"
-
Check Cache: CPU checks L1 cache for the file – Cache Miss
-
Check L2/L3: CPU checks L2/L3 caches – Cache Miss
-
Access RAM: CPU accesses RAM – if found, loads into cache
-
Access Disk: If not in RAM, CPU uses I/O system to read from hard drive
-
DMA Transfer: DMA controller handles disk-to-RAM transfer without CPU intervention
-
Load to CPU: Data loaded into registers for processing
-
Display: Processed data sent through I/O system to monitor
This demonstrates how memory hierarchy and I/O systems work together to retrieve data efficiently.
In Tanzania, understanding memory and I/O systems is practically applied when using mobile phones and computers for mobile money transactions (such as M-Pesa). When a customer sends money, the transaction data flows through input devices (phone keypad), is processed using RAM and cache memory, and then stored in secondary storage or transmitted via network interfaces. If the phone's RAM is insufficient (causing slow performance), the system may use virtual memory (swapping to storage), which is much slower. Similarly, farmers using weather apps or market price information rely on these memory and I/O systems to quickly retrieve and display data from servers, with DMA enabling smooth data transfers for streaming agricultural videos or market updates.
Swali
Which level of the memory hierarchy is the fastest and located inside the CPU?
Ingia ili kuwasilisha jibu lako na lihesabiwe katika umahiri wako.
Ingia ili kufanya mazoeziMwalimu
Umekwama? Niulize chochote kuhusu mada hii.
Ingia ili kumuuliza Mwalimu wa AI wa Sonza kuhusu swali hili.
Ingia ili kuuliza