Input-Output Organization and Bus Architectures
System Bus Architecture and Accessing I/O Devices
Bus Structural Organization:
Computer systems connect the processor, main memory, and multiple Input/Output (I/O) devices using a shared set of electrical signal pathways termed a system bus.
The system bus consists of three functional groups of signal lines:
Address Lines: Specify the unique destination address or location (memory address or I/O register) that the processor intends to access.
Data Lines: Bidirectional pathways that transmit binary data blocks between the processor, main memory, and I/O peripheral interfaces.
Control Lines: Signal lines carrying operational signals, command functions, and timing signals (such as Read and Write control lines).

Addressing Mechanism for I/O Access:
Each peripheral interface connected to the bus is assigned a unique hardware address.
To initiate communication with a target I/O device, the processor places the binary address corresponding to that device onto the address lines.
Every device interface connected to the bus constantly monitors the address lines through internal decoding logic.
Only the specific device whose assigned address matches the decoded binary address pattern responds to the bus transaction.
The processor subsequently asserts appropriate control line signals (e.g., Read or Write commands), and actual data transfer proceeds via the bus data lines.
Memory Addressing Schemes: Memory-Mapped I/O vs. Isolated I/O
Address Space Definition:
An address space represents the total set or numerical range of distinct addresses that a processor can generate to access memory locations or peripheral interface registers.
For a system utilizing a 16-bit address line configuration, the addressable range spans from hex address
to.
Memory-Mapped I/O Architecture:
Memory locations and I/O interface registers share a single, unified address space.
Each I/O register is assigned an explicit numerical address within the system memory map.
Machine instructions capable of accessing memory locations (such as
MOVE,LOAD, orSTORE) are used directly to read from or write to peripheral device registers.Eliminates the need for specialized assembly instructions dedicated strictly to peripheral transfer, resulting in streamlined software instruction set architectures (ISAs).

Isolated I/O / Port-Mapped I/O Architecture:
Main memory and peripheral I/O devices utilize separate, logically distinct address spaces.
Requires specialized assembly language instructions (such as
INandOUT) dedicated exclusively to exchanging data between processor registers and I/O ports.Peripheral I/O address ranges are typically smaller than memory address spaces, allowing devices to require fewer physical address lines.

Sharing Address Lines:
Dedicated physical address lines for I/O and memory are not required; systems share identical physical address lines between both spaces.
The processor multiplexes the address bus and distinguishes between a memory transaction and an I/O transaction by asserting a dedicated control signal line (e.g., Memory/ control signal).
I/O Interface Architecture and Operational Mechanism
Functional Role of an I/O Interface Circuit:
Acts as an intermediate hardware buffer and control interface bridging the high-speed system bus and lower-speed external peripherals.
Consists of four fundamental components:
Address Decoder: Decodes signals arriving from system address lines and enables internal interface logic when the address matches the assigned peripheral address.
Data Register: Temporarily stores data payload during transfers between processor and peripheral.
Input transfer flow: Peripheral Device Data Register Processor.
Output transfer flow: Processor Data Register Peripheral Device.
Status Register: Contains operational flags and status bits indicating device states (such as Device Ready, Device Busy, or Data Available).
Control Circuits: Recieves input signals from bus control lines, generates precise internal control commands, and coordinates operational timing across decoders, registers, and external peripheral hardware.

Sequential Operational Workflow of I/O Transfers:
The processor outputs the assigned peripheral interface address onto the address bus.
The address decoder within the interface circuit decodes the bit pattern and enables the target interface circuit registers.
The processor issues operational commands via the bus control lines.
Data payloads are placed onto the data lines and stored temporarily within data buffer registers.
The status register updates status flags to reflect current device readiness or completion state.
Internal control circuits manage timing and execution of peripheral operations.

