Unit 4
Unit 4
Architectures
Topic: Input Output Organization
Unit-IV
INPUT-OUTPUT ORGANIZATION
UNIT-IV
• Input-Output Processor
• Serial Communication
G.SWARNALATHA,Asst.Professor, GNITC
Peripheral Devices
G.SWARNALATHA,Asst.Professor, GNITC
UNIT-IV
G.SWARNALATHA,Asst.Professor, GNITC
UNIT-IV
G.SWARNALATHA,Asst.Professor, GNITC
Input/Output Interfaces
UNIT-IV INPUT/OUTPUT INTERFACE
• Provides a method for transferring information between internal storage
(such as memory and CPU registers) and external I/O devices
G.SWARNALATHA,Asst.Professor, GNITC
Input/Output Interfaces
UNIT-IV I/O BUS AND INTERFACE MODULES
I/O bus
Data
Processor Address
Control
Keyboard
and Printer Magnetic Magnetic
display disk tape
terminal
G.SWARNALATHA,Asst.Professor, GNITC
Input/Output Interfaces
UNIT-IV CONNECTION OF I/O BUS
Connection of I/O Bus to CPU
Op. Device Function Accumulator Computer
code address code register I/O
control
CPU
Sense lines
Data lines
Function code lines
I/O
bus
Device address lines
G.SWARNALATHA,Asst.Professor, GNITC
Input/Output Interfaces
UNIT-IV I/O BUS AND MEMORY BUS
Functions of Buses
* MEMORY BUS is for information transfers between CPU and the MM
* I/O BUS is for information transfers between CPU
and I/O devices through their I/O interface
Physical Organizations
* Many computers use a common single bus system
for both memory and I/O interface units
- Use one common bus but separate control lines for each funct
- Use one common bus with common control lines for both functions
* Some computer systems use two separate buses,
one to communicate with memory and the other with I/O interfaces
I/O Bus
- Communication between CPU and all interface units is via a common
I/O Bus
- An interface connected to a peripheral device may have a number of
data registers , a control register, and a status register
- A command is passed to the peripheral by sending
to the appropriate interface register
- Function code and sense lines are not needed (Transfer of data, control,
and status information is always via the common I/O Bus)
G.SWARNALATHA,Asst.Professor, GNITC
Input/Output Interfaces
Memory-mapped I/O
- A single set of read/write control lines
(no distinction between memory and I/O transfer)
- Memory and I/O addresses share the common address space
-> reduces memory address range available
- No specific input or output instruction
-> The same memory reference instructions can
be used for I/O transfers
- Considerable flexibility in handling I/O operations
G.SWARNALATHA,Asst.Professor, GNITC
Input/Output Interfaces
Internal bus
CPU Chip select CS
I/O
Register select RS1 Control Control Device
Timing register
Register select RS0 and
I/O read Control
RD Status Status
I/O write WR register
G.SWARNALATHA,Asst.Professor, GNITC
UNIT-IV
Input/Output Interfaces
Programmable Interface
Information in each port can be assigned a meaning depending on the
mode of operation of the I/O device
→ Port A = Data; Port B = Command; Port C = Status
CPU initializes(loads) each port by transferring a byte to the Control
Register
→ Allows CPU can define the mode of operation of each port
→ Programmable Port: By changing the bits in the control register, it is
possible to change the interface characteristics
G.SWARNALATHA,Asst.Professor, GNITC
Asynchronous Data Transfer
Strobe Strobe
G.SWARNALATHA,Asst.Professor, GNITC
Asynchronous Data Transfer
UNIT-IV HANDSHAKING
Strobe Methods
Source-Initiated
Destination-Initiated
G.SWARNALATHA,Asst.Professor, GNITC
Asynchronous Data Transfer
UNIT-IV SOURCE-INITIATED TRANSFER USING HANDSHAKE
Data bus
Source Data valid Destination
Block Diagram unit Data accepted unit
Valid data
Data bus
Timing Diagram
Data valid
Data accepted
Data valid
Valid data
Data bus
G.SWARNALATHA,Asst.Professor, GNITC
Asynchronous Data Transfer
UNIT-IV
DESTINATION-INITIATED TRANSFER USING HANDSHAKE
units
G.SWARNALATHA,Asst.Professor, GNITC
Asynchronous Data Transfer
1 1 0 0 0 1 0 1
Start Character bits Stop
bit bits
(1 bit) (at least 1 bit)
G.SWARNALATHA,Asst.Professor, GNITC
UNIT-IV
Asynchronous Data Transfer
UNIVERSAL ASYNCHRONOUS RECEIVER-TRANSMITTER
- UART -
A typical asynchronous communication interface available as an IC
Transmit
Bidirectional Transmitter Shift data
data bus Bus register register
buffers
Internal Bus
and clock
Chip select
CS
Register select Status Receiver Receiver CS RS Oper. Register selected
RS Timing clock
register control 0 x x None
I/O read and and clock 1 0 WR Transmitter register
RD Control 1 1 WR Control register
I/O write Receive 1 0 RD Receiver register
WR Receiver Shift data
1 1 RD Status register
register register
G.SWARNALATHA,Asst.Professor, GNITC
Asynchronous Data Transfer
UNIT-IV
UNIVERSAL ASYNCHRONOUS RECEIVER-TRANSMITTER
- UART -
Transmitter Register
Accepts a data byte(from CPU) through the data bus
Transferred to a shift register for serial transmission
Receiver
Receives serial information into another shift register
Complete data byte is sent to the receiver register
Status Register Bits
Used for I/O flags and for recording errors
Control Register Bits
Define baud rate, no. of bits in each character, whether
to generate and check parity, and no. of stop bits
G.SWARNALATHA,Asst.Professor, GNITC
UNIT-IV
Asynchronous Data Transfer
FIRST-IN-FIRST-OUT(FIFO) BUFFER
* Input data and output data at two different rates
* Output data are always in the same order in which the data entered the buffer.
* Useful in some applications when data is transferred asynchronously
4 x 4 FIFO Buffer (4 4-bit registers Ri),
4 Control Registers(flip-flops Fi, associated with each Ri)
R1 R2 R3 R4
Insert
S F1 S F2 S F3 S F4
Output
F'4 ready
R F'1 R F'
F2 R F'3 R
Master clear
G.SWARNALATHA,Asst.Professor, GNITC
UNIT-IVMODES OF TRANSFER - PROGRAM-CONTROLLED I/O
Modes of Transfer
G.SWARNALATHA,Asst.Professor, GNITC
Priority Interrupt
UNIT-IV
PRIORITY INTERRUPT
G.SWARNALATHA,Asst.Professor, GNITC
Priority Interrupt
UNIT-IV
HARDWARE PRIORITY INTERRUPT - DAISY-CHAIN -
Interrupt Request from any device(>=1)
-> CPU responds by INTACK <- 1
-> Any device receives signal(INTACK) 1 at PI puts the VAD on the bus
Among interrupt requesting devices the only device which is physically closest
to CPU gets INTACK=1, and it blocks INTACK to propagate to the next device
One stage of the daisy chain priority arrangement
VAD
Priority in Enable
PI
Vector address
G.SWARNALATHA,Asst.Professor, GNITC
Priority Interrupt
2
Interrupt
to CPU
3
INTACK
from CPU
G.SWARNALATHA,Asst.Professor, GNITC
Priority Interrupt
UNIT-IV
PARALLEL PRIORITY INTERRUPT
Interrupt Register:
Each bit is associated with an Interrupt Request from different
Interrupt Source - different priority level
Each bit can be cleared by a program instruction
Mask Register:
Mask Register is associated with Interrupt Register
Each bit can be set or cleared by an Instruction
G.SWARNALATHA,Asst.Professor, GNITC
Priority Interrupt
UNIT-IV
INTERRUPT PRIORITY ENCODER
Determines the highest priority interrupt whenmore than one
interrupts take place
Inputs Outputs
I0 I1 I2 I3 x y IST Boolean functions
1 d d d 0 0 1
0 1 d d 0 1 1
0 0 1 d 1 0 1 x = I 0' I 1'
0 0 0 1 1 1 1 y = I 0' I 1 + I 0’ I 2’
0 0 0 0 d d 0 (IST) = I0 + I1 + I2 + I3
G.SWARNALATHA,Asst.Professor, GNITC
Priority Interrupt
G.SWARNALATHA,Asst.Professor, GNITC
Priority Interrupt
UNIT-IV INTERRUPT SERVICE ROUTINE
address Memory I/O service programs
7
0 JMP DISK DISK Program to service
1 JMP PTR magnetic disk
VAD=00000011 3
2 JMP RDR PTR Program to service
3 JMP KBD line printer
8
1 Main program RDR
KBD Program to service
749 current instr.
interrupt 750 character reader
4
KBD Program to service
Stack
11 keyboard
5
2 255
256 Disk 256
750 interrupt
6 9 10
G.SWARNALATHA,Asst.Professor, GNITC
Priority Interrupt
UNIT-IV
INTERRUPT SERVICE ROUTINE
Initial Sequence:-
[1] Clear lower level Mask reg. bits
[2] IST <- 0
[3] Save contents of CPU registers
[4] IEN <- 1
[5] Go to Interrupt Service Routine
Final Sequence
[1] IEN <- 0
[2] Restore CPU registers
[3] Clear the bit in the Interrupt Reg
[4] Set lower level Mask reg. bits
[5] Restore return address, IEN <- 1
G.SWARNALATHA,Asst.Professor, GNITC
Direct Memory Access
UNIT-IV DIRECT MEMORY ACCESS
* Block of data transfer from high speed devices, Drum, Disk, Tape
* DMA controller - Interface which allows I/O transfer directly between
Memory and Device, freeing CPU for other tasks
* CPU initializes DMA Controller by sending memory
address and the block size(number of words)
CPU bus signals for DMA transfer
ABUS Address bus High-impedence
Bus request BR DBUS Data bus (disabled)
CPU when BG is
Bus granted BG RD Read
WR Write enabled
Bus grant BG
Interrupt Interrupt DMA request
DMA acknowledge to I/O device
G.SWARNALATHA,Asst.Professor, GNITC
Direct Memory Access
UNIT-IV DMA I/O OPERATION
Starting an I/O
- CPU executes instruction to
Load Memory Address Register
Load Word Counter
Load Function(Read or Write) to be performed
Issue a GO command
Input
[1] Input Device <- R (Read control signal)
[2] Buffer(DMA Controller) <- Input Byte; and
assembles the byte into a word until word is full
[4] M <- memory address, W(Write control signal)
[5] Address Reg <- Address Reg +1; WC(Word Counter) <- WC - 1
[6] If WC = 0, then Interrupt to acknowledge done, else go to [1]
G.SWARNALATHA,Asst.Professor, GNITC
Direct Memory Access
UNIT-IV
DMA I/O OPERATION
Output
[1] M <- M Address, R M Address R <- M Address R + 1,
WC <- WC - 1
[2] Disassemble the word
[3] Buffer <- One byte; Output Device <- W, for all
disassembled bytes
[4] If WC = 0, then Interrupt to acknowledge done, else go to [1]
G.SWARNALATHA,Asst.Professor, GNITC
Direct Memory Access
UNIT-IV CYCLE STEALING
DMA Controller and CPU both access Memory -> Memory Access Conflict
G.SWARNALATHA,Asst.Professor, GNITC
UNIT-IV
Direct Memory Access
CYCLE STEALING
Cycle Steal:-
G.SWARNALATHA,Asst.Professor, GNITC
UNIT-IV
Direct Memory Access
DMA TRANSFER
Interrupt
Random-access
BG
CPU memory unit (RAM)
BR
RD WR Addr Data RD WR Addr Data
Read control
Write control
Data bus
Address bus
Address
select
RD WR Addr Data
DS DMA ack.
RS DMA I/O
Controller Peripheral
BR device
BG DMA request
Interrupt
G.SWARNALATHA,Asst.Professor, GNITC
Input/Output Processor
Peripheral devices
Memory
unit PD PD PD PD
Input-output
processor
(IOP) I/O bus
Input/Output Processor
Continue
G.SWARNALATHA,Asst.Professor, GNITC
UNIT-IV
MEMORY HIERARCHY
MEMORY HIERARCHY
1.CPU Registers: These are the fastest storage locations within the CPU itself.
Registers hold data that the CPU is currently processing. They have the
smallest capacity and are the most expensive in terms of hardware.
2.Cache Memory: Cache memory sits between the CPU registers and the main
memory. It's faster than main memory but slower than registers. Cache
memory is typically divided into several levels (L1, L2, L3) based on proximity
to the CPU and size. The caches store frequently accessed data and
instructions to reduce the time needed to access them
G.SWARNALATHA,Asst.Professor, GNITC
MEMORY HIERARCHY
G.SWARNALATHA,Asst.Professor, GNITC
MEMORY HIERARCHY
G.SWARNALATHA,Asst.Professor, GNITC
MAIN MEMORY
G.SWARNALATHA,Asst.Professor, GNITC
Main Memory
G.SWARNALATHA,Asst.Professor, GNITC
Main Memory
G.SWARNALATHA,Asst.Professor, GNITC
Main Memory
G.SWARNALATHA,Asst.Professor, GNITC
Auxiliary Memory
file i
block 1 block 2
block 3 EOF
R1
R2 R3 R4
R5
R6
block 3 IRG
R1
EOF R3 R2
R5 R4 block 1
block 2
Track
G.SWARNALATHA,Asst.Professor, GNITC
Associative Memory
- Compare each word in CAM in parallel with the content of A(Argument Register)
- If CAM Word[i] = A, M(i) = 1
- Read sequentially accessing CAM for CAM Word(i) for M(i) = 1
- K(Key Register) provides a mask for choosing a
particular field or key in the argument in A
(only those bits in the argument that have 1’s in
their corresponding position of K are compared)
G.SWARNALATHA,Asst.Professor, GNITC
Associative Memory
G.SWARNALATHA,Asst.Professor, GNITC
Associative Memory
G.SWARNALATHA,Asst.Professor, GNITC
Cache Memory
G.SWARNALATHA,Asst.Professor, GNITC
Cache Memory
Cache memory
PERFORMANCE OF CACHE
Memory Access
All the memory accesses are directed first to Cache
If the word is in Cache; Access cache to provide it to CPU
If the word is not in Cache; Bring a block (or a line)
including
that word to replace a block now in Cache
UNIT-IV
PERFORMANCE OF CACHE
Te = Tc + (1 - h) Tm
G.SWARNALATHA,Asst.Professor, GNITC
Cache Memory
G.SWARNALATHA,Asst.Professor, GNITC
Cache Memory
G.SWARNALATHA,Asst.Professor, GNITC
Cache Memory
G.SWARNALATHA,Asst.Professor, GNITC
Cache Memory
G.SWARNALATHA,Asst.Professor, GNITC
Cache Memory
UNIT-IV
MEMORY AND CACHE MAPPING - SET ASSOCIATIVE MAPPING -
- Each memory block has a set of locations in the Cache to load
Set Associative Mapping Cache with set size of two
Operation
- CPU generates a memory address(TAG; INDEX)
- Access Cache with INDEX, (Cache word = (tag 0, data 0); (tag 1,
data 1))
- Compare TAG and tag 0 and then tag 1
- If tag i = TAG -> Hit, CPU <- data i
- If tag i TAG -> Miss,
Replace either (tag 0, data 0) or (tag 1, data 1),
Assume (tag 0, data 0) is selected for replacement,
(Why (tag 0, data 0) instead of (tag 1, data 1) ?)
M[tag 0, INDEX] <- Cache[INDEX](data 0)
Cache[INDEX](tag 0, data 0) <- (TAG, M[TAG,INDEX]),
CPU <- Cache[INDEX](data 0)
G.SWARNALATHA,Asst.Professor, GNITC
Cache Memory
G.SWARNALATHA,Asst.Professor, GNITC
Cache Memory
G.SWARNALATHA,Asst.Professor, GNITC