Sie sind auf Seite 1von 175

Faculty of Electrical and Electronic Engineering

Semester II, Session 2014/2015

BEC 30303
Computer Architecture and Organization
Chapter 3:
Input/Output

OUTLINE

Bus structure
Bus operation
Arbitration
Accessing IO devices
Interrupts
Interface circuits
Interconnection standards

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

BUS STRUCTURE

BUS STRUCTURE (1/2)


Processor, main memory, and I/O devices are
interconnected by means of a bus.
Bus provides a communication path for the transfer
of data.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

BUS STRUCTURE (2/2)

Processor
Input
Control
Memory
Datapath

Output

 A bus is a shared communication link


 It uses one set of wires to connect multiple subsystems

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

ADVANTAGES OF BUS
Versatility:
New devices can be added easily
Peripherals can be moved between computer
systems that use the same bus standard
Low Cost:
A single set of wires is shared in multiple ways

Processor

I/O
Device

I/O
Device

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

I/O
Device

Memory

DISADVANTAGES OF BUS
It creates a communication bottleneck:
The bandwidth of that bus can limit the maximum
I/O throughput
The maximum bus speed is largely limited by:
The length of the bus
The number of devices on the bus
The need to support a range of devices with:
Widely varying latencies
Widely varying data transfer rates

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

GENERAL BUS ORGANIZATION


3 functional groups:
Data lines: provide a path for moving data among
system modules. This lines, collectively called data
bus.
Address lines: used to designate the source of
destination of the data on the data bus. The width
of the address bus determines the maximum
possible memory capacity of the system
Control lines: use to control the access to and the
use of the data and address lines. Required size of
the data, when several operand sizes (byte, word,
long word) are possible.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

BUS FUNCTIONAL GROUPS

Address lines
Bus

Data lines
Control lines

Address
decoder

Control
circuits

Data and
status registers

I/O
interface

Input device

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

MASTER/SLAVE STRUCTURE
A bus transaction includes two parts:
Sending the address (master)
Receiving or sending the data (slave)
Master: starts the transaction by sending address
Slave is the one who responds to the address by:
Sending data to the master if the master ask for
data
Receiving data from the master if the master wants
to send data

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

10

MASTER/SLAVE CONNECTION

Master send address


Bus
Master

Data can go either way

Bus
Slave

Bidirectional

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

11

BUS OPERATION

BUS OPERATION
If one component wants to send/receive data to/from
another component, it must:
Obtain the bus i.e. request to use the bus
If devices go randomly then we have choose
with two components trying to send data on the
bus
Transfer the information on the bus once access is
granted
address, data, control

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

13

OUTPUT OPERATION
Output = proc. sending data to the IO devices
Step 1: Request Memory

Control (Memory Read Request)

Processor

Data (Memory Address)

Memory

I/O Device (Disk)


Step 2: Read Memory
Control
Processor

Data

Memory

I/O Device (Disk)


Step 3: Send Data to I/O Device Control (Device Write Request)
Processor
I/O Device (Disk)

Data
(I/O Device Address
and then Data)

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

Memory

14

INPUT OPERATION
Input = proc. receiving data from IO devices
Step 1: Request Memory

Control (Memory Write Request)

Processor

Data (Memory Address)

Memory

I/O Device (Disk)

Step 2: Receive Data


Processor
I/O Device (Disk)

Control (I/O Read Request)


Data
(I/O Device Address
and then Data)

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

Memory

15

ELEMENTS OF BUS DESIGN


Bus Types
Methods of Arbitration
Timing

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

16

BUS TYPES
Dedicated:
bus line is permanently assigned either to one
function or to a physical subset of computer
component
Physical dedication associated with the use of
multiple buses, each bus it is connected with only a
subset of the modules.
Example:
I/O to interconnect all I/O module, then this bus is
connected to the main bus through a kind of
adapter module I / O.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

17

ARBITRATION

ARBITRATION
Why do we need arbitration?
Relate to the bus structure
Who grants requests?
Assign an arbitrator (controlling bus access by the
master)
Arbitration goals:
Prevent more than one bus user at a time
Give all devices a fair chance to access the bus

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

19

ARBITRATION METHODS
Centralized:
Centralized bus arbitration requires hardware
(arbiter) that will grant the bus to one of the
requesting devices. This hardware can be part of
the CPU or it can be a separate device on the
motherboard.
Decentralized:
Decentralized arbitration there isn't an arbiter, so
the IO devices have to decide who goes next. This
makes the devices more complicated, but saves
the expense of having an arbiter (no extra logic).
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

20

ARBITRATION MECHANISM
An IO module may be required to read or write
directly to memory, without sending data to the CPU.
Because at one point is just a unit that will
successfully transmit data through the bus, then take
a few methods of arbitration.
The goal is to assign a device, the CPU or IO
module, acting as master. Then the master can
initiate data transfer (e.g., read or write) by using
other devices, which work as slave for this particular
data exchange.
Example: multiple interrupts using daisy chain, IO
DMA
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

21

IO DEVICES CONNECTION
When I/O devices were organized into a priority
structure, each device had its own interrupt-request
and interrupt-acknowledge line.
When I/O devices were organized in a daisy chain
structure, the devices shared an interrupt-request
line, and the interrupt-acknowledge propagated
through the devices.
A combination of priority structure and daisy chain
scheme can also used.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

22

DAISY CHAIN IO CONNECTION (1/2)

Processor

I NTR

Device 1

Device 2

Device n

INTA

INTR interrupt request


INTA interrupt acknowledge

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

23

DAISY CHAIN IO CONNECTION (2/2)


Devices are connected to form a daisy chain.
Devices share the interrupt-request line, and
interrupt-acknowledge line is connected to form a
daisy chain.
When devices raise an interrupt request, the
interrupt-request line is activated.
The processor in response activates interruptacknowledge.
Received by device 1, if device 1 does not need
service, it passes the signal to device 2.
Device that is electrically closest to the processor has
the highest priority.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

24

DAISY CHAIN WITH PRIORITY (1/2)


IO group 1

Processor

I NTR1

INTA1

Device

Device

Device

Device

IN T R p

INTA p
Priority arbitration
circuit

IO group 2
INTA interrupt acknowledge
INTR interrupt request
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

25

DAISY CHAIN WITH PRIORITY (2/2)


Devices are organized into groups.
Each group is assigned a different priority level.
All the devices within a single group share an
interrupt-request line, and are connected to form a
daisy chain.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

26

DMA (1/2)
Direct Memory Access
A special control unit (called DMA controller) to
transfer a block of data directly between an I/O
device and the main memory, without continuous
intervention by the processor.
DMA controller functions:
For each word, it provides the starting memory
address and all the control signals.
To transfer a block of data, it increments the
memory addresses and keeps track of the number
of transfers.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

27

DMA (2/2)
The processor must initiate the DMA transfer, which
the processor informs the DMA controller of:
Starting memory address
Number of words in the block
Direction of transfer (I/O device to the memory, or
memory to the I/O device)
Informs the processor once transfer is completed
by raising an interrupt signal

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

28

DMA BLOCK DIAGRAM


Main
memory

Processor
System bus

Disk/DMA
controller

