3 Memory Interface
3 Memory Interface
LEARNING OBJECTIVES
MeMorY Interface The memory responds by placing the data from the addressed loca-
tion onto the data lines and confirms the actions. Upon confirma-
Basic Concepts tion, the processor loads the data onto the data lines, into MDR
Computer memory is used to store programs and data. The maxi- register. The processor writes the data into the memory location by
mum size of a memory that can be used in any computer is deter- loading the address of this location into MAR and loading the data
mined by the addressing scheme. into MDR sets the R /W line to 0.
Example: If the memory address has 16-bits, then the size of • Memory Access Time: It is the time that elapses between
memory will be 216 Bytes. the initiation of an operation and the completion of that
operation.
Memory CPU
• Memory Cycle Time: It is the minimum time delay that
k -bit address required between the initiations of two successive memory
Upto 2k bus operations.
addressable MAR
lines n-bit data
Word length bus
= n bits
MBR RAM (Random Access Memory)
Control lines In RAM, if any location that can be accessed for a read/write oper-
ation in fixed amount of time, it is independent of the location’s
address:
If MAR is k-bits long and MDR is n-bits long, then the memory
may contain up to 2k addressable locations and the n-bits of data • Memory cells are usually organized in the form of array, in
are transferred between the processor and memory. This transfer which each cell is capable of storing one bit of information.
takes place over processor bus. The processor bus has • Each row of cells constitutes a memory word and all cells of a
1. Address line row are connected to a common line called as word line.
2. Data line • The cells in each column are connected to sense/write circuit by
3. Control line two bit lines.
Control line is used for coordinating data transfer. The data input and data output of each sense/write circuit are con-
Processor reads the data from the memory by loading the nected to a single bidirectional data line that can be connected to
address of the required memory location into MAR and setting the a data bus.
R /W line to 1.
2.34 | Unit 2 • Computer O
rganization and Architecture
b7 b 7′ b1 b 1′ b0 b 0′
W0
W1
A0 W2
A1 Address
A2 Decoder Memory cells
A3
Word line
•• R /W : Specifies the required operation.
•• CS: Chip select input selects a given chip in the multi-chip
memory system.
T
C
Static memories
Memories that consist of circuits capable of retaining their
state as long as power is applied are known as static memories. Bit line
If charge on capacitor > threshold value, then bit line will
SRAM (static RAM) SRAM consists of two inverters, two have ‘1’. If charge on capacitor < threshold value, then bit
transistors. In order to read the state of the SRAM cell, the line will have ‘0’.
word line is activated to close switches T1 and T2.
DRAM SRAM
b b′ 1. Volatile 1. Volatile
l1 2. Simple to build and slower 2. Faster than DRAM
T1 T2 than SRAM
3. Need refresh circuitry 3. More expensive to build
l2
4. Favoured for large memory 4. Favoured for cache memory
Word line units
Bit lines
Latency It is the amount of time it takes to transfer a word
Advantages of SRAM: of data to or from the memory.
1. It has low power consumption, because the current •• For the transfer of a single word, the latency provides the
flows in the cell only when the cell is being activated complete indication of memory performance.
or accessed. •• For a block transfer, the latency denotes the time it takes
2. SRAM can be accessed quickly. to transfer the first word of data.
Disadvantages of SRAM: SRAMs are said to be volatile Bandwidth It is defined as the number of bits or bytes that
memories, because their contents are lost when the power can be transferred in one second.
is interrupted.
Note: All dynamic memories have to be refreshed.
DRAM (Dynamic RAM) Less expensive RAMs can be
implemented if simplex cells are used, such cells cannot CS1
CS1
retain their state indefinitely. Hence they are called dynamic CS2
CS2
RAMs. Read
8-bit
RD 128 × 8
The information stored in a dynamic memory cell in the RAM
bidirectional
Write data bas
form of a charge on a capacitor and this charge can be main- WR
tained only for tens of milliseconds. 7-bit address
AD1 − AD 7
The contents must be periodically refreshed by restoring
the capacitor charge to its full value.
Example: Single-transistor dynamic memory cell: Figure 2 RAM chip block diagram
Chapter 3 • Memory Interface, I/O Interface | 2.35
Read-only Memory (ROM) register of a memory chip. To perform this, the micropro-
Both SRAM and DRAM chips are volatile, which means cessor should be
that they lose the stored information if power is turned off. 1. able to select the chip.
If the normal operation involves only reading of stored data, 2. identify the register.
use ROM memory. 3. enable the appropriate buffer.
Word line
Input–output Interfacing
T
Basic Concepts of I/O Module
Connected to store 0. I/O module contains logic for performing a communication
P
Not connected to store 1. function between the peripherals and the bus. The peripher-
als are not connected to the system bus directly. The reasons
for this are
Figure 3 ROM cell
1. Peripherals are electromechanical and electromag
netic devices and their manner of operation is
Types of ROM different from the operation of the CPU and memory,
Different types of non-volatile ROM are: which are electronicdevices. So a conversion of signal
values may be required.
1. PROM (Programmable ROM): 2. The data transfer rate of peripherals is usually
•• Allows the data to be loaded by the user. slower than the transfer rate of the CPU and hence a
•• Less expensive, faster, flexible. synchronization mechanism may be needed.
2. EPROM (Erasable PROM): 3. Data codes and formats in peripherals differ from the
•• Allows the stored data to be erased and new data word format in the CPU and memory.
to be loaded. 4. The operating modes of peripherals are different from
•• Flexible, retain information for a long time. each other and each must be controlled so as not to
•• Contents erased by UV light. disturb the operation of other peripherals connected
to the CPU.
3. EEPROM (Electrically Erasable PROM):
•• Programmed and erased electrically. To resolve these differences, computer systems include spe-
•• Allows the erasing of all cell contents selectively. cial hardware components between the CPU and peripherals
•• Requires different voltage for erasing, writing and to supervise and synchronize all input and output transfers.
reading of stored data. These components are called ‘interface’ units.
4. Flash memory: Allows to read the contents of a By using this interfacing,
single cell but it is only possible to write the entire
contents of a block. 1. interface to the processor and memory via the system
bus or central switch.
2. interface to one or more peripheral devices by tailored
data links.
Chip select 1 CS1
512 × 8
ROM 8-bit
Chip select 2 CS2 unidirectional
Input–output devices
data bas •• Input and Output devices provide a means for people to
make use of a computer.
9-bit address AD 1 − AD 9 •• Some I/O devices function as an interface between a
computer system and other physical system.
Figure 4 Block diagram of ROM chip
Input–output interface
Input/output Interface provides a method for transferring
Memory Interfacing information between internal storage (such as memory
The interfacing circuit enables the access of processor to and CPU Register) and external I/O devices. It resolves
memory. The function of memory interfacing is that the the difference between the computer and peripheral
processor should be able to read from and write into a given devices.
2.36 | Unit 2 • Computer O
rganization and Architecture
Input–output bus and interface modules In asynchronous transmission, binary information is sent
Each peripheral has an interface module associated with it. only when it is available and the line remains idle when
The interface module decodes the device address (device there is no information to be transmitted.
code), decodes signals for the peripheral controller, syn- In serial asynchronous transmission technique, each
chronizes the data flow and supervises the transfer rate character consists of three parts:
between peripheral and CPU or memory. 1. start bits
2. character bits
3. stop bits
Data
Processor Address Example:
Control
1 1 0 0 0 1 0 1
Interface Interface Interface Star bit Character bits Stop bits
Data valid No
Done?
Data Yes
accepted
Next instruction
Interrupt
Read status
Restore
of I/O module Processor signals
I/O CPU Process State
acknowledgement Information
of interrupt
Processor loads
new PC value
Write word
CPU Memory based on interrupt
into memory
System bus
Data count
Address
Address line register
I/O I/O I/O
DMA request With DMA, when the CPU wishes to read or write a block
DMA acknowledgement of data, it issues a command to the DMA module, by send-
Control ing the following information to the DMA module.
Interrupt logic
Read 1. Whether a read or write is requested.
Write 2. The address of the I/O device involved.
3. The starting location in memory to read from or write to.
4. The number of words to be read or written.
Figure 10 DMA Block Diagram
The CPU then continues with other work. It has delegates
The DMA module is capable of mimicking the processor this I/O operation to the DMA module, and that module will
and indeed, of taking over control of the system from the take care of it. The DMA module transfers the entire block
processor. It needs to do this to transfer data to and from of data, one word at a time, directly to or from memory,
memory over the system bus. For this purpose, the DMA without going through the CPU. When the transfer is com-
module must use the bus only when the processor does not plete, the DMA module sends an interrupt signal to the
need it or it must force the processor to suspend operation CPU. Thus, the CPU is involved only at the beginning and
temporarily. The latter technique is more common and is end of the transfer.
referred as cycle stealing.
DMA configurations
1. Single bus, detached DMA Issue read CPU DMA
block
•• Inexpensive, inefficient command to Do something
•• Each transfer of a word consumes two bus cycles. DMA module else
•• For those slow CPU, DMA Controller may steal •• Unlike DMA, the IOP can fetch and execute its own
most of the memory. instructions.
•• Cycle stealing, which may cause CPU remain idle
The following figure shows a computer with two
long time.
processors:
Exercises
Practice Problems 1 of the device. If the device is not ready, the processor
Directions for questions 1 to 20: Select the correct alterna- can jump to other tasks. After some timed interval, the
tive from the given choices. processor comes back to check status again. Let us
assume that above scheme is used for outputting data
1. Consider a DRAM that must be given a refresh cycle one character at a time to a printer that operates at 10
64 times per ms. Each refresh operation requires characters per second (CPS). Which of the following
150 ns, a memory cycle requires 250 ns. What is the statement is true if its status is scanned every 200 ms?
approximate percentage of the memory’s total operat- (A) The printing speed is increased by 5 CPS
ing time must be given to refreshes? (B) The printing rate is slowed to 5 CPS
(A) 1% (B) 2% (C) The printing rate is at 10 CPS only
(C) 9% (D) 60% (D) The printing rate is at 20 CPS
2. A DMA controller transfers 16-bit words to memory
5. Consider a system employing interrupt-driven I/O for
using cycle stealing. The words are assembled from a
a particular device that transfers data at an average of 8
device that transmits characters at a rate of 2400 char-
KB/s on a continuous basis. The interrupt processing
acters per second. The CPU is fetching and executing
takes about 100 ms and the I/O device interrupts processor
instructions at an average rate of 1 million instructions
for every byte. Let assume that the device has two 16-byte
per second. By how much time will the CPU be slowed
buffers and interrupts the processor when one of the buffer
down because of the DMA transfer?
is full. While executing the ISR, the processor takes about
(A) 0.6% (B) 0.1%
8 ms for the transfer of each byte. Then what is the fraction
(C) 0.12% (D) 0.24%
of processor time is consumed by this I/O device?
3. A system is based on a 16-bit microprocessor and has
(A) 8% (B) 11%
two I/O devices. The I/O controllers for this system use
(C) 50% (D) 65%
separate control and status registers. Both devices han-
dle data on a one-byte-at-a time basis. The first device 6. A 32-bit computer has two selector channels one mul-
has two status lines and three control lines. The sec- tiplexor channel. Each selector channel supports two
ond device has three status lines and four control lines. magnetic disks and three magnetic tape units. The mul-
How many 16-bit I/O control module registers do we tiplexor channel has two line printers, two card readers
need for status reading and control of each device? and 10 VDT terminals connected to it. Assume the fol-
(A) 1, 2 (B) 2, 1 lowing transfer rates:
(C) 2, 2 (D) 1, 1 Disk drive: 1000 KB/sec
4. In a programmed I/O technique, the processor is stuck Magnetic tape drive: 300 KB/sec
in a wait loop doing status checking of an I/O device. Line printer: 6.2 KB/sec
To increase efficiency, the I/O software could be writ- Card reader: 2.4 KB/sec
ten so that the processor periodically checks the status VDT: 1 KB/sec
2.42 | Unit 2 • Computer O
rganization and Architecture
What is the maximum aggregate I/O transfer rate of (A) Interrupt vectoring (B) Cycle stealing
this system? (C) DMA (D) Daisy chain
(A) 1625.6 KB/s (B) 1327.2 KB/s
(C) 2027.2 KN/s (D) 2327.2 KB/s 15. What will be the response of the CPU, on receiving an
interrupt from an input/output device?
7. Consider a disk drive with 16 surfaces, 512 tracks per (A) It hands over the control of address bus and data
surface and 512 sectors per track, 1 kilo bytes per sector bus to the interrupting device.
and a Rotation speed of 3000 RPM. The disk is oper- (B) It branches off to the interrupt service routine after
ated in cycle stealing mode where by whenever one 4 completion of the current instruction.
byte word is ready it is sent to memory; similarly, for (C) It halts for a predetermined time.
writing, the disk interface read a 4 byte word from the (D) It branches off to the interrupt service routine im-
memory in each DMA cycle. The memory cycle time mediately.
is 40 nsec. Find the maximum percentage of time that
16. What is the bandwidth of memory system that has a
the CPU gets blocked during DMA operation?
latency of 50ns, a pre charge time of 10ns and transfers
(A) 2.62% (B) 26.21%
2 bytes of data per access?
(C) 0.26% (D) 0.52%
(A) 60 B/sec (B) 1.67 B/sec
8. How many RAM chips of size (256 K × 1-bit) are (C) 1.67 × 107 B/sec (D) 3.33 × 107 B/sec
needed to build a 1 M Byte memory? 17. A hard disk is connected to a 50MHz processor through
(A) 16 (B) 8 a DMA controller. Assume that the initial set-up of a
(C) 32 (D) 24 DMA transfer takes 2000 clock cycles for the proces-
9. Four memory chips of 16 × 4 size have their address sor and also assume that the handling of the interrupt
bases connected together. The whole system will have at DMA completion requires 1000 clock cycles for the
a size of processor. The hard disk has a transfer rate of 4000
(A) 16 × 8 (B) 64 × 64 K bytes/sec and average block size transferred is 8 K
(C) 16 × 16 (D) 256 × 1 bytes. What fraction of the processor time is consumed
by the disk, if the disk is actively transferring 100% of
10. In which of following I/O techniques, there will be no the time?
interrupt? (A) 1% (B) 1.5%
(A) Programmed I/O (B) Interrupt-driven I/O (C) 2% (D) 3%
(C) DMA (D) Both (B) and (C)
18. A device with transfer rate of 20KB/sec is connected
11. The capacity of a memory unit is defined by the num- to a CPU. Data is transferred byte wise. Let the inter-
ber of words multiplied by the number of bits/word. rupt overhead is 6 micro seconds. The byte transfer
How many separate address and data lines are needed time between the device interface register and CPU or
for a memory 16K × 16? memory is negligible. What is minimum performance
(A) 10 address, 4 data lines gain of operating the device under interrupt mode over
(B) 14, 4 operating it under program-controlled mode?
(C) 14, 16 (A) 6 (B) 8
(D) 14, 14 (C) 10 (D) 12
12. The main problem of strobe asynchronous data transfer is 19. A DMA module is transferring characters to main
(A) it employs a single control line memory from an external device at 76800 bits per
(B) it is controlled by clock pulses in the CPU. second. The processor can fetch instructions at a rate
(C) the falling edge again used to trigger of 2 million instructions per second. How much will
(D) no way of knowing whether the destination has re- the processor be slowed down due to DMA activity?
ceived the data item. (Express this as a percent of the time from when there
13. Which of the following DMA transfer modes and is a conflict between DMA and the CPU)
interrupt handling mechanisms will enable the highest (A) 0.24% (B) 0.48%
I/O bandwidth? (C) 0.96% (D) 0.50%
(A) Block transfer and polling interrupt 20. Let us suppose that we want to read 2048 bytes in pro-
(B) Cycle stealing and polling interrupt grammed I/O mode of CPU. The bus width is 32-bits.
(C) Block transfer and vectored interrupt Each time an interrupt occurs from Hard disk drive and
(D) Transparent DMA and vectored interrupt it taken 4 msec to service it. How much CPU time is
14. Which of the following enables peripherals to pass a required to read 2048 bytes?
signal down the bus to the next device on the bus dur- (A) 512 msec (B) 768 msec
ing polling of the device? (C) 1024 msec (D) 2048 msec
Chapter 3 • Memory Interface, I/O Interface | 2.43
19. Which one of the following is true for a CPU having a 20. In which of the following I/O, there is a single address
single interrupt request line and a single interrupt grant space for memory locations and I/O devices
line? (A) Isolated I/O
(A) Vectored interrupt multiple interrupting devices (B) Memory mapped I/O
are always possible. (C) DMA
(B) Vectored interrupts are not possible but multiple (D) Both (A) and (B)
interrupting devices are possible
(C) Vectored interrupts and multiple interrupting de- 21. ____ signal used to interrupt processor and to execute
vices are sometimes possible service routine that takes an error recovery action.
(D) Vectored interrupt is possible but multiple inter- (A) Strobe (B) Handshaking
rupting devices are not possible (C) Polling (D) Time out
Initialize the address register. nanoseconds. The time required to perform one
Initialize the count to 500 refresh operation on all the cells in the memory unit
LOOP: Load a byte from device is [2010]
(A) 100 nanoseconds
Store in memory at address given by address register.
(B) 100 * 210 nanoseconds
Increment the address register
(C) 100 * 220 nanoseconds
Decrement the count
(D) 3200 * 220 nanoseconds
If count! = 0 go to LOOP
10. A processor can support a maximum memory of 4GB,
Assume that each statement in this program is equiva-
where the memory is word - addressable (a word con-
lent to a machine instruction which takes one clock sists of two bytes). The size of the address bus of the
cycle to execute if it is a non-load/store instruction.
processor is atleast ___ bits. [2016]
The load-store instructions take two clock cycles to
execute. 11. The size of the data count register of a DMA control-
ler is 16 bits. The processor needs to transfer a file
The designer of the system also has an alternate
of 29,154 kilobytes from disk to main memory. The
approach of using the DMA controller to implement
memory is byte addressable. The minimum number
the same transfer. The DMA controller requires 20 of times the DMA controller needs to get the control
clock cycles for initialization and other overheads. of the system bus from the processor to transfer the
Each DMA transfer cycle takes two clock cycles file from the disk to main memory is _____. [2016]
to transfer one byte of data from the device to the
memory. 12. The following are some events that occur after a
device controller issues an interrupt while process L
What is the approximate speedup when the DMA is under execution.
controller based design is used in place of the inter-
(P) The processor pushes the process status of L onto
rupt driven program based input-output? [2011]
the control stack.
(A) 3.4 (B) 4.4
(Q) The processor finishes the execution of the cur-
(C) 5.1 (D) 6.7
rent instruction.
8. Which of the following statements about synchronous (R) The processor executes the interrupt service rou-
and asynchronous I/O is NOT true? [2008] tine.
(A) An ISR is invoked on completion of I/O in syn- (S) The processor pops the process status of L from
chronous I/O but not in asynchronous I/O the control stack.
(B) In both synchronous and asynchronous I/O, an (T) The processor loads the new PC value based on
ISR (Interrupt Service Routine) is invoked after the interrupt.
completion of the I/O Which one of the following is the correct order in
(C) A process making a synchronous I/O call waits which the events above occur? [2018]
until I/O is complete, but a process making an (A) QPTRS (B) PTRSQ
asynchronous I/O call does not wait for comple- (C) TRPQS (D) QTPRS
tion of the I/O 13. A 32-bit wide main memory unit with a capacity of
(D) In the case of synchronous I/O, the process wait- 1 GB is built using 256 M × 4-bit DRAM chips. The
ing for the completion of I/O is woken up by the number of rows of memory cells in the DRAM chip
ISR that is invoked after the completion of I/O is 214. The time taken to perform one refresh operation
is 50 nanoseconds. The refresh period is 2 millisec-
9. A main memory unit with a capacity of 4 megabytes
onds. The percentage (rounded to the closest integer)
is built using 1M × 1-bit DRAM chips. Each DRAM
of the time available for performing the memory read
chip has 1K rows of cells with 1K cells in each row.
write operations in the main memory unit is ______.
The time taken for a single refresh operation is 100
[2018]
2.46 | Unit 2 • Computer O
rganization and Architecture
Answer Keys
Exercises
Practice Problems 1
1. A 2. C 3. D 4. B 5. B 6. C 7. B 8. C 9. C 10. A
11. C 12. D 13. A 14. D 15. B 16. D 17. D 18. B 19. B 20. D
Practice Problems 2
1. B 2. B 3. A 4. C 5. A 6. C 7. B 8. D 9. C 10. C
11. A 12. D 13. A 14. B 15. B 16. B 17. A 18. D 19. B 20. B
21. D