Data Transfer Synchronization and Program-Controlled I/O
Synchronization Requirements:
High-speed central processors operate significantly faster than external mechanical or electronic I/O hardware.
A keyboard generates character data sporadically based on manual user keystrokes, during which the processor could execute millions of instructions.
Hardware mechanisms must coordinate timing differences to prevent lost data during slow device processing.
Program-Controlled I/O and Polling:
In program-controlled I/O, software instructions continuously query and evaluate peripheral status flags to execute transfers.
Polling Procedure:
Processor sends an initial operation command to the peripheral.
Processor enters an explicit execution loop, continually reading the device status register.
The processor evaluates status flags until the device signals completion or readiness.
Upon confirmation of readiness, the processor executes the actual memory or register data movement.
Inherent Limitation:
Polling wastes CPU instruction cycles inside idle wait loops.
While polling slow devices, processor computation capacity remains underutilized.
Interrupt-Driven I/O Architecture
Concept and Mechanism:
Eliminates idle processor polling by shifting response initiative to external hardware.
Instead of continuous processor querying, an I/O peripheral independently issues an asynchronous hardware electrical signal—termed an interrupt request—when requiring CPU attention.
The interrupt signal travels along dedicated control lines called Interrupt-Request lines ().
Allows the processor to execute unrelated task routines concurrently, pausing execution only when alerted by peripheral hardware.
Interrupt Execution Sequence and Stack Maintenance:
Assume the processor is executing an instruction located at memory address when an interrupt request is detected:
The processor completes the execution phase of instruction .
Execution transfers to a dedicated service program called an Interrupt Service Routine (ISR).
Prior to branching to the ISR, the processor automatically preserves program context by pushing the return address—the updated Program Counter (PC) value pointing to address —onto the system stack.
Execution branches to the starting location of the designated ISR.
At the conclusion of the ISR, a specialized
Return-from-Interruptinstruction executes, popping the saved PC address () off the stack and resuming original execution.

Subroutine vs. Interrupt Service Routine (ISR) Structural Comparison:
Functional Purpose:
Subroutine: Executes a task explicitly requested by the calling main application software.
ISR: Services asynchronous peripheral hardware requests and may be unrelated to the suspended application thread.
Control Transfer Trigger:
Subroutine: Explicitly invoked via software branch/call instructions (e.g.,
CALL,JSR).ISR: Automatically hardware-invoked when an external electrical interrupt line is asserted.
Program Relationship:
Subroutine: Shares logical context and scope within the user execution program.
ISR: Belongs to system-level operating system code or lower-level device drivers.
Context Preservation Requirements:
Subroutine: Typically requires saving only the return address on the stack (alongside user-specified registers).
ISR: Must thoroughly preserve the complete processor state, including the Program Counter (PC), Processor Status Register (PSR) condition flags, and modified registers.
Return Mechanism:
Subroutine: Executes a software return instruction (
RET), returning directly to the caller line.ISR: Executes a specialized return-from-interrupt instruction, completely restoring the preserved hardware processor status register before returning control.
Interrupt Handling, Control, and Priority Structures
Interrupt Latency:
Defined as the total elapsed time delay measured from the precise moment an external hardware interrupt request is asserted to the initiation of the first instruction within the Interrupt Service Routine (ISR).
\n \text{Interrupt Latency} = \text{Time}(\text{Interrupt Request Asserted}) \rightarrow \text{Time}(\text{ISR Execution Starts})\n
Latency is directly affected by context saving operations; saving extensive register files requires memory bus cycles, increasing latency.
To minimize latency, modern processor hardware automatically saves only minimal context registers (PC and PSR) before branching, delegating additional register saving to software instructions at the start of the ISR.
Interrupt Acknowledgment Protocols:
Method 1: Dedicated Hardware Signal:
Processors issue a hardware Interrupt Acknowledge () signal along control lines.
Received by interrupting peripheral interface, confirming request recognition.
Method 2: Implicit Bus Data Transfer:
Acknowledgment is accomplished without dedicated signals.
Accessing or reading data registers during interrupt processing implicitly signals recognition to peripheral hardware logic.
Enabling and Disabling Interrupts:
Uncontrolled nested interrupts can destabilize execution during critical state processing inside an ISR.
Systems implement machine instructions to manage state acceptance:
Interrupt-Disable Instruction: Blocks the processor from accepting incoming software or hardware interrupt requests.
Interrupt-Enable Instruction: Re-arms processing logic to evaluate incoming interrupt requests.
ISR Control Flow Protocol:
Entry phase: Execute
Interrupt-Disableas the first instruction to prevent concurrent interruption by identical peripherals.Processing phase: Execute core peripheral handling routines.
Exit phase: Execute
Interrupt-Enableas the final instruction before returning.
Interrupt-Enable (IE) Bit in Peripheral Interfaces:
Peripheral interface registers contain a dedicated software-configurable bit termed the Interrupt-Enable (IE) bit.
IE Bit Value | Functional Meaning |
|---|---|
0 | Device is explicitly prohibited from generating hardware interrupt requests. |
1 | Device is allowed to assert hardware interrupt request lines ( Request permitted). |
Multi-Level Control Logic:
Control operates across two distinct hierarchy levels:
Peripheral Device Interface Level: Regulated by internal interface
IEbit settings.Processor Core Level: Regulated by processor status flags and programmed priority bit masks.
Privilege Levels and Protected States:
Current execution priority is stored within designated bits in the Processor Status Register (PSR).
Instructions that alter execution priority or modify PSR values are privileged instructions.
Privileged instructions execute exclusively when the system operates in Supervisor Mode (Kernel Mode) and cannot be executed by user-level code operating in User Mode.
Attempting to execute privileged priority instructions while running in User Mode triggers a hardware exception termed a Privilege Exception, transferring execution directly to kernel trap handlers.
Hardware Interrupt Schemes and Identification Methods
Identification of Interrupting Peripherals:
Software Polling Scheme:
Peripherals share a single control line connected to the processor.
When an interrupt occurs, individual interface status registers set an internal IRQ (Interrupt Request) status flag bit to
1().The master ISR executes a sequential polling routine, sequentially reading peripheral status registers.
Device priority is defined by polling sequence order; the first device evaluated with is serviced.
Limitation: Software polling incurs high overhead when many peripherals are attached.
Vectored Interrupt Scheme:
The interrupting peripheral identifies itself directly to processor hardware by writing a 4-to-8 bit binary identification code—termed an Interrupt Vector—onto data lines upon receiving acknowledgment.
The processor uses the vector as an index offset into a system memory structure called the Interrupt Vector Table (IVT).
The IVT stores absolute memory entry pointers to target ISR routines, enabling direct branching without polling delays.
Hardware Priority Arbitration Architectures:
1. Multiple Independent Priority Lines:
Every individual peripheral connects to dedicated physical Interrupt Request () and Interrupt Acknowledge () bus lines.
Requests route directly to an internal hardware priority arbitration circuit within the CPU core, evaluating requests against current PSR levels.