Disk

Disk

DMA
controller

Printer

Keyboard

Network
Interface

DMA controller connects a high-speed network to the computer bus.


Disk controller, which controls two disks also has DMA capability. It
provides two DMA channels.
It can perform two independent DMA operations, as if each disk has its
own DMA controller. The registers to store the memory address, word
count and status and control information are duplicated.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

29

DMA OPERATION
DMA devices are given higher priority than the
processor to access the bus.
Among different DMA devices, high priority is given to
high-speed peripherals such as a disk or a graphics
display device.
Processor originates most memory access cycles on
the bus.
DMA controller can be said to steal memory access
cycles from the bus. This interweaving technique is
called as cycle stealing.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

30

DMA BUS ARBITRATION


Processor and DMA controllers have to use the bus
to access the memory.
DMA devices are given higher priority than the
processor to access the bus (e.g. high speed
peripheral disk or graphic display devices)
Bus request to CPU (can I use the bus, please?)
Bus grant from CPU (yes, you can, at the end of
this bus cycle)
Bus grant acknowledge to CPU (thank you. Here I
go!)
Processor and DMA controllers both need to initiate
data transfers on the bus and access main memory.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

31

CENTRALIZED BUS ARBITRATION (1/2)


Single bus arbiter performs the arbitration

Priority arbiter

BG bus grant
BR bus request
BBSY bus busy

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

32

CENTRALIZED BUS ARBITRATION (2/2)


Bus arbiter, the processor or a separate unit
connected to the bus.
DMA controller requests the control of the bus by
asserting the Bus Request (BR) line.
In response, the processor activates the Bus-Grant1
(BG1) line, indicating that the controller may use the
bus when it is free.
BG1 signal is connected to all DMA controllers in a
daisy chain fashion.
BBSY signal is 0, it indicates that the bus is busy.
When BBSY becomes 1, the DMA controller which
asserted BR can acquire control of the bus.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

33

ARBITRATION TIMING DIAGRAM


DMA controller 2
asserts the BR signal.

Time

Processor asserts
the BG1 signal

BR

BG1

BG1 signal propagates


to DMA#2.

BG2

BR bus request

BBSY
Bus
master

BG bus grant
Processor

DMA controller 2

Processor

BSY busy

Processor relinquishes control


of the bus by setting BBSY to 1.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

34

DISTRIBUTED BUS ARBITRATION (1/2)


No central arbiter used
Each device is assigned a 4-bit ID number.
All the devices are connected using 5 lines, 4
arbitration lines to transmit the ID, and one line for
the Start-Arbitration signal.
To request the bus, a device:
Asserts the Start-Arbitration signal.
Places its 4-bit ID number on the arbitration lines.
The pattern that appears on the arbitration lines is
the logical-OR of all the 4-bit device IDs placed on
the arbitration lines.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

35

DISTRIBUTED BUS ARBITRATION (2/2)

ARB - arbitrator

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

36

ARBITRATION PROCESS (1/2)


Each device compares the pattern that appears on
the arbitration lines to its own ID, starting with MSB.
If it detects a difference, it transmits 0s on the
arbitration lines for that and all lower bit positions.
The pattern that appears on the arbitration lines is
the logical-OR of all the 4-bit device IDs placed on
the arbitration lines.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

37

ARBITRATION PROCESS (2/2)


Device A compares its ID 5 with a pattern 0101 to
pattern 0111.
It detects a difference at bit position 0, as a result, it
transmits a pattern 0100 on the arbitration lines.
The pattern that appears on the arbitration lines is the
logical-OR of 0100 and 0110, which is 0110.
This pattern is the same as the device ID of B, and
hence B has won the arbitration.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

38

ARBITRATION ORGANIZATION

Which one if preferred between


centralized and distributed arbitration?

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

39

BUS TIMING
Synchronous
Asynchronous

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

40

SYNCHRONOUS BUS (1/9)


Time
Bus clock

Timing diagram
for master writes
data to slave

Address and
command

Data
t0

Master places the


device address and
command on the bus,
and indicates that
it is a Read operation.

t1

t2

Bus cycle

Addressed slave places


data on the data lines

Master strobes the data


on the data lines into its
input buffer, for a Read
operation.

Master and slave operations are referenced to a clock


(i.e. synchronous to clock)
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

41

SYNCHRONOUS BUS (2/9)


In case of a write operation, the master places the
data on the bus along with the address and
commands at time t0 (reference to positive edge of
the clock).
The slave strobes the data into its input buffer at time
t2 (again, reference to positive edge of the clock).

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

42

SYNCHRONOUS BUS (3/9)


Once the master places the device address and
command on the bus, it takes time (bus delay) for
this information to propagate to the devices (depends
on the physical/electrical char. of the bus)
Also, the devices have to be given enough time to
decode the address and control signals, so that the
addressed slave can place data on the bus.
Width of the pulse t1 - t0 depends on:
Maximum propagation delay between two devices
connected to the bus.
Time taken by all the devices to decode the
address and control signals, so that the addressed
slave can respond at time t1.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

43

SYNCHRONOUS BUS (4/9)


At the end of the clock cycle, at time t2, the master
strobes the data on the data lines into its input buffer
if its a Read operation.
Strobe means to capture the values of the data
and store them into a buffer.
When data are to be loaded into a storage buffer
register, the data should be available for a period
longer than the setup time of the device.
Width of the pulse t2 - t1 should be longer than:
Maximum propagation time of the bus plus
Set up time of the input buffer register of the
master.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

44

SYNCHRONOUS BUS (5/9)


Time

Address &
command
appear on the
bus.

Bus clock

Seen by
master

Data reaches
the master.

t AM

Address and
command
Data

Address &
command reach
the slave.

t DM

Seen by
slave

tAS

Data appears
on the bus.

Address and
command

delay

Data

tDS

Timing diagram
for master reads
data from slave

t0

t1

Operations are referenced to the clock, but


realistically, there will be delay in the communication

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

45

SYNCHRONOUS BUS (6/9)


Signals do not appear on the bus as soon as they are
placed on the bus, due to the propagation delay in
the interface circuits.
Signals reach the devices after a propagation delay
which depends on the characteristics (physical) of
the bus.
Data must remain on the bus for some time after t2
equal to the hold time of the buffer.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

46

SYNCHRONOUS BUS (7/9)


Data transfer has to be completed within one clock
cycle:
Clock period t2 - t0 must be such that the longest
propagation delay on the bus and the slowest
device interface must be accommodated.
Forces all the devices to operate at the speed of
the slowest device.
Processor just assumes that the data are available at
t2 in case of a Read operation, or are read by the
device in case of a Write operation.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

47

SYNCHRONOUS BUS (8/9)


Control signals serve two purposes:
Inform the master that the slave has recognized
the address, and is ready to participate in a data
transfer operation.
Enable to adjust the duration of the data transfer
operation based on the speed of the participating
slaves.
High-frequency bus clock is used for:
Data transfer spans several clock cycles instead of
just one clock cycle.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

48

SYNCHRONOUS BUS (9/9)


Address & command
requesting a Read
operation appear on
the bus.

Time
1

Multi clock cycle

Clock

