Unit 5 - Coa
Unit 5 - Coa
- INTRODUCTION
Input/Output Interfaces
INPUT/OUTPUT INTERFACES
* Provides a method for transferring information between internal storage
(such as memory and CPU registers) and external I/O devices
- Unit of Information
Peripherals - Byte
CPU or Memory - Word
- Operating Modes
Peripherals - Autonomous, Asynchronous
CPU or Memory - Synchronous
Input/Output Interfaces
Keyboard
and Printer Magnetic
disk
Magnetic
tape
display
terminal
Each peripheral has an interface module associated with it
Interface
- Decodes the device address (device code)
- Decodes the commands (operation)
- Provides signals for the peripheral controller
- Synchronizes the data flow and supervises
the transfer rate between peripheral and CPU or Memory
Typical I/O instruction
Op. code Device address Function code
(Command)
Introduction to Data Transfer Techniques
Handshaking
- A control signal is accompanied with each data
being transmitted to indicate the presence of data
- The receiving unit responds with another control
signal to acknowledge receipt of the data
Asynchronous Data Transfer
STROBE CONTROL
• The strobe may be activated by either the source or the destination unit
Strobe Strobe
• a strobe is a signal that is sent that validates
data or other signals on adjacent parallel lines.
In memory technology, the CAS (column
address strobe) and RAS ( row
address strobe ) signals are used to tell a
dynamic RAM that an address is a column or
row address.
Asynchronous Data Transfer
HANDSHAKING
Strobe Methods
Source-Initiated
Destination-Initiated
Valid data
Data bus
Timing Diagram
Data valid
Data accepted
Data valid
Valid data
Data bus
Address and
command
Data
t0 t1 t2
Bus cycle
Master places the
device address and Addressed slave places
command on the bus, data on the data lines Master “strobes” the data
and indicates that on the data lines into its
it is a Read operation. input buffer, for a Read
operation.
• In case of a Write operation, the master places the data on the bus along with the
address and commands at time t0.
• The slave strobes the data into its input buffer at time t2.
Synchronous bus (contd..)
Once the master places the device address and
command on the bus, it takes time for this
information to propagate to the devices:
◦ This time depends on the physical and electrical characteristics of the bus.
Data
Address & t DM
command reach
Seen by slave
the slave. tAS
Address and Data appears
command on the bus.
Data
tDS
t0 t1 t
2
• 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 of the bus.
• Data must remain on the bus for some time after t2 equal to the hold time of the buffer.
Synchronous bus (contd..)
• 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.
Address
Command
Master strobes data
into the input buffer.
Data
Slave-ready
Slave places the data on the bus, Clock changes are seen by all the devices
and asserts Slave-ready signal. at the same time.
Asynchronous bus
Data transfers on the bus is controlled by a handshake
between the master and the slave.
Common clock in the synchronous bus case is replaced by
two timing control lines:
Master-ready,
Slave-ready.
Master-ready
Slave-ready
Data
t0 t1 t2 t3 t4 t5
Bus cycle
t0 - Master places the address and command information on the bus.
t1 - Master asserts the Master-ready signal. Master-ready signal is asserted at t 1 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 Slave-ready signal from the bus.
Asynchronous vs. Synchronous bus
• Advantages of asynchronous bus:
– Eliminates the need for synchronization between the sender and the receiver.
– Can accommodate varying delays automatically, using the Slave-ready signal.
25
Introduction of uart & usart
26
WHY USE A UART?
A UART may be used when:
High speed is not required
An inexpensive communication link between two devices is required
27
BASICS OF SERIAL COMMUNICATION
Bit rate:
Baud rate:
-Number of symbols sent every second, where every symbol can represent more than
one bit.
Ex. high-speed modems which use phase shifts to make every data transition period
represent more than one bit.
-For the PIC 16f877A’s USART, with every clock tick one bit is sent, each symbol
represents one bit.
-So, we can consider bit rate and baud rate the same thing.
28
TRANSMISSION REQUIREMENT
- 5, 6, 7 or 8 data bits
29
BASIC BLOCK DIAGRAM OF UART
30
BASIC BLOCK DIAGRAM OF UART
UART/USART TRANSMITTER
TRMT bit:
Once the data in the TSR register has been clocked out on the TX pin(at
the beginning of the STOP bit), the TRMT bit in the TXSTA register will be
set,
Indicating that the transmission has been completed.
33
UART/USART RECIEVER
1. The clock of the receiver is a multiple of the bit rate, in PIC 16f877A,it’s x16
or x64. So, each bit is transmitted/received in 16 clock cycle.
2. If the receiver detects a start bit for a period= bit period (16 clock cycles),
then it waits for the period of half bit, and then sample the value on the RX
pin and shift it in the receiving shift register.
34
RECEIVER CONTD.
3. Every received bit is sampled at the middle of the bit’s time period.
4. The USART can be configured to receive eight or nine bits by the RX9 bit in the
RCSTA register.
5. After the detection of a START bit, eight or nine bits of serial data are shifted
from the RX pin into the Receive Shift Register, one bit at a time.
6. After the last bit has been shifted in, the STOP bit is checked and the data is
moved into the FIFO buffer.
7. RCREG is the output of the two element FIFO buffer. A next start bit can be sent
immediately after the stop bit.
35
UART CHARACTER TRANSMISSION
mark
space
Time
36
UART REGISTERS
To use and control the UART, special internal registers are assigned to them. Usually
there will be at least four registers: control, status, receive and transmit registers. All
these vary in size depending on the MCU.
1) Control Register - Contains settings for the UART. Some common settings/features
include: Number of data bits, number of stop bits, parity control, UART TX/RX
enable/disable, baud rate setting, RX/TX interrupt enable, etc.
2) Status Register - From its name, this contains information about the UART's condition
or state. During run-time, this register may be helpful in guiding the processor on the
next instruction to execute like when to retrieve data. Information that can be retrieved
include: data send/receive ready, etc.
37
UART Interfacing
38
MC6850 UART
MC6850 UART
4 UART registers accessible by CPU selected
by R/~W and RS (register select):
– 00: control register
– 01: transmit data register
– 10: status register
– 11: receive data register
MC6850 UART
UART control register: initialized by
program;
bits to divide tx/rec clocks by factor of 1, 16, or
64, select # of data bytes, type of parity, # of
stop bits, and interrupt control
• UART status register: status/error bits that
may either generate interrupts or be polled
by s/w:
– Received data reg. full (set when data transferred from serial input reg. to rec’d
data reg., reset when CPU reads data) to see if new data has arrived since last data
read
– Transmit data reg. empty (set when data transferred from transmit data reg. to
serial output reg.)
– RS-232 modem handshaking bits (DCD, CTS)
UART Status Register
Interrupt request output bit (shows state of h/w IRQ)
• Error bits
– Framing error? UART detects an invalid stop bit
– Receiver overrun error? when data transferred from
serial input
reg. to rec’d data reg. before CPU has read last data; s/w
not
reading data fast enough, and data possibly lost
– Parity error? received character does not match
scheme ⇒ error in code word
Flow Control
Refers to higher level of handshaking to control s/w
transferring data
Computer perhaps unable to deal with incoming
data quickly enough, data may be lost
Destination sends message to source to stop
sending data until ready to receive more
H/W flow control: RTS and CTS handshaking signals
used as h/w flow control; computer must control
these bits in the communication s/w
– Requires full DTE-DCE cable or full DTE-DTE null-
modem cable (need RTS/CTS)
Accessing I/O Devices
Accessing I/O devices
Processor Memory
Bus
• 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.
Accessing I/O devices (contd..)
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 or
from an I/O device.
Simpler software.
47
Accessing I/O devices (contd..)
Address lines
Bus Data lines
Control lines
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.
Accessing I/O devices (contd..)
Recall that the rate of transfer to and 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.
1
2
Interrupt
occurs i
here
i +1
INTA1 INTA p
Priority arbitration
Device Device
INTA1
Processor
INTR p
Device Device
INTAp
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.
Interrupts (contd..)
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.
• 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.
Exceptions (contd..)
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.
Direct Memory Access
Direct Memory Access (contd..)
Direct Memory Access (DMA):
A special control unit may be provided to transfer a block of data directly between an
I/O device and the main memory, without continuous intervention by the processor.
System bus
Centralized arbitration:
A single bus arbiter performs the arbitration.
Distributed arbitration:
All devices participate in the selection of the next bus master.
Centralized Bus Arbitration
B BS Y
BR
Processor
DMA DMA
controller controller
BG1 1 BG2 2
Centralized Bus Arbitration(cont.,)
• Bus arbiter may be the processor or a separate unit connected to the
bus.
• Normally, the processor is the bus master, unless it grants bus
membership to one of the DMA controllers.
• 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.
Centralized arbitration (contd..)
DMA controller 2
asserts the BR signal. Time
Processor asserts
BR
the BG1 signal
BBSY
Bus
master
Processor DMA controller 2 Processor
Arbitration process:
• 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.
• 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.
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
Control
Address
DATAIN Data
Encoder
R /W and Keyboard
Processor SIN
debouncing switches
Master-ready circuit
Valid
Input
Slave-ready
interface
Address
DATAIN Data
Encoder
R/W and Keyboard
Processor SIN
debouncing switches
Master-ready circuit
Valid
Input
Slave-ready
interface
Processor
CPU R /W SOUT Printer
Valid
Master-ready
Output Idle
Slave-ready interface
Processor
CPU R /W SOUT Printer
Valid
Master-ready
Output Idle
Slave-ready interface
DATAIN
D1
D0 PA0
SIN
• Combined I/O interface circuit.
Input
CA
• Address bits A2 through A31, that is
status
30 bits are used to select the overall
PB7
interface.
DATAOUT • Address bits A1 through A0, that is, 2
bits select one of the three registers,
PB0
SOUT
namely, DATAIN, DATAOUT, and
CB1
Handshake
control
the status register.
CB2
Slave-
Ready 1 • Status register contains the flags SIN and
SOUT in bits 0 and 1.
• Data lines PA0 through PA7 connect the
Master- input device to the DATAIN register.
Ready
R/ W
• DATAOUT register connects the data
A31 lines on the processor bus to lines PB0
My-address
Address
decoder through PB7 which connect to the output
A2 device.
A1
RS1 • Separate input and output data lines for
connection to an I/O device.
RS0
A0
D7 P7
• Data lines to I/O device are bidirectional.
DATAIN • Data lines P7 through P0 can be used for
D0
both input, and output.
P0
• In fact, some lines can be used for input &
some for output depending on the pattern
in the Data Direction Register (DDR).
DATAOUT • Processor places an 8-bit pattern into a DDR
• If a given bit position in the DDR is 1, the
corresponding data line acts as an output
line, otherwise it acts as an input line.
• C1 and C2 control the interaction between
Data
Direction the interface circuit and the I/O devices.
Register
• Ready and Accept lines are the handshake
control lines on the processor bus side, and
My-address
are connected to Master-ready & Slave-ready.
RS2
• Input signal My-address is connected to the
C1
RS1 Status output of an address decoder.
Register
RS0 and
R/W
select control • Three register select lines that allow up to 8
Ready C2 registers to be selected.
Accept
INTR
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.
Input shift register Serial
input
• Input shift register accepts input one bit
at a time from the I/O device.
DATAIN • 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.
D7 • Bits are shifted out of the output shift
register and sent out to the I/O device one
D0 bit at a time.
• As soon as data from the input shift reg.
My-address DATAOUT
are loaded into DATAIN, it can start
accepting another 8 bits of data.
RS1
• Input shift register and DATAIN registers
RS0
Chip and are both used at input so that the input
Serial
R /W register Output shift re gister
Ready select shift register can start receiving another
Accept set of 8 bits from the input device after
loading the contents to DATAIN, before
Receiving clock
the processor reads the contents of
I NTR Status
and
ransmission clock
DATAIN. This is called as double-
control
T buffering.
erial port (contd..)
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.
108
Standard I/O interfaces (contd..)
Main
Processor
memory
Bridge circuit translates
signals and protocols from
Processor bus
processor bus to PCI bus.
Bridge
PCI bus
Expansion bus on
the motherboard
Additional SCSI Ethernet USB ISA
memory controller Interface controller Interface
SCSI bus
IDE
disk
Video
Disk CD-ROM
controller controller
CD-
Disk 1 Disk 2 ROM K eyboard Game
PCI Bus
Peripheral Component Interconnect
Introduced in 1992
Low-cost bus
Processor independent
Plug-and-play capability
In today’s computers, most memory transfers involve a burst of data rather than just
one word. The PCI is designed primarily to support this mode of operation.
The bus supports three independent address spaces: memory, I/O, and configuration.
we assumed that 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 in PCI terminology. The addressed device that responds
to read and write commands is called a target.
Data transfer signals on the PCI bus.
Name Function
CLK
Frame#
AD Adress #1 #2 #3 #4
IRDY#
TRD Y#
DEVSEL#
DB 2
DB 5
DB 6
BS Y
S EL
Host computer
Root
hub
Hub Hub
I/O I/O
de vice de vice
Universal Serial Bus tree structure
To accommodate a large number of devices that can be added or removed at
any time, the USB has the tree structure as shown in the figure.
Each node of the tree has a device called a hub, which 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 (for example, keyboard, Internet connection,
speaker, or digital TV)
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.
Addressing
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.
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.
USB Protocols
All information transferred over the USB is organized in packets, where a packet
consists of one or more bytes of information. There are many types of packets
that perform a variety of control functions.
The information transferred on the USB can be divided into two broad
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.
PID0 PID1 PID2 PID3 PID0 PID1 PID2 PID3
Bits 8 7 4 5
Control packets used for
PID ADDR ENDP CRC16 controlling data transfer
operations are called token
packets.
(b) Token packet, IN or OUT
Bits 8 0 to 8192 16
Token
Data0
ACK
Time
Token
Data0
ACK
Token
Data1
Figure: An output
transfer
ACK
Token
Data1
ACK
Isochronous Traffic on USB
One of the key objectives of the USB is to 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.
A frame is 1ms 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.
Electrical Characteristics
The cables used for USB connections consist of four wires.
Two are used to carry power, +5V and Ground.
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.
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 o the two signal wires.
For high-speed links, differential transmission is used.
Firewire
IEEE 1394 is an interface standard for a serial bus for high-speed
communications and isochronous real-time data transfer. It was
developed in the late 1980s and early 1990s by Apple, which
called it FireWire. The 1394 interface is also known by the
brands i.LINK(Sony), and Lynx (Texas Instruments).
The copper cable it uses in its most common implementation can
be up to 4.5 metres (15 ft) long. Power is also carried over this
cable, allowing devices with moderate power requirements to
operate without a separate power supply. FireWire is also
available in Cat 5 and optical fiber versions.
The 1394 interface is comparable to USB, though USB requires a
master controller and has greater market share
Serial Advanced Technology
Attachment (SATA)
SATA Uses in the Enterprise
• SAS improves drive addressability and connectivity using an expander that enables one or
more SAS host controllers to connect to a large number of drives. Each expander allows
connectivity to 128 physical links, which may include other host connections, other SAS
expanders or hard disks. This highly scalable connection scheme enables enterprise-level
topologies that easily support multi-node clustering for automatic failover availability or
load balancing.
• SAS improves drive addressability and connectivity using an expander that enables one or
more SAS host controllers to connect to a large number of drives. Each expander allows
connectivity to 128 physical links, which may include other host connections, other SAS
expanders or hard disks. This highly scalable connection scheme enables enterprise-level
topologies that easily support multi-node clustering for automatic failover availability or
load balancing
PCI Express Solution
Advanced Switching with PCI Express
outdated
• A new model of PCI, called PCI Express will replace
the dated architecture giving it life for another decade
IO Channel
Input/output channel. Alternatively referred to as the
input channel and I/O channel, the input/output channel is a line
of communication between the input/output bus or memory to the
CPU or computer peripherals
The input/output processor or I/O processor is a processor that is
separate from the main processor or CPU and is designed to
handle only input/output processes for a device or the computer. ... A
more advanced I/O processor may also have memory built into it,
allowing it to perform actions and activities more quickly.
Input/Output Processor
An input-output processor (IOP) is a processor with direct memory access
capability. In this, the computer system is divided into a memory unit and number
of processors.
Each IOP controls and manage the input-output tasks. The IOP is similar to CPU
except that it handles only the details of I/O processing. The IOP can fetch and
execute its own instructions. These IOP instructions are designed to manage I/O
transfers only.
Block Diagram Of I/O Processor
Below is a block diagram of a computer along with various I/O Processors. The
memory unit occupies the central position and can communicate with each
processor.
The CPU processes the data required for solving the computational tasks. The
IOP provides a path for transfer of data between peripherals and memory. The
CPU assigns the task of initiating the I/O program.
The IOP operates independent from CPU and transfer data between peripherals
and memory.
The communication between the IOP and the devices is similar to the program
control method of transfer. And the communication with the memory is similar to
the direct memory access method.
The CPU can act as master and the IOP act as slave processor. The CPU assigns
the task of initiating operations but it is the IOP, who executes the instructions, and
not the CPU. CPU instructions provide operations to start an I/O transfer. The IOP
asks for CPU through interrupt.
Instructions that are read from memory by an IOP are also called commands to
distinguish them from instructions that are read by CPU. Commands are prepared
by programmers and are stored in memory. Command words make the program
for IOP. CPU informs the IOP where to find the commands in memory.