DMA stands for Direct Memory Access. It is designed by
Intel to transfer data at the fastest rate. It allows the device to transfer
the data directly to/from memory without any interference of the CPU.
What is a DMA Controller?
The term DMA stands for direct memory access.
The hardware device used for direct memory access is called the DMA controller.
DMA controller
is a control unit, part of I/O device’s interface
circuit,
which can transfer blocks of data between I/O devices and main memory with
minimal intervention from the processor.
DMA
Controller Diagram in Computer Architecture
DMA controller
provides an interface between the bus and the input-output devices. Although it
transfers data without intervention of processor, it is controlled by the
processor. The processor initiates the DMA controller by sending the starting
address, Number of words in the data block and direction of transfer of data
.i.e. from I/O devices to the memory or from main memory to I/O devices. More
than one external device can be connected to the DMA controller.
DMA controller contains an address unit, for generating
addresses and selecting I/O device for transfer. It also contains the control
unit and data count for keeping counts of the number of blocks transferred and
indicating the direction of transfer of data. When the transfer is completed,
DMA informs the processor by raising an interrupt. The typical block diagram of
the DMA controller is shown in the figure below.
Working of DMA Controller
DMA controller has to share the bus with the processor to make the data
transfer. The device that holds the bus at a given time is called bus master.
When a transfer from I/O device to the memory or vice versa has to be made, the
processor stops the execution of the current program, increments the program counter, moves
data over stack then sends a DMA select signal to DMA controller over the
address bus.
If the DMA controller
is free, it requests the control of bus from the processor by raising the bus
request signal. Processor grants the bus to the controller by raising the bus
grant signal, now DMA controller is the bus master. The processor initiates the
DMA controller by sending the memory addresses, number of blocks of data to be
transferred and direction of data transfer. After assigning the data transfer
task to the DMA controller, instead of waiting ideally till completion of data
transfer, the processor resumes the execution of the program after retrieving
instructions from the stack.
DMA controller now
has the full control of buses and can interact directly with memory and I/O
devices independent of CPU. It makes the data transfer according to the control
instructions received by the processor. After completion of data transfer, it disables
the bus request signal and CPU disables the bus grant signal thereby moving
control of buses to the CPU.
When an I/O device
wants to initiate the transfer then it sends a DMA request signal to the DMA
controller, for which the controller acknowledges if it is free. Then the
controller requests the processor for the bus, raising the bus request signal.
After receiving the bus grant signal it transfers the data from the device. For
n channel DMA controller n number of external devices can be connected.
How DMA Operations are Performed?
Following is the sequence of operations performed by a DMA −
·
Initially, when any device has to send data between the
device and the memory, the device has to send DMA request (DRQ) to DMA
controller.
·
The DMA controller sends Hold request (HRQ) to the CPU
and waits for the CPU to assert the HLDA.
· Then the microprocessor tri-states all the data bus, address bus, and control bus. The CPU leaves the control over bus and acknowledges the HOLD request through HLDA signal.
·
Now the CPU is in HOLD state and the DMA controller has
to manage the operations over buses between the CPU, memory, and I/O devices.
i. DREQ (DMA Request):
Peripheral sends a request to the DMA controller for data transfer.
ii. HOLD (Hold Signal):
DMA controller requests control of the system bus from the CPU.
iii. HLDA (Hold Acknowledge):
CPU acknowledges the HOLD signal, releasing control of the system bus.
iv. DACK (DMA Acknowledge):
DMA controller signals the peripheral that it is ready for data transfer.
v. DATA Transfer/Final Execution: DMA controller transfers data directly between memory and the peripheral.
The DMA transfers the
data in three modes which include the following.
a) Burst Mode: In this mode DMA
handover the buses to CPU only after completion of whole data transfer.
Meanwhile, if the CPU requires the bus it has to stay ideal and wait for data
transfer.
b) Cycle Stealing Mode: In this
mode, DMA gives control of buses to CPU after transfer of every byte. It
continuously issues a request for bus control, makes the transfer of one byte
and returns the bus. By this CPU doesn’t have to wait for a long time if it
needs a bus for higher priority task.
c) Transparent Mode: Here,
DMA transfers data only when CPU is executing the instruction which does not
require the use of buses.
Advantages and Disadvantages of DMA Controller
The advantages and
disadvantages of DMA controller include the following.
Advantages
·
DMA speedups the memory operations by
bypassing the involvement of the CPU.
·
The work overload on the CPU decreases.
·
For each transfer, only a few numbers of
clock cycles are required
Disadvantages
·
Cache coherence problem can be seen when DMA
is used for data transfer.
·
Increases the price of the system.
Direct
Memory Access (DMA) is a technique that allows peripherals or devices to
transfer data directly to or from a CPU's memory without involving the CPU in
every data transfer, freeing it for other tasks.
Here’s a
concise overview of DMA applications in CPUs:
1.
High-Speed Data
Transfer: DMA enables fast data movement between
memory and peripherals (e.g., storage devices, network cards, or GPUs),
reducing CPU overhead for tasks like copying large files or streaming data.
2.
I/O Operations: DMA is used in input/output operations, such as reading
from or writing to hard drives, SSDs, or network interfaces, allowing the CPU
to focus on processing while data is transferred in the background.
3.
Multimedia Processing: In audio/video applications, DMA handles continuous
data streams (e.g., for sound cards or video capture devices), ensuring smooth
playback or recording without CPU intervention.
4.
Network Communication: DMA accelerates packet processing in network interface
cards (NICs), enabling efficient data transfer for high-bandwidth tasks like
streaming or server communications.
5.
Graphics Processing: In systems with GPUs, DMA facilitates rapid data
exchange between system memory and GPU memory, critical for rendering graphics
or running compute-intensive tasks like AI model training.
6.
Embedded Systems: In microcontrollers or IoT devices, DMA offloads
repetitive data tasks (e.g., sensor data collection), allowing the CPU to
handle control logic or enter low-power modes.
Benefits:
- Reduces CPU
workload, improving system efficiency.
- Speeds up
data transfers for large or continuous datasets.
- Enhances
multitasking in real-time systems.
Example: In a computer, when transferring a large file from an
SSD to RAM, the DMA controller handles the transfer, allowing the CPU to
execute other processes like running applications or handling user inputs.
0 Comments