Address

Command

Master strobes data


into the input buffer.
Data

Slave-ready

Slave places the data on the bus,


and asserts Slave-ready signal.

Clock changes are seen by all


the devices at the same time.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

49

ASYNCHRONOUS BUS (1/2)


Data transfers are controlled by a handshake
between the master and the slave (no common
clock).
Operations are based on two timing control lines:
Master-ready
Slave-ready
Master-ready signal is asserted by the master to
indicate that the slave is ready to for a data transfer.
Slave-ready signal is asserted by the slave in
response to the master-ready from the master, and it
indicates to the master that the slave is ready for a
data transfer.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

50

ASYNCHRONOUS BUS (2/2)


Data transfer using the handshake protocol:
Master places the address and command information
on the bus.
Asserts the Master-ready signal to indicate to the
slaves that the address and command information has
been placed on the bus.
All devices on the bus decode the address.
Address slave performs the required operation, and
informs the processor it has done so by asserting the
Slave-ready signal.
Master removes all the signals from the bus, once
Slave-ready is asserted.
If the operation is a Read operation, Master also
strobes the data into its input buffer.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

51

ASYNCHRONOUS TIMING DIAGRAM


Time

Address
and command

Master-ready

Slave-ready

Data

t0

t1

t2

t3

t4

t5

Bus cycle

Master-ready and slave-ready signals control


the overall data transfer process (replacing
clock signal in the synchronous operation)

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

52

ASYNCHRONOUS TIMING OPERATION


t0 - Master places the address and command
information on the bus.
t1 - Master asserts the Master-ready signal. Masterready signal is asserted at t1 instead of t0
t2 - Addressed slave places the data on the bus and
asserts the Slave-ready signal.
t3 - Slave-ready signal arrives at the master.
t4 - Master removes the address and command
information.
t5 - Slave receives the transition of the Master-ready
signal from 1 to 0. It removes the data and the Slaveready signal from the bus.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

53

ASYNCHRONOUS BUS ADV./DISADV.


Advantages:
Eliminates the need for synchronization between
the sender and the receiver.
Can accommodate varying delays automatically,
using the Slave-ready signal.
Disadvantages:
Data transfer rate with full handshake is limited by
two-round trip delays.
Data transfers using a synchronous bus involves
only one round trip delay, and hence a
synchronous bus can achieve faster rates.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

54

ACCESSING IO DEVICES

ACCESSING IO DEVICES (1/4)


Processor

Memory

Bus

I/O device 1







I/O device n

Multiple I/O devices may be connected to the processor and the memory via a bus.
Bus consists of three sets of lines to carry address, data and control signals.
Each I/O device is assigned an unique address.
To access an I/O device, the processor places the address on the address lines.
The device recognizes the address, and responds to the control signals.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

56

ACCESSING IO DEVICES (2/4)


I/O devices and the memory may share the same address space:
Memory-mapped I/O
Any machine instruction that can access memory can be used
to transfer data to/from an I/O device.
Simpler software.
I/O devices and the memory may have different address spaces:
Special instructions to transfer data to/from I/O devices.
I/O devices may have to deal with fewer address lines.
I/O address lines need not be physically separate from
memory address lines.
In fact, address lines may be shared between I/O devices and
memory, with a control signal to indicate whether it is a
memory address or an I/O address.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

57

ACCESSING IO DEVICES (3/4)


Address lines
Bus

Data lines
Control lines

Address
decoder

Control
circuits

Data and
status registers

I/O
interface

Input device

 I/O device is connected to the bus using an I/O interface circuit which has:
 Address decoder, control circuit, and data and status registers.
 Address decoder decodes the address placed on the address lines thus
enabling the device to recognize its address.
 Data register holds the data being transferred to or from the processor.
 Status register holds information necessary for the operation of the I/O device.
 Data and status registers are connected to the data lines, and have unique
addresses.
 I/O interface circuit coordinates I/O transfers.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

58

ACCESSING IO DEVICES (4/4)


Recall that the rate of transfer to/from I/O devices is
slower than the speed of the processor. This creates
the need for mechanisms to synchronize data
transfers between them.
Program-controlled I/O:
Processor repeatedly monitors a status flag to
achieve the necessary synchronization.
Processor polls the I/O device.
Two other mechanisms used for synchronizing data
transfers between the processor and memory:
Interrupts
Direct Memory Access
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

59

IO SYNCHRONIZATION (1/2)
Programmed I/O:
Data are exchanged between the processor and
the I/O module
Processor executes a program that gives it direct
control of the I/O operation
When the processor issues a command it must
wait until the I/O operation is complete
If the processor is faster than the I/O module this is
wasteful of processor time

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

60

IO SYNCHRONIZATION (2/2)
Interrupt-driven I/O:
Processor issues an I/O command, continues to
execute other instructions, and is interrupted by
the I/O module when the latter has completed its
work
Direct memory access (DMA):
The I/O module and main memory exchange data
directly without processor involvement

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

61

IO COMMANDS (1/2)
There are four types of I/O commands that an I/O
module may receive when it is addressed by a
processor
Control:
used to activate a peripheral and tell it what to do
Test:
used to test various status conditions associated
with an I/O module and its peripherals

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

62

IO COMMANDS (2/2)
Read:
causes the I/O module to obtain data from the
peripheral and place it in an internal buffer
Write:
causes the I/O module to take data from the data
bus and subsequently transmit that data to the
peripheral

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

63

IO TECHNIQUES (1/2)

IO techniques classification

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

64

IO TECHNIQUES (2/2)

Detailed IO
techniques example

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

65

PROGRAMMED IO (1/2)
There is a close correspondence between the I/Orelated instructions that the processor fetches from
memory and the I/O commands that the processor
issues to an I/O module to execute the instructions
The form of the instruction depends on the way in
which external devices are addressed
Each I/O device connected through I/O modules is
given a unique identifier or address

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

66

PROGRAMMED IO (2/2)
When the processor issues an I/O command, the
command contains the address of the desired device
Thus each I/O module must interpret the address
lines to determine if the command is for itself

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

67

MEMORY-MAPPED IO
There is a single address space for memory locations
and I/O devices
A single read line and a single write line are needed
on the bus

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

68

IO MAPPING (1/2)
Memory mapped I/O:
Devices and memory share an address space
I/O looks just like memory read/write
No special commands for I/O
Large selection of memory access commands
available
Isolated I/O:
Separate address spaces
Need I/O or memory select lines
Special commands for I/O
Limited set
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

69

IO MAPPING (2/2)

Isolated IO
Memory-mapped IO

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

70

INTERRUPT-DRIVEN IO
The problem with programmed I/O is that the
processor has to wait a long time for the I/O module
to be ready for either reception or transmission of
data
An alternative is for the processor to issue an I/O
command to a module and then go on to do some
other useful work
The I/O module will then interrupt the processor to
request service when it is ready to exchange data
with the processor
The processor executes the data transfer and
resumes its former processing
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

71

INTERRUPT PROCESSING

Example of simple
interrupt processing

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

72

INTERRUPT IO DESIGN ISSUES