2. Daisy Chain Scheme:
Peripherals share a common line, but the acknowledgment line is connected serially from device to device in a chain.
Upon receiving , the processor asserts to Device 1.
If Device 1 requested service, it captures and places its vector on the bus. If Device 1 did not request service, it passes down to Device 2.
Physical proximity to the processor defines hardware priority: electrically closer devices hold higher priority.

3. Hybrid Combination Scheme:
Combines independent priority levels with daisy chain lines.
Peripherals are organized into discrete priority groups.
Each group shares a unique priority line, while individual peripherals within a single group are daisy-chained along that group's line.

System Exceptions
Definition:
An exception refers to any internal or external event that interrupts standard sequential application execution, requiring control transfer to specialized software handlers.
Taxonomy of System Exceptions:
I/O Interrupt Requests: Asynchronous external hardware notifications generated by peripheral devices.
Bus and Runtime Hardware Errors: Internal execution faults, such as memory parity errors, bus timeouts, or division-by-zero operations.
Software Traps and Debugging Functions: Execution traps utilized by software debuggers to establish breakpoints and monitor state transitions.
Privilege Exceptions: Security violations triggered when user-mode applications attempt executing protected supervisor instructions.
Direct Memory Access (DMA) Operations
DMA Principles:
Direct Memory Access (DMA) enables high-speed peripheral devices to transfer data blocks directly to and from main memory over the system bus without processor intervention.
Managed by specialized controller hardware termed a DMA Controller (DMAC).
Operational Functions of a DMA Controller:
Generates sequential physical memory addresses.
Generates required read/write bus control signals.
Manages data payload transfer between memory and peripherals.
Automatically increments memory address pointers following each transferred word.
Maintains internal loop counters tracking remaining word block counts.
DMA Initialization Sequence:
The processor writes initialization parameters to internal DMAC registers:
Target Memory Starting Address.
Total Word Count / Block Length.
Transfer Direction (Peripheral-to-Memory or Memory-to-Peripheral).
The processor releases the system bus to continue executing independent computations.
The DMAC manages block data movement autonomously.
Upon transferring the complete data block count, the DMAC asserts a hardware interrupt line to notify the processor of completion.
DMA Bus Operating Modes:
Cycle Stealing Mode:
DMAC interweaves single-word memory cycles between processor instruction memory cycles.
The DMAC temporarily "steals" individual bus cycles, relinquishing control back to the processor between transfers.
Keeps the processor active concurrently during large transfers.
Block / Burst Mode:
DMAC acquires exclusive, continuous control of the system bus for the complete block transfer.
The processor remains suspended from accessing the memory bus until the entire burst completes.
Mode Comparison Feature | Cycle Stealing Mode | Block / Burst Mode |
|---|---|---|
Bus Control Duration | Takes bus for single individual word transfers | Retains exclusive bus control for complete block |
Bus Access Pattern | Processor and DMAC access bus alternately | DMAC locks bus exclusively throughout transfer |
Processor Execution | Processor continues execution between transfers | Processor waits for complete burst finish |
Application Suitability | Maintains concurrent processor activity | Optimized for high-speed, continuous block transfers |
Multi-Channel DMA Architecture:
Advanced DMACs integrate multiple independent transfer channels (e.g., Disk/DMA controllers driving multiple drives simultaneously by duplicating memory address registers, word counters, and control registers per channel).

