Architecture and Micro
Architecture and Micro
Microprocessor
1
Chapter 1: Introduction to Computer Architecture
Write short notes on Basic organization of a computer system (Von Neumann architecture)
Control Unit (CU): Directs the operation of the processor by fetching, decoding, and executing
instructions from memory.
Registers: Small, fast storage locations within the CPU used to hold data temporarily during
execution.
Memory:
Primary Memory (RAM): Volatile memory used to store data and instructions that the CPU
needs while executing tasks.
Read-Only Memory (ROM): Non-volatile memory containing essential instructions for booting
the computer and performing diagnostics.
Input Devices: Tools for user input, such as keyboards, mice, and scanners.
Output Devices: Tools for data output, like monitors, printers, and speakers.
Bus System:
Data Bus: Transfers data between the CPU, memory, and I/O devices.
Address Bus: Carries addresses of data (but not the data itself) to be read or written by the CPU.
2
Control Bus: Carries control signals from the CPU to other components to manage data flow and
operations.
Storage:
Primary Storage: Includes RAM and cache, which provide fast access to data for the CPU.
Secondary Storage: Non-volatile storage such as hard drives, SSDs, and optical discs used for
long-term data storage.
Stored Program Concept: Instructions and data are stored in the same memory space.
Sequential Execution: Instructions are fetched from memory one at a time and executed in order.
Single Bus for Data and Instructions: Both data and instructions share the same communication
pathways, simplifying design but potentially leading to bottlenecks.
3
Operation Flow:
Execute: The ALU executes the instruction, performing calculations or data manipulation.
The Instruction Set Architecture (ISA) is the part of a computer architecture related to
programming, which includes the set of instructions that a processor can execute. It serves as the
interface between software and hardware, defining the supported instructions, data types,
registers, addressing modes, and the input/output model.
1) Instruction Types:
Arithmetic and Logic Instructions: Perform mathematical operations (e.g., addition, subtraction)
and logical operations (e.g., AND, OR, NOT).
Data Transfer Instructions: Move data between memory and registers or between registers (e.g.,
LOAD, STORE, MOVE).
Control Flow Instructions: Change the sequence of execution (e.g., JUMP, CALL, RETURN,
conditional branches).
Input/Output Instructions: Manage data exchange between the processor and external devices
(e.g., IN, OUT).
2) Data Types:
Defines the types of data the ISA can process, such as integers, floating-point numbers,
characters, and more complex data structures.
4
3) Registers:
Small, fast storage locations within the CPU used to hold data temporarily during instruction
execution.
4) Addressing Modes:
Methods for specifying the operands of instructions. Common modes include immediate, direct,
indirect, register, indexed, and base-plus-offset addressing.
5) Instruction Format:
The binary representation of instructions, including opcode (operation code) and operands.
Defines the layout and size of each instruction.
6) Encoding:
The method by which instructions and their components (opcode, operands) are represented in
binary form. Can affect the complexity and performance of the processor.
5
Types of ISAs:
Features a large number of complex instructions that can perform multiple operations.
Emphasizes a smaller set of simpler instructions, aiming for higher performance through
simplicity and efficiency.
ISA Characteristics:
1) Compatibility:
Defines the ability of software to run on different generations of processors within the same ISA
family.
2) Performance:
Affects the efficiency and speed of software execution, influenced by factors such as instruction
complexity, pipeline design, and parallelism.
3) Scalability:
The ability to extend the ISA with new instructions or features while maintaining backward
compatibility.
4) Portability:
Facilitates the development of software that can run on different hardware platforms with the
same ISA.
6
Write short notes on Performance metrics (speed, throughput, *MIPS, *CPI, *FLOPS)
Speed: Refers to how quickly a computer system can complete a specific task or execute a
program. Often measured in time units (seconds, milliseconds, etc.).
Throughput: Measures the amount of work a system can accomplish in a given time period.
Typically expressed in units like tasks per second or data processed per second.
Measures the execution rate of a computer, indicating how many million instructions a processor
can execute per second.
While useful, MIPS can be misleading as it doesn’t account for the complexity of different
instructions or variations in program behavior.
CPI is influenced by the instruction set architecture, microarchitecture, and the nature of the
workload.
7
Write short notes on Types of computer architectures ( Harvard, *RISC, *CISC, VLIW,
EPIC)
Key Characteristics:
Definition: Architecture with a broad set of instructions, some of which perform complex tasks.
Key Characteristics:
3. Harvard Architecture:
Definition: Architecture with separate memory storage for instructions and data.
Key Characteristics:
Definition: Architecture that allows multiple operations to be encoded in a single long instruction
word.
Key Characteristics:
Definition: Architecture that relies on the compiler to identify parallelism and optimize
execution.
Key Characteristics:
9
Chapter 2: Processor Fundamentals and Programming Model
Common Instructions:
o PUSH/POP: Transfer data between registers and the stack (push onto or pop from
the stack).
2. Arithmetic/Logical Instructions:
Arithmetic Operations:
Logical Operations:
10
o OR: Perform a bitwise OR.
Example: OR AX, BX (Logical OR between AX and BX).
Common Instructions:
Use:
Example: MOV AX, [1000] (Move the value at memory location 1000 into AX).
11
Use:
o Easy to understand.
Definition: The instruction specifies a register or memory location that holds the address
of the operand.
Example: MOV AX, [BX] (The address stored in BX points to the operand, which is
moved into AX).
Use:
Definition: The operand is located in a register, and the instruction specifies the register.
Use:
Definition: The address of the operand is calculated by adding an index value (stored in a
register) to a base address.
Example: MOV AX, [BX + 10] (The value at the memory location specified by the sum
of the BX register and the offset 10 is loaded into AX).
Use:
Key Points:
12
Direct Addressing accesses a fixed memory location, making it easy but static.
Indexed Addressing is commonly used in arrays and complex data structures for flexible
memory access.
13
Chapter 3: Memory Hierarchy and Organization
Write short notes on Memory types and technologies (RAM, ROM, Cache)*
Definition: Volatile memory used for temporary storage of data and instructions
currently being processed by the CPU.
Characteristics:
Types:
Use: Main memory in computers, providing fast access to data for the CPU.
Definition: Non-volatile memory used for permanently storing data needed for system
boot and basic functions.
Characteristics:
o Read-Only: Data can typically only be read, not written during normal operation.
Types:
14
o EPROM (Erasable Programmable ROM): Erasable and reprogrammable using
ultraviolet light.
Use: Stores firmware, system boot instructions, and essential system software.
3. Cache Memory
Definition: High-speed memory located near the CPU, used to store frequently accessed
data for faster retrieval.
Characteristics:
o High-speed: Faster than RAM, located between the CPU and main memory.
o Stores frequently used data: Reduces access time to main memory, improving
overall CPU efficiency.
Levels:
o L1 Cache: Small and very fast, located directly on the CPU chip.
o L2 Cache: Larger than L1, slower but still faster than main memory, located near
the CPU.
Use: Enhances performance by reducing the time it takes to access frequently used data.
Key Points:
RAM: Volatile, fast, and used for temporary data storage during operations.
ROM: Non-volatile, used for storing permanent system data like firmware and BIOS.
15
Memory hierarchy and its importance
Memory hierarchy is a structured arrangement of storage types based on speed, cost, and size.
Memory hierarchy is important because it optimizes the speed and efficiency of data access in
computer systems. It organizes memory into different levels based on speed, size, and cost,
ensuring that frequently used data is stored in faster, more expensive memory (like CPU caches),
while less frequently used data is kept in slower, larger, and cheaper memory (like RAM or disk
storage). This structure reduces the average time to access data, balancing the trade-off between
performance and cost, ultimately improving overall system efficiency.
Registers:
Purpose: Temporary storage for data currently being processed by the CPU.
16
Cache Memory:
Purpose: Stores frequently accessed data and instructions to reduce access time to the
main memory.
Cost: Moderate
Purpose: Stores active programs and data that are in current use.
Speed: Slower than RAM but faster for SSD compared to HDD
Purpose: Permanent storage for files, applications, and operating system data.
Speed: Slowest
17
Write short notes on Memory access time and bandwidth.
Definition:
Memory access time is the amount of time it takes to read or write data from memory
after the address is supplied.
Memory Access Time is the time it takes to read or write a single data item from or to
memory. It's a crucial factor in determining the overall performance of a computer
system. Faster access times lead to quicker program execution.
Components:
o Latency: The delay between the request for data and the delivery of the data.
o Memory type: Faster memories like cache and RAM have lower access times
compared to secondary storage (e.g., HDD/SSD).
o Distance from CPU: Memory closer to the CPU (e.g., registers, cache) has lower
access times than those farther away (e.g., secondary storage).
Importance:
Shorter access times improve the system’s performance by allowing the CPU to retrieve
and process data more quickly.
Memory Bandwidth
Definition:
Memory bandwidth is the amount of data that can be transferred to or from memory per second,
usually measured in gigabytes per second (GB/s).
Memory Bandwidth is the rate at which data can be transferred between the CPU and memory.
It's often measured in bytes per second (B/s). Higher bandwidth means more data can be
transferred in a given amount of time, which is essential for applications that deal with large
datasets.
18
Formula:
o Bus Width: Wider memory buses allow more data to be transferred at once.
o Clock Speed: Faster clock speeds increase the number of operations performed
per second.
o Memory Type: DDR (Double Data Rate) and other high-performance memory
technologies can transfer data on both rising and falling edges of the clock signal.
Importance:
Higher memory bandwidth allows more data to be transferred in a given time, improving
the system’s ability to handle high-performance tasks like gaming, video rendering, or
scientific simulations.
Write short notes on: *Cache memory: organization, *mapping, *replacement policies,
associativity, cache coherency.
1. Organization
Definition: Cache memory is a small, high-speed memory close to the CPU that stores
frequently accessed data, reducing access time to main memory.
Structure:
o Levels: Typically has multiple levels (L1, L2, L3), where L1 is the smallest and
fastest, and L3 is the largest but slowest.
2. Mapping Techniques
Direct Mapping:
o Disadvantage: Can cause conflict misses if multiple addresses map to the same
line.
19
Fully Associative Mapping:
Set-Associative Mapping:
o Cache is divided into sets, and each block can be placed in any line within its set.
3. Replacement Policies
When a cache is full, a block must be replaced using one of these policies:
Least Recently Used (LRU): Replaces the block that hasn’t been accessed for the
longest time.
Least Frequently Used (LFU): Replaces the block accessed the fewest times.
4. Associativity
Definition: Determines how many cache lines a memory block can be mapped to.
o Direct-Mapped: Each block maps to only one cache line (1-way set associative).
o Set-Associative: Blocks are mapped to sets, allowing multiple cache lines per set
(e.g., 2-way, 4-way).
Trade-Off: Higher associativity reduces conflict misses but increases complexity and
access time.
5. Cache Coherency
20
Problem: If one cache updates its copy of the data, other caches must reflect this change
to avoid inconsistencies.
Coherency Protocols:
Key Points:
Virtual Memory: Allows processes to use more memory than is physically available by
extending RAM with disk space.
Segmentation: Divides memory logically, offering more flexibility and better memory
protection but can suffer from external fragmentation.
Page Faults: Occur when a virtual page is not present in physical memory, requiring the OS
to load it from disk.
21
Virtual Memory: Key Points
1. Concept
Purpose: Enables the system to run large applications and multitask efficiently.
2. Paging
Definition: Divides both virtual and physical memory into fixed-size blocks called pages
(virtual memory) and page frames (physical memory).
How it Works:
o The MMU translates a program’s virtual address into a physical address using a
page table.
o If the requested page is not in RAM, a page fault occurs, and the OS retrieves it
from disk (swap space).
Advantages:
Disadvantage:
o Page faults can slow down system performance since accessing disk is slower
than accessing RAM.
3. Segmentation
Definition: Divides virtual memory into logical segments that correspond to different
parts of a program (e.g., code, data, stack).
How it Works:
22
o The MMU uses a segment table to map the virtual addresses of segments to
physical memory.
o Each segment has a base address and limit, allowing for variable-sized segments.
Advantages:
o Supports logical memory grouping, making it easier to manage code and data
separately.
o Provides better protection and sharing as segments can have different access
rights.
Disadvantage:
o Manages the page tables (for paging) or segment tables (for segmentation),
handles page faults, and manages swapping of pages/segments between RAM and
disk.
o Some systems combine both techniques, dividing virtual memory into segments,
with each segment further divided into pages. This provides the flexibility of
segmentation and the efficiency of paging.
23
Chapter 4: Data Path and Control Unit
Definition: The data path refers to the circuitry within a processor responsible for
executing instructions, performing arithmetic and logical operations, and controlling data
movement.
Purpose: Acts as the backbone of the CPU, handling communication and processing
between components such as registers, the ALU (Arithmetic Logic Unit), and memory.
Components: Includes registers, ALU, multiplexers, buses, memory units, and control
logic.
Registers:
o Types:
Buses:
o Types:
24
Address Bus: Carries memory addresses from the CPU to memory.
Control Bus: Sends control signals to manage data flow and operations.
Multiplexers (MUX):
o Function: Selects one of many inputs to pass to the next stage, enabling
controlled data processing.
Memory Units:
o Types:
Main Memory (RAM): Larger but slower memory used for active
processes.
Control Unit:
o Function: Directs the operations of the data path by generating control signals to
regulate the execution of instructions.
o Types:
Instruction Decode: The control unit decodes the fetched instruction and sets up the data
path.
25
4. Types of Data Paths
o Breaks down instruction execution into multiple steps over several cycles.
5. Design Considerations
Instruction Set Architecture (ISA): The set of instructions the processor can execute;
the data path must support ISA operations.
Clock Rate: Determines the speed of instruction execution; higher clock rates improve
performance.
26
6. Key Points
The data path is crucial for instruction execution and overall CPU operation.
Components such as the ALU, registers, buses, memory units, and control unit are
essential for data path functioning.
Effective data path design influences CPU performance, execution speed, power
consumption, and scalability.
Write notes on Data path organization (data path and control path)*
Control Path: Directs and manages the flow of data through the data path using control
signals.
the processor depends on the effective design and coordination of these two paths.
Data Path
Definition: The data path consists of the components within a CPU that handle the actual
processing of data. It includes hardware components that perform arithmetic, logical, and
data transfer operations.
Key Components:
o Registers: Small, fast storage locations that hold data temporarily during
processing.
o Buses: Pathways that transfer data between the ALU, registers, memory, and
other components.
o Multiplexers (MUX): Used to select between multiple data sources, routing them
to the next component for processing.
o Memory Interface: Manages the transfer of data between the CPU and memory
(cache or main memory).
27
Function: The data path is responsible for executing instructions by performing
operations on data and moving it through various parts of the CPU.
Operations:
2. Control Path
Definition: The control path manages the sequencing and execution of instructions by
generating control signals that direct the data path.
Key Components:
o Control Unit: The main component that interprets instructions and sends control
signals to the data path components.
o Control Signals: Generated by the control unit to direct the operations of the
ALU, registers, memory, and other components.
o Finite State Machine (FSM): The control unit often operates as an FSM,
changing states based on the current instruction and generating the appropriate
control signals.
Function: The control path ensures that the right operations happen in the correct order
by coordinating the flow of data through the data path.
Types:
28
3. Relationship Between Data Path and Control Path
Interaction: The control path generates signals that direct the operations within the data
path. It dictates when the ALU should perform an operation, when data should be read
from memory, and when the result should be written back to a register.
Execution Process:
o The data path executes the instruction under the direction of these control signals.
Definition: The control unit is responsible for directing the operations of the processor by
generating control signals to coordinate the execution of instructions. It orchestrates the
activities of the data path components (ALU, registers, memory).
o Hardwired Control
o Microprogrammed Control
Definition: A hardwired control unit uses fixed logic circuits to generate control signals
based on the current instruction. It consists of combinational logic that produces control
outputs based on the inputs (opcode, flags).
Characteristics:
o Speed: Faster than microprogrammed control due to the direct use of logic
circuits.
o Complexity: More complex to design and modify because control signals are
generated by intricate combinations of logic gates.
29
o Size: Occupies less space compared to microprogrammed control as no control
memory is needed.
Advantages:
Disadvantages:
o Complex design for modern processors with large and diverse instruction sets.
Characteristics:
o Complexity: Easier to design and debug as the control logic is specified in a more
structured and programmable way.
o Size: Requires more space due to the need for control memory to store
microinstructions.
Advantages:
Disadvantages:
30
o Requires more memory space for storing microprograms.
5. Key Points
Hardwired Control is faster and more efficient for simpler instruction sets but less
flexible and harder to modify.
The control unit is a crucial component of a processor, responsible for coordinating the execution
of instructions. Its design and implementation can significantly impact the processor's
performance and flexibility.
Control Unit (CU) is the central component of a processor responsible for sequencing the
execution of instructions and controlling the data path components. It acts as the "brain" of the
processor, ensuring that instructions are fetched, decoded, and executed correctly.
31
Functions:
Instruction Fetch: Retrieves instructions from memory based on the current value of the
program counter (PC).
Operand Fetch: Retrieves the operands required for the instruction from registers or
memory.
Operation Execution: Sends control signals to the data path components to execute the
specified operation.
Result Storage: Stores the result of the operation in a register or memory location.
Design Considerations
Hardwired Control: A design where the control signals are generated directly by
combinational logic. This can be faster but less flexible than microprogramming.
Superscalar: A processor that can execute multiple instructions in parallel. The control
unit must schedule instructions efficiently to maximize parallelism.
Implementation
Hardwired Control: A state machine or finite state automaton can be used to implement
the control logic.
32
Write short notes on Arithmetic Logic Unit (ALU) operations and structure*
performing arithmetic and logical operations. It executes operations based on the instructions
provided by the control unit.
ALU Operations: Include arithmetic (addition, subtraction), logical (AND, OR), comparison
(equal, greater than), and shift operations (left/right shifts).
ALU Structure: Comprises operand registers, an ALU control unit, arithmetic and logical
operation units, and result storage.
Operations
Arithmetic Operations:
o Addition
o Subtraction
o Multiplication
o Division
o Increment
o Decrement
33
Logical Operations:
o AND
o OR
o NOT
o XOR
Comparison Operations:
34
Shift Operations:
Logical Shift Left (LSL): Shifts bits to the left, inserting zeros on the right.
Logical Shift Right (LSR): Shifts bits to the right, inserting zeros on the left.
Arithmetic Shift Right (ASR): Shifts bits to the right, preserving the sign bit for signed
integers.
ALU Structure
Basic Components:
o ALU Control Unit: Interprets the opcode and generates control signals for the
specific operation.
Bus Interface:
o Control Bus: Sends control signals from the control unit to the ALU.
35
2. ALU Implementation
Combinational Logic: ALUs use combinational logic circuits to generate outputs based
solely on current inputs.
Basic Gates:
o AND, OR, NOT, XOR, NAND: Fundamental gates used to build the ALU.
Carry-Lookahead Logic:
Ripple-Carry Adder:
o Description: A simple adder where the carry-out from one stage is used as the
carry-in for the next stage.
Barrel Shifter:
36
Chapter 5: Pipelining
What is pipelining?*
Key Concepts:
o Execute (EX)
Parallelism: Multiple instructions are processed at the same time, each at a different
stage, increasing the overall number of instructions completed per unit of time.
Cycle Time Reduction: Each stage can be optimized to execute faster, reducing the time
per instruction cycle.
37
Hazards in Pipelining:
Data Hazards: Occur when instructions depend on the results of previous instructions
still in the pipeline.
Control Hazards: Arise from branch instructions that affect program flow.
Structural Hazards: Happen when hardware resources are insufficient for simultaneous
instruction processing.
Pipeline Stalls: Occur when hazards prevent the next instruction from advancing,
temporarily halting the pipeline.
Speedup:
Theoretically, pipelining can speed up execution by the number of stages. However, the
actual performance gain is reduced by hazards and stalls.
Types of Pipelining:
Benefits of Pipelining:
Challenges:
Hazards and Stalls: Need to be mitigated to avoid reducing the potential performance
gain.
38
What is Pipeline hazards: data, control, and structural hazards?*
Pipeline hazards are conditions that prevent the next instruction in the pipeline from executing
in the following cycle. They cause delays and reduce pipeline efficiency. There are three main
types:
1. Structural Hazards: Occur when hardware resources are insufficient to support all
instructions in the pipeline at the same time.
2. Data Hazards: Happen when instructions depend on the results of previous instructions,
leading to incorrect data being used (e.g., Read After Write (RAW) dependency).
3. Control Hazards: Arise from changes in program flow, such as branch instructions,
causing incorrect instructions to enter the pipeline.
What are the techniques to resolve hazards in pipelining?: forwarding, stalling, branch
prediction
1. Stalling: Pausing the pipeline until the hazard is resolved (used in structural and data
hazards).
2. Forwarding (Data Bypassing): Bypassing data from later stages to earlier ones to
resolve data hazards.
3. Branch Prediction: Predicting the outcome of a branch instruction to reduce control
hazards, allowing the pipeline to continue with predicted instructions.
4. Delayed Branching: Delaying the execution of a branch instruction by scheduling
independent instructions to execute while the branch is resolved.
5. Pipeline Flushing: Discarding incorrect instructions from the pipeline in the case of
incorrect branch predictions (control hazard).
Pipeline Stalls:
Definition: A pipeline stall occurs when the pipeline cannot proceed with the next
instruction due to hazards (data, structural, or control).
39
Causes:
1. Data Hazards: When an instruction depends on the result of a previous one.
2. Structural Hazards: Resource conflicts where multiple instructions need the
same hardware simultaneously.
3. Control Hazards: Branches or jumps alter the flow of instructions, requiring
pipeline pauses.
Impact: Stalls reduce the instruction throughput and overall performance by delaying
execution.
40
Chapter 6: Input/Output (I/O) Systems and Storage Systems
Definition: Input/Output (I/O) refers to communication between a computer and the external
environment, including peripherals like keyboards, monitors, storage devices, and network
interfaces.
I/O Techniques:
1. Programmed I/O:
o CPU directly controls data transfer by repeatedly checking the device status
(polling).
o Downside: Inefficient as it occupies the CPU, wasting processing time.
2. Interrupt-Driven I/O:
o Devices send interrupts to notify the CPU when ready for data transfer.
o Advantage: Reduces CPU idle time, allowing it to perform other tasks.
3. Direct Memory Access (DMA):
o Enables devices to transfer data directly to/from memory without CPU
involvement.
o Benefit: Efficient for large data transfers, minimizing CPU overhead.
4. Memory-Mapped I/O:
o I/O devices use the same address space as memory, simplifying access and
improving performance.
I/O Ports: Physical connections between the CPU and I/O devices.
I/O Controllers: Handle communication, buffering, and data transfer between CPU and
devices.
Interfaces:
o Parallel: Transfers multiple bits simultaneously (e.g., USB, IDE).
o Serial: Transfers bits one at a time (e.g., RS-232, USB).
o Network: Connects to networks for communication (e.g., Ethernet).
41
Key Performance Considerations:
1. Throughput: Maximizing the rate of data transfer between I/O devices and the system.
2. Latency: Minimizing delay between I/O request and data transfer.
3. Efficiency: Reducing CPU involvement to optimize performance.
4. Scalability: Supporting additional devices as needed.
5. Reliability: Ensuring error-free data transfer.
6. Compatibility: Supporting a wide range of devices and interfaces.
I/O Devices:
Definition: I/O (Input/Output) devices are hardware components that enable a computer
to interact with the external environment by receiving input or sending output.
1. Storage Devices:
o Function: Used for storing data either permanently or temporarily.
o Examples:
Hard Disk Drives (HDDs): Magnetic storage for large, long-term data.
Solid-State Drives (SSDs): Flash-based storage, faster and more durable
than HDDs.
Optical Drives: Use lasers to read/write data on CDs, DVDs, and Blu-ray
discs.
USB Flash Drives: Portable flash memory for temporary or permanent
storage.
o Characteristics:
Storage Capacity: Typically measured in GB or TB.
Read/Write Speeds: Determines how fast data can be accessed or stored.
Durability: Especially significant for SSDs due to the absence of moving
parts.
2. Communication Devices:
o Function: Enable data exchange between computers or networks.
o Examples:
Network Interface Cards (NICs): Connect computers to networks via
Ethernet or Wi-Fi.
Modems: Convert digital data to analog for transmission (e.g., DSL,
cable).
Routers: Direct data packets between networks, enabling internet and
local network communication.
Bluetooth Adapters: Facilitate short-range wireless communication
between devices.
42
o Characteristics:
Data Transfer Rate: Speed of data exchange, measured in Mbps or Gbps.
Range: Important for wireless communication devices.
Supported Protocols: Standards like Ethernet, Wi-Fi.
1. Speed: Transfer rates are crucial for both storage and communication devices.
2. Reliability: Ensuring accurate, error-free data transfer.
3. Capacity: Important for storage devices (measured in GB/TB).
4. Compatibility: Ensuring devices work with existing systems or networks.
Definition:
Purpose:
Allows the CPU to respond to important events (e.g., I/O completion, errors) without
constant polling, enhancing efficiency.
Types of Interrupts:
1. Hardware Interrupts:
o Generated by external devices (e.g., keyboard, mouse, network cards).
2. Software Interrupts:
o Triggered by software instructions (e.g., system calls, debugging).
1. Interrupt Detection:
o CPU detects the interrupt signal.
2. Interrupt Acknowledgement:
o CPU acknowledges the interrupt and prepares to handle it.
3. Interrupt Vector:
o CPU uses the interrupt vector table to locate the address of the Interrupt Service
Routine (ISR).
4. Context Switching:
o CPU saves its current state (e.g., registers, program counter) to a stack.
43
5. ISR Execution:
o CPU executes the ISR to handle the event.
6. Context Restoration:
o CPU restores the saved state from the stack after ISR completion.
7. Return to Main Program:
o CPU resumes its original task.
Types of Interrupts:
Maskable Interrupts:
o Can be ignored or delayed based on priority.
Non-Maskable Interrupts (NMI):
o Cannot be ignored; used for critical errors (e.g., hardware malfunctions).
Interrupt Prioritization:
Interrupt Masks:
o Control enabling or disabling of interrupts to manage their order.
Interrupt Priority Levels:
o Assign priority levels to handle critical interrupts first.
Interrupt Controllers:
Function:
o Manage detection, prioritization, and forwarding of interrupts to the CPU.
o Reduce CPU overhead in handling interrupts.
Key Considerations:
Definition:
DMA allows hardware devices to transfer data directly to or from memory without
involving the CPU, improving data transfer efficiency.
44
Purpose:
Offloads the CPU from managing data transfers, allowing it to focus on other tasks,
enhancing overall system performance.
1. DMA Controller:
o Specialized hardware that manages the entire DMA transfer process between
memory and I/O devices.
2. DMA Request:
o The I/O device signals the DMA controller when it is ready for data transfer.
3. DMA Acknowledgement:
o DMA controller gains control of the system bus, signaling readiness to transfer
data.
4. Data Transfer:
o Data moves directly between memory and the I/O device, bypassing the CPU to
minimize overhead.
5. Completion:
o Once the transfer is done, the DMA controller sends an interrupt to notify the
CPU that the task is complete.
1. Burst Mode:
o Transfers data in large bursts, during which the DMA controller controls the bus
exclusively.
2. Cycle Stealing:
o DMA controller temporarily takes control of the bus, allowing the CPU to use the
bus between DMA transfers.
3. Transparent Mode:
o DMA transfers occur only when the CPU is not using the bus, minimizing any
performance disruption.
Benefits of DMA:
Key Considerations:
45
4. Performance: Maximize data transfer rates while minimizing CPU involvement.
5. Reliability: Ensure accurate and error-free data transfers.
DMA Controllers:
Handle various features like burst transfers, priority handling, and chained transfers.
Play a critical role in efficiently managing and optimizing data transfers.
I/O programming involves managing communication between the CPU and external devices
through various methods, such as I/O instructions, interrupts, and DMA (Direct Memory
Access). Key techniques include:
1. I/O Instructions:
The CPU directly communicates with I/O devices by reading or writing data to designated I/O
ports or memory locations.
2. Interrupts:
Interrupts:
o Signals sent by hardware or software to the CPU, prompting the execution of an
Interrupt Service Routine (ISR).
Types of Interrupts:
o Hardware Interrupts: Triggered by external devices (e.g., keyboard, disk) when
they require CPU attention.
o Software Interrupts: Generated by programs, often for system calls or handling
exceptions.
Interrupt Handling:
o The CPU temporarily stops its current task, executes the ISR, and then resumes its
previous task.
o Interrupt Vector Table (IVT): A table that links interrupt numbers to the
corresponding ISR addresses.
46
3. Polling vs. Interrupt-Driven I/O:
Polling:
o CPU continuously checks the status of an I/O device for readiness.
o Simple but inefficient, especially for slower devices.
Interrupt-Driven I/O:
o CPU performs other tasks while waiting for I/O devices to signal their readiness
via interrupts.
o More efficient for managing multiple devices or multitasking.
A dedicated hardware controller that transfers data directly between memory and I/O
devices, bypassing the CPU.
Enhances efficiency by freeing the CPU to perform other tasks, especially for high-speed
data transfers.
Key Considerations:
Performance: Interrupt-driven I/O and DMA offer better efficiency compared to polling,
particularly in systems with multiple devices or high-speed data transfers.
Complexity: Interrupt handling requires careful management of synchronization and
error handling, making it more complex than polling.
Device Compatibility: I/O technique selection depends on the specific device's
capabilities.
Operating System Support: OS provides abstractions like device drivers and file
systems to manage I/O efficiently.
Technology: Mechanical storage using spinning magnetic platters with read/write heads
to access data.
Speed: Slower access due to mechanical parts; typical speeds around 100 MB/s.
Capacity & Cost: Offers large capacities (in terabytes) at lower cost per gigabyte,
making it cost-effective.
Durability: Prone to mechanical failures (e.g., head crashes) due to moving parts.
Data Access: Sequential, meaning slower retrieval times.
Use Case: Suitable for bulk data storage, backups, and media files where speed is not
critical.
47
2. Solid State Drive (SSD):
Technology: Uses NAND flash memory (no moving parts) for electronic data storage.
Speed: Significantly faster than HDDs, with speeds ranging from 500 MB/s to 3,500
MB/s, depending on the interface (SATA or NVMe).
Capacity & Cost: More expensive per gigabyte but decreasing in price; typically
available in smaller capacities compared to HDDs.
Durability: More durable as there are no moving parts, though write cycles are limited,
which may cause degradation over time.
Data Access: Random access, allowing faster data retrieval.
Use Case: Ideal for operating systems, applications, and fast-access data.
Technology: Combines multiple HDDs or SSDs into a single logical unit to improve
performance, data redundancy, or both.
Key RAID Levels:
o RAID 0 (Striping): Improves performance by splitting data across multiple
drives but offers no redundancy. Data loss occurs if one drive fails.
o RAID 1 (Mirroring): Duplicates data across two or more drives, providing data
redundancy but no performance boost. Higher cost due to duplicate storage.
o RAID 5 (Striping with Parity): Balances performance and redundancy by
distributing data and parity across drives. However, write performance can be
slower.
o RAID 6 (Dual Parity): Similar to RAID 5 but with extra parity for greater fault
tolerance, though slower write speeds.
o RAID 10 (Combination of RAID 1 & 0): Combines mirroring and striping,
offering both high performance and redundancy.
Use Case: RAID is used in systems that require high availability, data redundancy, and
performance, such as servers and data storage arrays.
Key Considerations:
Performance: SSDs and RAID (depending on configuration) offer faster data access
compared to HDDs.
Capacity: HDDs typically provide more storage at a lower cost per gigabyte.
Reliability: RAID configurations improve fault tolerance and data redundancy.
Cost: HDDs are cheaper for bulk storage, while SSDs offer better performance but are
more expensive per terabyte.
48
Chapter 7: Microprocessor Basics
1. Microprocessor:
2. Microcontroller:
Definition: A compact, integrated system designed for specific control tasks, combining
a CPU, memory (RAM, ROM), and I/O ports on a single chip.
Components: Includes CPU, RAM, ROM, timers, and I/O ports, all embedded on the
chip.
Memory: On-chip memory and I/O peripherals reduce the need for external components.
Power Consumption: Low, making it ideal for embedded, battery-powered systems.
Applications: Designed for embedded systems used in devices like appliances,
automotive systems, robotics, and IoT devices.
Specialization: Optimized for specific control-oriented tasks, offering lower processing
power but higher efficiency and integration.
49
Key Differences:
The microprocessor architecture includes the ALU for computations, the Control Unit for
instruction handling, registers for temporary data storage, and buses for data transfer. Its
performance is influenced by the clock speed and memory organization. The fundamental
instruction cycle—fetch, decode, execute, and store—remains central to microprocessor
operation despite technological advancements.
3. Registers:
Function: Small, high-speed storage locations within the CPU used for temporary data
storage.
Common Registers:
o Accumulator (ACC): Stores results of ALU operations.
o Program Counter (PC): Holds the address of the next instruction.
o Instruction Register (IR): Holds the current instruction being executed.
o General-Purpose Registers: Used for temporary data storage during instruction
execution.
50
4. Clock:
5. Bus System:
Types:
o Data Bus: Transfers data between the microprocessor and other components.
o Address Bus: Carries memory addresses to locate data.
o Control Bus: Sends control signals to manage CPU operations and coordinate
with peripherals.
6. Memory:
Cache: High-speed memory inside or near the CPU for frequently used data and
instructions.
RAM (Random Access Memory): External memory used during execution for data and
instructions.
Function: Manages communication between the CPU and external devices (e.g.,
memory, peripherals).
Role: Provides a standardized method for CPU interaction with the external world.
Instruction Cycle:
Fetch: Retrieves the instruction from memory and stores it in the instruction register.
Decode: Interprets the instruction to determine the required operation and operands.
Execute: Performs the specified operation using the ALU or other components.
Store: Saves the result of the operation in a register or memory location.
51
1. Arithmetic Logic Unit (ALU)
3. Registers
Function: Small, high-speed storage locations within the CPU for temporary data storage
during instruction execution.
Types:
o General-purpose Registers: For intermediate data storage (e.g., AX, BX).
o Special-purpose Registers:
Accumulator: Stores results of arithmetic operations.
Program Counter (PC): Tracks the address of the next instruction.
Instruction Register (IR): Holds the current instruction.
Status Registers: Hold flags or status indicators.
Operation: Data is loaded from memory or ALU, and results are stored before further
processing or moving to memory.
4. Buses
Function: Electrical pathways for communication between CPU components and other
system parts.
Types:
o Data Bus: Transfers data between CPU,
memory, and peripherals.
o Address Bus: Carries addresses to/from
which data is read or written.
o Control Bus: Carries control signals for
coordinating operations (e.g., read/write
signals, interrupts).
52
Chapter 8: Microprocessor Programming
It is specific to a computer architecture (e.g., x86, ARM), providing direct control over hardware.
Key Characteristics:
Basic Concepts:
Registers: Special-purpose memory locations within the CPU used for temporary data
storage.
Instructions: Basic operations the processor performs, such as arithmetic, logical
operations, and data movement.
Addressing Modes: Methods to specify data locations in memory.
Labels: Symbolic names representing memory addresses for easier reference.
Directives: Instructions to the assembler to control the assembly process or define data.
Common Uses:
53
Applications:
Embedded systems.
Writing device drivers.
Performance-critical applications.
Drawbacks:
Code snippet
; Example for x86 assembly (NASM syntax)
section .text
global _start
_start:
mov eax, 5 ; first number
mov ebx, 3 ; second number
add eax, ebx ; add the numbers
; ... do something with the result in eax ...
mov eax, 1 ; system call for exit
int 0x80
section .data
section .text
global _start
54
_start:
mov [result], al
syscall
Explanation:
mov al, [num1]: Load the value of num1 into the AL register.
add al, [num2]: Add the value of num2 to AL.
mov [result], al: Store the result of the addition in the result variable.
The program ends with a system call to exit (eax = 60 is the exit system call).
55
Write short notes on Instruction sets and their implementation.
The ISA defines the interface between the CPU and the computer system, including the
instruction set, addressing modes, register set, and memory organization.
Example:
ADD R1, R2, R3: Adds the contents of registers R2 and R3, storing the result in R1.
o Fetch: Retrieve the instruction.
o Decode: Identify the operation as addition and the registers involved.
o Fetch Operands: Read the values from R2 and R3.
o Execute: Perform the addition.
o Store: Save the result in R1.
56
5. Factors Affecting Instruction Set Design:
6. Categories of Instructions:
Data Movement: Transfer data between registers, memory, and I/O (e.g., MOV, LOAD,
STORE).
Arithmetic and Logical: Perform operations like addition, subtraction, AND, OR (e.g.,
ADD, SUB, AND, OR).
Control Flow: Direct the program flow (e.g., JUMP, CALL, RETURN).
I/O: Handle input and output with external devices (e.g., IN, OUT).
Performance: The design of the instruction set impacts the overall speed and efficiency
of the CPU.
Compatibility: Determines software portability across different processors.
57
Chapter 9: Microprocessor Interfacing
Write short notes on Bus architecture (address bus, data bus, control bus)
Address Bus: Unidirectional, sends memory addresses.
Data Bus: Bidirectional, transfers data.
A bus is a shared communication channel that connects the CPU, memory, and I/O devices. It
enables data transfer and coordination between different parts of a computer system.
2. Address Bus:
Function: Carries memory addresses of data or instructions the CPU wants to access.
Unidirectional: Data flows only from the CPU to memory or I/O devices.
Width: Determines the maximum addressable memory. For example, a 32-bit address
bus can address up to 4 GB of memory.
3. Data Bus:
Function: Transfers actual data between the CPU, memory, and I/O devices.
Bidirectional: Data can flow both to and from the CPU.
58
Width: Determines the amount of data transferred in one cycle. A 64-bit data bus can
move 8 bytes of data per cycle, improving performance.
4. Control Bus:
Function: Carries control signals to coordinate operations between the CPU and other
components.
Signals Include:
o Read/Write (R/W): Indicates if data is being read from or written to memory or
devices.
o Interrupt Requests (IRQ): Signals from I/O devices to alert the CPU.
o Clock Signal: Synchronizes operations across the system.
Bidirectional: Control signals can be sent both to and from the CPU and other
components.
5. Working Together:
1. Address Decoding:
59
2. Memory Mapping:
Memory-mapped I/O: Treats I/O devices as memory locations, allowing the CPU to
access them using memory instructions.
Isolated I/O: Uses separate instructions for I/O devices, keeping I/O and memory
operations distinct.
Asynchronous Memory: Works independently of the CPU clock, relies on signals like
"ready" or "wait" for data transfer.
Synchronous Memory: Operates in sync with the CPU clock, ensuring consistent timing
for memory access, improving speed.
Matching Bus Width: Ensures that the width of the memory data bus matches the CPU
data bus for efficient transfer.
Multiplexed Bus: Combines address and data buses to reduce the number of pins, but
requires additional control circuitry.
Purpose: Ensures that only the selected memory chip responds to a CPU request by using
a combination of address lines and control signals.
6. Wait States:
Purpose: Introduced when memory is slower than the CPU, forcing the CPU to wait for
memory to respond and preventing timing mismatches.
Additional Techniques:
60
Purpose: Allows data transfer between memory and I/O devices without involving the
CPU, reducing its overhead.
Process: The DMA controller takes control of the bus, transfers data, and signals the
CPU when done.
Advantages: Improved performance, efficient handling of large data transfers.
8. Burst Mode:
9. Cache Memory:
Purpose: Reduces memory access time by storing frequently accessed data closer to the
CPU.
Types: L1, L2, L3 caches.
Advantages: Improved performance and responsiveness due to reduced memory latency.
System Performance Requirements: Techniques like DMA and burst mode are ideal
for high-performance applications.
Hardware Architecture: The type of memory and devices influences the interfacing
technique.
Software Compatibility: Some techniques work better with specific operating systems
and programming environments.
61
Common I/O Interfacing Techniques
1. Memory-Mapped I/O:
o Description: Treats I/O devices as part of the memory address space.
o Implementation:
Same memory addressing scheme for both memory and I/O devices.
Requires a separate decoder to differentiate between memory and I/O
addresses.
o Advantages:
Simple implementation.
Efficient for devices with slower data rates.
o Disadvantages:
Consumes memory address space.
Less flexible for more complex devices.
62
3. Interrupt-Driven I/O:
o Description: The CPU performs other tasks while waiting for I/O devices to
signal when they are ready.
o Implementation:
I/O devices generate interrupts when ready to transfer data.
The CPU responds by jumping to an Interrupt Service Routine (ISR) to
handle the request.
o Advantages:
Increases system efficiency by allowing concurrent processing.
o Disadvantages:
Requires careful programming to prevent race conditions and deadlocks.
63
4. Direct Memory Access (DMA):
o Description: Offloads data transfer to a specialized DMA controller, bypassing
the CPU.
o Implementation:
The DMA controller transfers data directly between I/O devices and
memory.
o Advantages:
Improves system performance, especially for large data transfers.
Frees up CPU resources for other tasks.
o Disadvantages:
Requires additional hardware (DMA controller).
More complex to implement.
64
5. Programmed I/O (Polling):
o Description: The CPU continuously checks if the I/O device is ready for data
transfer.
o Implementation:
The processor polls the device's status, waiting for it to be ready.
o Advantages:
Simple and straightforward to implement.
o Disadvantages:
Inefficient as it wastes CPU cycles by waiting for the I/O device.
65
SIMD vs. MIMD
SIMD: Single instruction on multiple data (data parallelism); suited for fine-grained parallel
tasks like image processing.
MIMD: Multiple instructions on multiple data (task parallelism); suited for coarse-grained
parallel tasks like general-purpose computing.
66
Write short notes on Vector processors and array processors
Key Differences:
Vector Processors: Optimized for vector operations on contiguous data, offering simpler
programming but limited flexibility for non-vector tasks.
Array Processors: Handle general parallel computations with scalable architecture, but with
more complex programming and potential communication overhead
Vector Processors
Array Processors
Concept: Composed of multiple processing elements (PEs) that operate in parallel, capable of
executing multiple instructions on different data elements, supporting both SIMD and MIMD
architectures.
Characteristics:
o Array-like arrangement of PEs.
o Interconnection network for communication between PEs.
o Local memory for each PE and a control unit to coordinate operations.
Use Cases: Suitable for high computational throughput tasks, such as real-time simulations,
signal processing, and large-scale scientific computations.
Advantages:
o Scalability and flexibility for varied applications.
o Fault tolerance due to independent PEs.
67
o High-speed data processing due to parallel execution.
Disadvantages:
o Complex programming and communication overhead between PEs.
o Higher cost and energy consumption.
68
Chapter 10: Advanced Microprocessor Concepts
69