Two design issues arise in implementing interrupt
I/O:
Because there will be multiple I/O modules how
does the processor determine which device issued
the interrupt?
If multiple interrupts have occurred how does the
processor decide which one to process?

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

73

DEVICE IDENTIFICATION (1/2)


Multiple interrupt lines:
Between the processor and the I/O modules
Most straightforward approach
Even if multiple lines are used, it is likely that each
line will have multiple I/O modules attached to it
Software poll:
When processor detects an interrupt it branches to
an interrupt-service routine whose job is to poll
each I/O module to determine which module
caused the interrupt
Time consuming process
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

74

DEVICE IDENTIFICATION (2/2)


Daisy chain (hardware poll, vectored):
The interrupt acknowledge line is daisy chained
through the modules
Vector address of the I/O module or some other
unique identifiers
Vectored interrupt processor uses the vector as a
pointer to the appropriate device-service routine, avoid
executing a general interrupt-service routine first
Bus arbitration (vectored):
An I/O module must first gain control of the bus before
it can raise the interrupt request line
When the processor detects the interrupt, it responds
on the interrupt acknowledge line
Then the requesting module places its vector on the
data lines
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

75

PROB. OF INTERRUPT IO/PROG. IO


Two inherent drawbacks:
The I/O transfer rate is limited by the speed of the
IO device with which the processor can test and
service
The processor is tied up in managing an I/O
transfer; a number of instructions must be
executed for each I/O transfer
When large volumes of data are to be moved a more
efficient technique is direct memory access (DMA)

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

76

DMA MODULE DIAGRAM

Typical DMA
block diagram

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

77

DMA OPERATION

DMA and interrupt


breakpoints during
an instruction cycle

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

78

DMA CONFIGURATION

Single-bus, detached DMA

Single-bus, integrated DMA-IO

IO bus

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

79

DMA USAGE OF SYSTEM BUS

8237 an Intel DMA


controller chip

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

80

EVOLUTION OF IO FUNCTIONS (1/2)


The CPU directly controls a peripheral device.
A controller or I/O module is added. The CPU uses
programmed I/O without interrupts.
The CPU need not spend time waiting for an I/O
operation to be performed, thus increasing efficiency.
The I/O module is given direct access to memory via
DMA. It can now move a block of data to or from
memory without involving the CPU, except at the
beginning and end of the transfer.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

81

EVOLUTION OF IO FUNCTIONS (2/2)


The I/O module is enhanced to become a processor
in its own right, with a specialized instruction set
tailored for I/O
The I/O module has a local memory of its own and is
a computer in its own right. With this architecture a
large set of I/O devices can be controlled with
minimal CPU involvement.
Essentially: as computer systems are getting
complex, CPU involvement for IO operations
needs to be as less as possible not to compromise
the overall performance

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

82

IO CHANNEL ARCHITECTURE

Selector: common bus


for all IO controllers

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

Multiplexer: separate bus


for each IO controller

83

PARALLEL/SERIAL IO

Parallel IO

Serial IO

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

84

POINT-TO-POINT/MULTIPOINT

Connection between an I/O


module in a computer system
and external devices can be
either:

Point-to-point interface
provides a dedicated line
between the I/O module and
the external device

point-to-point

On small systems
(PCs, workstations)
typical point-to-point
links include those to
the keyboard, printer,
and external modem

multipoint

Example: EIA-232
specification

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

Multipoint external interfaces


are used to support external
mass storage devices (disk
and tape drives) and
multimedia devices (CDROMs, video, audio)

Are in effect external


buses

85

POINT-TO-POINT/MULTIPOINT

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

86

INTERRUPTS

INTERRUPTS
In program-controlled I/O, when the processor
continuously monitors the status of the device, it
does not perform any useful tasks.
Alternative: I/O device alert the processor when it
becomes ready, through sending a hardware signal
called an interrupt to the processor.
At least one of the bus control lines, called an
interrupt-request line is dedicated for this purpose.
Processor can perform other useful tasks while it is
waiting for the device to be ready.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

88

INTERRUPT PROCESS
1
2
Interrupt
occurs
here

i
i +1

 Processor is executing the instruction located at address i when an interrupt


occurs.
 Routine executed in response to an interrupt request is called the interruptservice routine.
 When an interrupt occurs, control must be transferred to the interrupt service
routine.
 But before transferring control, the current contents of the PC (i+1), must be
saved in a known location.
 This will enable the return-from-interrupt instruction to resume execution at i+1.
 Return address, or the contents of the PC are usually stored on the processor
stack.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

89

INTERRUPT SERVICE ROUTINE


Treatment of an interrupt-service routine is very similar to that
of a subroutine process.
However there are significant differences:
A subroutine performs a task that is required by the calling
program.
Interrupt-service routine may not have anything in common
with the program it interrupts.
Interrupt-service routine and the program that it interrupts
may belong to different users.
As a result, before branching to the interrupt-service
routine, not only the PC, but other information such as
condition code flags, and processor registers used by both
the interrupted program and the interrupt service routine
must be stored.
This will enable the interrupted program to resume
execution upon return from interrupt service routine.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

90

INTERRUPT LATENCY
Saving and restoring information can be done automatically by
the processor or explicitly by program instructions.
Saving and restoring registers involves memory transfers:
Increases the total execution time.
Increases the delay between the time an interrupt request
is received, and the start of execution of the interruptservice routine. This delay is called interrupt latency.
In order to reduce the interrupt latency, most processors save
only the minimal amount of information:
Includes only Program Counter and processor status
registers.
Any additional information that must be saved, must be saved
explicitly by the program instructions at the beginning of the
interrupt service routine.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

91

INTERRUPT ACKNOWLEDGE
When a processor receives an interrupt-request, it
must branch to the interrupt service routine.
It must also inform the device that it has recognized
the interrupt request (i.e. telling the IO device, yes I
have received your request and I will response to
you).
This can be accomplished in two ways:
Some processors have an explicit interruptacknowledge control signal for this purpose.
In other cases, the data transfer that takes place
between the device and the processor can be
used to inform the device.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

92

INTERRUPT ENABLE/DISABLE
Interrupt-requests interrupt the execution of a program, and may
alter the intended sequence of events:
Sometimes such alterations may be undesirable, and must not
be allowed.
For example, the processor may not want to be interrupted by
the same device while executing its interrupt-service routine.
Processors generally provide the ability to enable and disable such
interruptions as desired.
One simple way is to provide machine instructions such as
Interrupt-enable and Interrupt-disable for this purpose.
To avoid interruption by the same device during the execution of an
interrupt service routine:
First instruction of an interrupt service routine can be Interruptdisable.
Last instruction of an interrupt service routine can be Interruptenable.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

93

MULTIPLE INTERRUPTS
Multiple I/O devices may be connected to the processor and
the memory via a bus, thus can generate multiple interrupt
requests.
Each device operates independently, and hence no definite
order can be imposed on how the devices generate
interrupt requests?
Problems:
How does the processor know which device has generated
an interrupt?
How does the processor know which interrupt service
routine needs to be executed?
When the processor is executing an interrupt service
routine for one device, can other device interrupt the
processor?
If two interrupt-requests are received simultaneously, then
how to break the tie?
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

94

INTERRUPT POLLING (1/2)