Bus Arbitration Mechanisms: Centralized and Distributed
Bus Arbitration Principles:
System buses are shared communication links that can be driven by only one master device at any given instant to prevent electrical signal corruption (bus contention).
The active controlling device authorized to initiate transfers is designated as the Bus Master.
Bus Arbitration is the formal decision process that selects which requesting master device acquires bus control when multiple devices request access simultaneously.
Three-Step Arbitration Sequence:
Request: A device asserts a request line indicating a requirement for bus ownership.
Arbitration: The system evaluates relative priorities among all active requests.
Grant: Control logic asserts a bus grant line, conferring master status to the selected device.
Centralized Bus Arbitration:
A single dedicated hardware unit—the Central Bus Arbiter (frequently embedded inside the processor core)—manages all bus allocations.
Control Signals:
Bus Request (): Shared active-low line asserted by devices requesting master status.
Bus Grant (, ): Serial daisy-chained grant line routed through candidate controllers.
Bus Busy (): Active-low line driven to
0by the active bus master to signal that the bus is occupied.

Centralized Arbitration Operational Steps:
DMA Controller 2 asserts .
The central processor detects and asserts .
propagates along the daisy chain. Intermediate controllers not asserting requests propagate the signal downstream ().
Upon receiving , DMA Controller 2 detects (bus free), assumes bus mastership, and sets (bus busy).
After completing its transfers, DMA Controller 2 releases to
1, returning mastership to the processor.

Distributed Bus Arbitration:
Operates without a central arbiter; all candidate master devices participate in decentralized hardware logic to determine bus ownership.
Offers higher system fault tolerance by eliminating single points of failure.
Bus Line Allocation:
4 Shared Arbitration Lines ( to ): Driven by open-collector outputs to transmit device ID codes.
1 Start-Arbitration Line (): Shared line asserted to trigger an arbitration cycle.
Device Designation | Assigned Unique 4-bit Binary ID |
|---|---|
Device 1 |
|
Device 2 |
|
Device 3 |
|
Device 4 |
|
Distributed Arbitration Mechanics:
Devices desiring bus access assert and drive their unique 4-bit ID onto lines .
Open-collector hardware connections perform a logical OR operation on all asserted bit patterns simultaneously.
Each participating device compares its internal ID bit pattern against the combined pattern appearing on the arbitration lines starting from the most significant bit (MSB).
If a device detects a higher-priority binary bit asserted on any line where its own ID bit is
0, it deactivates its lower-order driver outputs and withdraws from competition.The device possessing the highest numerical ID survives the comparison, wins arbitration, and assumes bus mastership.