Consider a simple arrangement where all devices
send their interrupt-requests over a single control line
in the bus.
When the processor receives an interrupt request
over this control line, how does it know which device
is requesting an interrupt?
This information is available in the status register of
the device requesting an interrupt:
The status register of each device has an IRQ bit
which it sets to 1 when it requests an interrupt.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

95

INTERRUPT POLLING (2/2)


Interrupt service routine can poll the I/O devices
connected to the bus. The first device with IRQ equal
to 1 is the one that is serviced.
Polling mechanism is easy, but time consuming to
query the status bits of all the I/O devices connected
to the bus.
In this case the priority is determined by the order in
which the devices are polled.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

96

INTERRUPT IDENTIFIER
The device requesting an interrupt may identify itself directly to
the processor:
Device can do so by sending a special code (4 to 8 bits)
the processor over the bus.
Code supplied by the device may represent a part of the
starting address of the interrupt-service routine.
The remainder of the starting address is obtained by the
processor based on other information such as the range of
memory addresses where interrupt service routines are
located.
Usually the location pointed to by the interrupting device is
used to store the starting address of the interrupt-service
routine.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

97

MULTIPLE INTERRUPTS PROCESSING


Previously, before the processor started executing the
interrupt service routine for a device, it disables the
interrupts from the device.
In general, same arrangement is used when multiple
devices can send interrupt requests to the processor.
During the execution of an interrupt service routine of
device, the processor does not accept interrupt
requests from any other device.
Since the interrupt service routines are usually short,
the delay that this causes is generally acceptable.
However, for certain devices this delay may not be
acceptable:
Which devices can be allowed to interrupt a processor
when it is executing an interrupt service routine of
another device?
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

98

INTERRUPT PRIORITY
Which interrupt request does the processor accept if
it receives interrupt requests from two or more
devices simultaneously?
If the I/O devices are organized in a priority structure,
the processor accepts the interrupt request from a
device with higher priority.
Each device has its own interrupt request and interrupt
acknowledge line.
A different priority level is assigned to the interrupt
request line of each device.

However, if the devices share an interrupt request


line, then how does the processor decide which
interrupt request to accept?
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

99

IO DEVICE PRIORITY
I/O devices are organized in a priority structure:
An interrupt request from a high-priority device is accepted
while the processor is executing the interrupt service
routine of a low priority device.
A priority level is assigned to a processor that can be changed
under program control.
Priority level of a processor is the priority of the program
that is currently being executed.
When the processor starts executing the interrupt service
routine of a device, its priority is raised to that of the device.
If the device sending an interrupt request has a higher
priority than the processor, the processor accepts the
interrupt request.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

100

PROCESSORS PRIORITY
Processors priority is encoded in a few bits of the
processor status register.
Priority can be changed by instructions that write into
the processor status register.
Usually, these are privileged instructions, or
instructions that can be executed only in the
supervisor mode.
Privileged instructions cannot be executed in the user
mode.
Prevents a user program from accidentally or
intentionally changing the priority of the processor.

If there is an attempt to execute a privileged


instruction in the user mode, it causes a special type
of interrupt called as privilege exception.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

101

INTERRUPT MECHANISM

Processor

Interrupt request lines

INTR1
Device 1

I NTRp
Device 2

INTA1

Device p
INTA p

Priority arbitration

 Each device has a separate interrupt-request and interrupt-acknowledge line.


 Each interrupt-request line is assigned a different priority level.
 Interrupt requests received over these lines are sent to a priority arbitration circuit in
the processor.
 If the interrupt request has a higher priority level than the priority of the processor,
then the request is accepted.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

102

DAISY CHAIN SCHEME


Daisy chain connection

Processor

I NTR

Device 1

Device 2

Device n

INTA

 Devices are connected to form a daisy chain.


 Devices share the interrupt-request line, and interrupt-acknowledge line is
connected to form a daisy chain.
 When devices raise an interrupt request, the interrupt-request line is activated.
 The processor in response activates interrupt-acknowledge.
 Received by device 1, if device 1 does not need service, it passes the signal to
device 2.
 Device that is electrically closest to the processor has the highest priority.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

103

DAISY CHAIN PRIORITY (1/2)


When I/O devices were organized into a priority
structure, each device had its own interrupt-request
and interrupt-acknowledge line.
When I/O devices were organized in a daisy chain
fashion, the devices shared an interrupt-request line,
and the interrupt-acknowledge propagated through
the devices.
A combination of priority structure and daisy chain
scheme can also used.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

104

DAISY CHAIN PRIORITY (2/2)

Processor

I NTR1

INTA1

Device

Device

Device

Device

INTR p

INTA p
Priority arbitration
circuit

 Devices are organized into groups.


 Each group is assigned a different priority level.
 All the devices within a single group share an interrupt-request line, and
are connected to form a daisy chain.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

105

INTERRUPT REQUEST CONTROL


Only those devices that are being used in a program
should be allowed to generate interrupt requests.
To control which devices are allowed to generate
interrupt requests, the interface circuit of each I/O
device has an interrupt-enable bit.
If the interrupt-enable bit in the device interface is set to 1,
then the device is allowed to generate an interrupt-request.

Interrupt-enable bit in the devices interface circuit


determines whether the device is allowed to generate
an interrupt request.
Interrupt-enable bit in the processor status register or
the priority structure of the interrupts determines
whether a given interrupt will be accepted.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

106

EXCEPTIONS
Interrupts caused by interrupt-requests sent by I/O
devices.
Interrupts could be used in many other situations
where the execution of one program needs to be
suspended and execution of another program needs
to be started.
In general, the term exception is used to refer to any
event that causes an interruption.
Interrupt-requests from I/O devices is one type of an
exception.

Other types of exceptions are:


Recovery from errors
Debugging
Privilege exception
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

107

EXCEPTION SOURCES
Many sources of errors in a processor. For example:
Error in the data stored.
Error during the execution of an instruction.
When such errors are detected, exception processing
is initiated:
Processor takes the same steps as in the case of
I/O interrupt-request.
It suspends the execution of the current program,
and starts executing an exception-service routine.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

108

IO INTERRUPT VS EXCEPTIONS
Differences between handling I/O interrupt-request
and handling exceptions due to errors:
In case of I/O interrupt-request, the processor
usually completes the execution of an instruction in
progress before branching to the interrupt-service
routine.
In case of exception processing, the execution of
an instruction in progress usually cannot be
completed.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

109

ANALYZING EXCEPTIONS
Debugger important features:
Trace
Breakpoints
Trace mode:
Exception occurs after the execution of every instruction.
Debugging program is used as the exception-service
routine.
Breakpoints:
Exception occurs only at specific points selected by the
user.
Debugging program is used as the exception-service
routine.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

110

PRIVILEGED EXCEPTIONS
Certain instructions can be executed only when the
processor is in the supervisor mode. These are
called privileged instructions.
If an attempt is made to execute a privileged
instruction in the user mode, a privilege exception
occurs.
Privilege exception causes:
Processor to switch to the supervisor mode,
Execution of an appropriate exception-servicing
routine.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

111

INTERFACE CIRCUITS

INTERFACE CIRCUITS
I/O interface consists of the circuitry required to
connect an I/O device to a computer bus.
Side of the interface which connects to the computer
has bus signals for address, data and control
Side of the interface which connects to the I/O device
has:
Datapath and associated controls to transfer data
between the interface and the I/O device (called as
a port)
Ports can be classified into parallel and serial ports

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

113

IO INTERFACE BLOCK DIAGRAM

Address lines
Bus

Connected to
the processor

Data lines
Control lines

Address
decoder

Control
circuits

Data and
status registers

I/O
interface

Input device

IO devices

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

114

INTERFACE CIRCUIT FUNCTION


Provides a register for temporary storage of data
Includes a status register containing status
information that can be accessed by the processor
Includes a control register that holds the information
governing the behavior of the interface
Contains address-decoding circuitry to determine
when it is being addressed by the processor
Generates the required timing signals
Performs format conversion (communication
protocol) necessary for data transfer to/from the
processor
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

115

PARALLEL/SERIAL PORTS
Parallel port:
transfers data in the form of a number of bits at a
time, normally 8 or 16 to or from the device.
Serial port:
transfers and receives data one bit at a time.
Processor communicates with the bus in the same
way, whether it is a parallel port or a serial port.
Conversion from the parallel to serial and vice versa
takes place inside the interface circuit.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

116

INPUT INTERFACE (1/2)


Keyboard example
Data
Address

Processor

R/W

DATAIN
SIN

Master-ready
Slave-ready

Data

Input
interface

Valid

Encoder
and
debouncing
circuit

Keyboard
switches

Keyboard is connected to a processor using a parallel port.


Processor is 32-bits and uses memory-mapped I/O and the
asynchronous bus protocol.
On the processor side of the interface we have:
Data lines
Address lines
Control or R/W line
Master-ready signal
Slave-ready signal
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

117

INPUT INTERFACE (2/2)


Keyboard example
Data
Address

Processor

R/W

DATAIN
SIN

Master-ready
Slave-ready

Data

Input
interface

Valid

Encoder
and
debouncing
circuit

Keyboard
switches

On the keyboard side of the interface:


Encoder circuit which generates a code for the key pressed
Debouncing circuit which eliminates the effect of a key bounce (a single
key stroke may appear as multiple events to a processor)
Data lines contain the code for the key
Valid line changes from 0 to 1 when the key is pressed. This causes the
code to be loaded into DATAIN and SIN to be set to 1.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

118

OUTPUT INTERFACE (1/2)


Printer example
Data
Address

Processor
CPU

R/W

DATAOUT

Data

SOUT

Valid

Output
interface

Idle

Printer

Master-ready
Slave-ready

Printer is connected to a processor using a parallel port.


Processor is 32 bits, uses memory-mapped I/O and asynchronous bus protocol.
On the processor side:
Data lines
Address lines
Control or R/W line
Master-ready signal
Slave-ready signal
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

119

OUTPUT INTERFACE (2/2)


Printer example
Data
Address

Processor
CPU

R/W

DATAOUT

Data

SOUT

Valid

Output
interface

Idle

Printer

Master-ready
Slave-ready

On the printer side:


Idle signal line which the printer asserts when it is ready to accept a
character. This causes the SOUT flag to be set to 1
Processor places a new character into a DATAOUT register
Valid signal, asserted by the interface circuit when it places a new
character on the data lines.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

120

INPUT INTERFACE CIRCUIT


Output lines of DATAIN are
connected to the data lines of
the bus by means of 3 state
drivers
Drivers are turned on when
the processor issues a read
signal and the address
selects this register.

SIN signal is generated using a status flag circuit.


It is connected to line D0 of the processor bus
using a three-state driver.
Address decoder selects the input interface based
on bits A1 through A31.
Bit A0 determines whether the status or data
register is to be read, when Master-ready is
active.
In response, the processor activates the Slaveready signal, when either the Read-status or
Read-data is equal to 1, which depends on line
A0.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

121

STATUS FLAG CIRCUIT


Data lines of the processor bus are
connected to the DATAOUT register
of the interface.
The status flag SOUT is connected
to the data line D1 using a threestate driver.
The three-state driver is turned on,
when the control Read-status line is
1.
Address decoder selects the output
interface using address lines A1
through A31.
Address line A0 determines whether
the data is to be loaded into the
DATAOUT register or status flag is
to be read.
If the Load-data line is 1, then the
Valid line is set to 1.
If the Idle line is 1, then the status
flag SOUT is set to 1.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

122

OUTPUT INTERFACE CIRCUIT


D7

Bus

PA7
DATAIN

D1
D0

PA0
SIN
Input
status

CA
PB7
DATAOUT
PB0

SOUT
Handshak
e
control
SlaveReady

Master
Ready
R/ W
A31
Address
decoder
A2
A1
A0

RS1
RS0

My-address

CB1
CB2

Combined I/O interface circuit.


Address bits A2 through A31, that
is 30 bits are used to select the
overall interface.
Address bits A1 through A0, that
is, 2 bits select one of the three
registers, namely, DATAIN,
DATAOUT, and the status register.
Status register contains the flags
SIN and SOUT in bits 0 and 1.
Data lines PA0 through PA7
connect the input device to the
DATAIN register.
DATAOUT register connects the
data lines on the processor bus to
lines PB0 through PB7 which
connect to the output device.
Separate input and output data
lines for connection to an I/O
device.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

123

SERIAL PORT
Serial port is used to connect the processor to I/O
devices that require transmission of data one bit at a
time.
Serial port communicates in a bit-serial fashion on
the device side and bit parallel fashion on the bus
side.
Transformation between the parallel and serial
formats is achieved with shift registers that have
parallel access capability.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

124

BLOCK DIAGRAM

Serial
input

Input shift register

DATAIN

Example interface
circuit for serial port

D7
D0

DATAOUT

My-address
RS1
RS0
R /W
Ready

Chip and
register
select

Output shift register

Serial

Accept
Receiving clock
I NTR

Status
and
control

ransmission clock
T

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

125

SERIAL OPERATION
Input shift register accepts input one bit at a time from the
I/O device.
Once all the 8 bits are received, the contents of the input
shift register are loaded in parallel into DATAIN register.
Output data in the DATAOUT register are loaded into the
output shift register.
Bits are shifted out of the output shift register and sent out
to the I/O device one bit at a time.
As soon as data from the input shift reg. are loaded into
DATAIN, it can start accepting another 8 bits of data.
Input shift register and DATAIN registers are both used at
input so that the input shift register can start receiving
another set of 8 bits from the input device after loading
the contents to DATAIN, before the processor reads the
contents of DATAIN. This is called as double-buffering.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

126

SERIAL PORTS CHARACTERISTICS


Serial interfaces require fewer wires, and hence serial
transmission is convenient for connecting devices that
are physically distant from the computer.
Speed of transmission of the data over a serial interface
is known as the bit rate.
Bit rate depends on the nature of the devices
connected.
In order to accommodate devices with a range of speeds,
a serial interface must be able to use a range of clock
speeds.
Several standard serial interfaces have been developed:
Universal Asynchronous Receiver Transmitter (UART)
for low-speed serial devices.
RS-232-C.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

127

INTERCONNECTION STANDARDS

THE NEED OF STANDARDS


I/O device is connected to a computer using an
interface circuit.
Question: Do we have to design a different interface
for each IO device? not practical.
Solution: develop standard interfaces and protocols
thus interfacing is easier
A personal computer has:
A motherboard which houses the processor chip,
main memory and some I/O interfaces.
A few connectors for plugging additional interfaces

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

129

MOTHERBOARD BUS
Because of electrical reasons only a few devices can be
connected directly to the processor bus.
Motherboard usually provides another bus that can
support more devices.
Processor bus and the other bus (called as expansion
bus) are interconnected by a circuit called bridge.
Devices connected to the expansion bus experience a
small delay in data transfers.
Design of a processor bus is closely tied to the
architecture of the processor.
No uniform standard can be defined.
Expansion bus however can have uniform standard
defined.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

130

BUS STANDARDS
A number of standards have been developed for the
expansion bus.
Three widely used bus standards:
PCI (Peripheral Component Interconnect)
USB (Universal Serial Bus)

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

131

PCI CONNECTION IN COMPUTER


Main
memory

Processor

Processor bus

Bridge circuit translates


signals and protocols from
processor bus to PCI bus.

Bridge
PCI bus

Additional
memory

SCSI
controller

Ethernet
Interface

USB
controller

Expansion bus on
the motherboard
ISA
Interface

SCSI bus

IDE
disk

Video
Disk
controller

Disk 1

Disk 2

CD-ROM
controller

CDROM

K eyboard

Game

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

132

PCI PORTS IN MOTHERBOARD

Source: http://www.playtool.com/pages/vidslots/mballslots.jpg
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

133

PCI BUS
Peripheral Component Interconnect
Parallel interface connection
PCI main function:
support memory transfers involve a burst of data rather
than just one word.

Advantages:
Low-cost bus
Processor independent
Plug-and-play capability

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

134

PCI CONCEPT
The bus supports three independent address spaces:
memory, I/O, and configuration.
The master maintains the address information on the
bus until data transfer is completed. But, the address
is needed only long enough for the slave to be
selected. Thus, the address is needed on the bus for
one clock cycle only, freeing the address lines to be
used for sending data in subsequent clock cycles.
The result is a significant cost reduction.
A master is called an initiator, the slave is called a
target.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

135

PCI PINS LIST

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

136

ADDRESS AND DATA SIGNALS


AD[31:00]:
Address and data are both multiplexed on the same
PCI pins
PCI supports both single and burst read and write
transactions
C/BE[3:0]#:
4-bit command/byte enable bus
Defines the PCI command during address phase
Indicates byte enable during data phases
PAR:
Parity bit (quiz 2/2)
Used to verify correct transmittal of address/data and
command/byte-enable
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

137

INTERFACE CONTROL SIGNALS (1/2)


FRAME#:
Driven by the initiator to indicate the start and end
of a transaction
TRDY#:
When the target asserts this signal, it tells the
initiator that it is ready to send or receive data
IRDY#:
initiator ready signal indicates that it is ready to
send or receive data

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

138

INTERFACE CONTROL SIGNALS (2/2)


STOP#
Used by target to indicate that it needs to terminate the
transaction
DEVSEL#
Device select
Each target is responsible for decoding the address
associated with each transaction
When a target recognizes its address, it asserts
DEVSEL# to claim the corresponding transaction
IDSEL
ID-Sel
Individual device select for configuration one unique
IDSEL
line per agent
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

139

ARBITRATION SIGNALS
REQ#
Asserted by initiator to request bus ownership
GNT#
Asserted by system arbiter to grant bus ownership
to the initiator

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

140

SYSTEM SIGNALS
CLK
PCI operates at 33 or 66 MHz

RST#
Asynchronous reset brings all the PCI specific signals to a
consistent state

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

141

INTERRUPT SIGNALS
INTA#
Interrupt A is used to request Interrupts.
INTB#
Interrupt B is used to request Interrupts.
INTC#
Interrupt C is used to request Interrupts.
INTD#
Interrupt D is used to request Interrupts.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

142

PCI READ OPERATION

Source: PCI Bus Demystified, Newnes, 2004

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

143

PCI WRITE OPERATION

Source: PCI Bus Demystified, Newnes, 2004

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

144

PCI COMMANDS

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

145

DEVICE CONFIGURATION
When an I/O device is connected to a computer, several actions are
needed to configure both the device and the software that communicates
with it.
PCI incorporates in each I/O device interface a small configuration ROM
memory that stores information about that device.
The configuration ROMs of all devices are accessible in the configuration
address space. The PCI initialization software reads these ROMs and
determines whether the device is a printer, a keyboard, an Ethernet
interface, or a disk controller. It can further learn bout various device
options and characteristics.
Devices are assigned addresses during the initialization process.
This means that during the bus configuration operation, devices cannot be
accessed based on their address, as they have not yet been assigned one.
Hence, the configuration address space uses a different mechanism. Each
device has an input signal called Initialization Device Select, IDSEL#
Electrical characteristics:
PCI bus has been defined for operation with either a 5 or 3.3 V power
supply

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

146

PCI EVOLUTION (1/6)


PCI 32 bit @ 33 MHz
Introduced in 1993
Limited to 10 loads per bus
Can run at lower speed to accommodate more
loads
Peak Bandwidth: 133MB/sec

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

147

PCI EVOLUTION (2/6)


PCI 64 bit @ 66 MHz
Introduced in 1995
Limited to 5 loads per bus
64 bits addressing with single address cycle
Peak Bandwidth: 533MB/sec

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

148

PCI EVOLUTION (3/6)


PCI-X has improvements over PCI
Introduced in 1999
Specification for higher bus speeds
Increased efficiency of bus transfers with protocol
enhancements
Split Transactions allowing the bus to be
utilized by another device while the slave
(completer) device is gathering the read data
PCI bus transfer efficiency: 50-60%
PCI-X bus transfer efficiency: 85%

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

149

PCI EVOLUTION (4/6)


PCI-X 64 bit @ 100 MHz
Limited to two-three loads per bus
Peak Bandwidth: 800MB/sec
PCI-X 64 bit @ 133 MHz
Point to Point Bus limited to one-two loads per
bus*
Peak Bandwidth: 1066MB/sec
PCI-X based systems can run at lower bus speed to
increase the number of loads and take advantage of
PCI-X split transaction feature

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

150

PCI EVOLUTION (5/6)


PCI Express
Introduced in 2002
Packet based high-speed serial lines
Point-to-Point Differential signaling
PCIe is switched versus a multi-drop bus found in
PCI
Higher Throughput; Higher Bandwidth/pin; and
Scalable Interconnect
Full Duplex Transmit and Receive
Simultaneously
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

151

PCI EVOLUTION (6/6)


Each SerDes (serial) line runs at:
PCIe 1.0 Gen1: 2.5 Gb/sec
Aggregate Bandwidth: x1=0.5; x4=2; x8=4;
x16=8 GB/sec
PCIe 2.0 Gen2: 5.0 Gb/sec (2X throughput of
Gen1)
Aggregate Bandwidth: x1=1; x4=4; x8=8;
x16=16 GB/sec
PCIe 3.0 Gen3: 8.0 Gb/sec (2X throughput of
Gen2)
Aggregate Bandwidth: x1=2; x4=8; x8=16;
x16=32 GB/sec
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

152

PCI VARIATIONS
Same protocol format, but in a different form factor:
PMC: PCI Mezzanine Card
CompactPCI: PCI in Eurocard form factor
Mini PCI: for laptops

PMC

CompactPCI

Mini PCI
Source: xilinx.com

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

153

USB
Universal Serial Bus
An industry standard developed through a
collaborative effort of several computer and
communication companies, including Compaq,
Hewlett-Packard, Intel, Lucent, Microsoft, Nortel
Networks, and Philips.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

154

USB EVOLUTION
USB 1.0:
1996
1.5 Mbit/s (keyboard, etc), 12 Mbit/s (disk)
USB 2.0:
2000
470 Mbit/s
USB 3.0:
2008
5 Gbit/s
USB 3.1:
2014
156 Gbit/s
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

155

USB SPEEDS
Low-speed devices (USB 1.0):
Examples: keyboards, mice, and game peripherals
Bus Rate: 1.5 Mb/s
Maximum Effective Data Rate: 800 B/s
Full-speed devices (USB 1.0):
Examples: phones, audio devices, and compressed video
Bus Rate: 12 Mb/s
Maximum Effective Data Rate: 1.2 MB/s
High-speed devices (USB 2.0):
Examples: video, imaging, and storage devices
Bus Rate: 480 Mb/s
Maximum Effective Data Rate: 53 MB/s
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

156

USB PHYSICAL PINS

Source: cypress.com
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

157

ELECTRICAL CHARACTERISTICS
The cables used for USB connections consist of four wires.
Two are used to carry power (+5V) and ground (Vbus, GND).
Thus, a hub or an I/O device may be powered directly from
the bus, or it may have its own external power connection.
The other two wires are used to carry data (D+, D-).
Different signaling schemes are used for different speeds of
transmission.
At low speed, 1s and 0s are transmitted by sending a high
voltage state (5V) on one or the other of the two signal
wires. For high-speed links, differential transmission is
used.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

158

DIFFERENTIAL SIGNALING

Source: cypress.com
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

159

DIFFERENTIAL TRANSMISSION
Non-return-to-zero inverted (NRZI) encoded with bit
stuffing across the twisted pair
A logic 1 is represented by no change in voltage level
and a logic 0 is represented by a change in voltage
level

Source: cypress.com
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

160

USB VARIATIONS

Source: cypress.com
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

161

USB TREE STRUCTURE (1/2)

Source: cypress.com
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

162

USB TREE STRUCTURE (2/2)


Tree structure:
to accommodate a large number of devices that
can be added or removed at any time (up to 128
devices)
Each node of the tree has a device called a hub, acts
as an intermediate control point between the host
and the I/O devices.
At the root of the tree, a root hub connects the entire
tree to the host computer. The leaves of the tree are
the I/O devices being served

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

163

USB OPERATION
In normal operation, a hub copies a message that it
receives from its upstream connection to all its
downstream ports.
As a result, a message sent by the host computer is
broadcast to all I/O devices, but only the addressed
device will respond to that message.
However, a message from an I/O device is sent only
upstream towards the root of the tree and is not seen
by other devices. Hence, the USB enables the host
to communicate with the I/O devices, but it does not
enable these devices to communicate with each
other.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

164

USB ADDRESSING (1/2)


When a USB is connected to a host computer, its
root hub is attached to the processor bus, where it
appears as a single device.
The host software communicates with individual
devices attached to the USB by sending packets of
information, which the root hub forwards to the
appropriate device in the USB tree.
Each device on the USB, whether it is a hub or an I/O
device, is assigned a 7-bit address. This address is
local to the USB tree and is not related in any way to
the addresses used on the processor bus.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

165

USB ADDRESSING (2/2)


A hub may have any number of devices or other hubs
connected to it, and addresses are assigned arbitrarily. When
a device is first connected to a hub, or when it is powered on,
it has the address 0. The hardware of the hub to which this
device is connected is capable of detecting that the device has
been connected, and it records this fact as part of its own
status information. Periodically, the host polls each hub to
collect status information and learn about new devices that
may have been added or disconnected.
When the host is informed that a new device has been
connected, it uses a sequence of commands to send a reset
signal on the corresponding hub port, read information from
the device about its capabilities, send configuration
information to the device, and assign the device a unique USB
address. Once this sequence is completed the device begins
normal operation and responds only to the new address.
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

166

USB PROTOCOL
All information transferred over the USB is organized in packets,
where a packet consists of one or more bytes of information.
The information transferred on the USB can be divided into two
categories: control and data.
Control packets perform such tasks as addressing a device to
initiate data transfer, acknowledging that data have been
received correctly, or indicating an error.
Data packets carry information that is delivered to a device.
A packet consists of one or more fields containing different kinds of
information. The first field of any packet is called the packet
identifier (PID), which identifies the type of that packet.
They are transmitted twice. The first time they are sent with their
true values, and the second time with each bit complemented
The four PID bits identify one of 16 different packet types. Some
control packets, such as ACK (Acknowledge), consist only of the
PID byte.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

167

USB COMMUNICATION

Consists of a
series of
frames for a
complete
data transfer

SOF start of frame


SYNC synchronization
EOP end of packet
Source: cypress.com
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

168

PACKET TYPES
Token packets:
Initiate transaction
Identify device involved in transaction
Are always sourced by the host
Data packets:
Delivers payload data
Sourced by host or device
Handshake packets:
Acknowledge error-free data receipt
Sourced by receiver of data
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

169

PACKETS CONTENT

Packet format

Token packets

Data packets

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

Handshake packets
Source: cypress.com
170

PACKETS STRUCTURE

Token packet

SOF packet

Data packet

Handshake packet

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

171

OUTPUT TRANSFER
Host

Hub

USB device

Token
data 0
ACK
Time
Token
data 0

Communication flow:
from host to hub, then from
hub to USB IO device
layered communication
protocol

ACK
Token
data 1
ACK
Token
data 1
ACK

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

172

ISOCHRONOUS TRAFFIC
USB key objective: support the transfer of isochronous data.
Devices that generates or receives isochronous data require a time
reference to control the sampling process.
To provide this reference transmission over the USB is divided
into frames of equal length (1 ms long for low-and full-speed data).
The root hub generates a Start of Frame control packet (SOF)
precisely once every 1 ms to mark the beginning of a new frame.
The arrival of an SOF packet at any device constitutes a regular
clock signal that the device can use for its own purposes.
To assist devices that may need longer periods of time, the SOF
packet carries an 11-bit frame number.
Following each SOF packet, the host carries out input and output
transfers for isochronous devices.
This means that each device will have an opportunity for an input or
output transfer once every 1 ms.

Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

173

PACKET TIMING

Which is the time interval


between frames
Source: cypress.com
Computer Architecture and Organization (BEC30303) | Chapter 3: Input/Output

174

FINISH

Das könnte Ihnen auch gefallen