DMA Controller
DMA Controller
What is DMAC ?
DMA or Direct Memory Access Controller is an external device that controls the transfer of data
between I/O device and memory without the involvement of the processor.
It holds the ability to directly access the main memory for read or write operation.
Using a DMA controller, the device requests the CPU to hold its data, address and control bus,
so, the device is free to transfer data directly to/from the memory.
The DMA data transfer is initiated only after receiving HLDA signal from the CPU.
DMA controller was designed by Intel, to have the fastest data transfer rate with less processor
utilization.
Why DMAC ?
Generally, to perform an operation, the microprocessor
first fetches the instruction -- then decodes it -- then further execute it.
But individually if the processor is performing all the task inside the system,
Basically, it is nothing but hardware-controlled data transfer, where the address and control
This method of data transfer is known as direct memory access and the external device
And at the time of data transfer operation, the processor cannot execute any other
operation.
Hence, if the system has a DMA controller, then it frees the CPU from data transfer
operation and at that particular time, the CPU can execute/ perform other
operations.
Features of 8257
It has four channels which can be used over four I/O devices.
Each channel can perform read transfer, write transfer and verify transfer operations.
It generates MARK signal to the peripheral device that 128 bytes have been transferred.
It requires a single phase clock [all clock signals are effectively transmitted on 1 wire]
The mark will be activated after each 128 cycles or integral multiples of it from the beginning. It indicates
the current DMA cycle is the 128th cycle since the previous MARK output to the selected peripheral
device.
Vcc
It is the power signal which is required for the operation of the circuit.
Operation of DMA Controller
Basically, whenever an I/O device needs to transfer the data to the memory, then it initially sends a
On receiving data transfer request, the DMA controller sends Hold request (HRQ) to the CPU and
waits for the CPU to assert the HLDA - hold acknowledge by the CPU.
So, on getting HRQ request by the controller, the CPU leaves the control over all the buses (i.e., tri-
state’s the data, control and address bus) and acknowledges the HRQ request by sending HLDA to
the controller.
Now the CPU is in HOLD state and the DMAC has to manage the operations over buses.
The processor is free from any data transfer operation until an interrupt is generated by the DMAC
DMAC inside the system can be either in an idle and active state.
In the idle cycle, initially when the system gets on, the processor has control over the system buses and the
In this position, the buses form the connection between main memory and peripherals through the processor. So,
But once, need arises to read/write the data from /to the disk.
Then the microprocessor sends an instruction to the disk controller about the read/write operation of the data.
On fetching the required data, the disk controller (peripheral device) sends DMA request, i.e., DRQ signal to the
DMAC.
This DRQ signal indicates that the device directly wants to transfer data to the memory without disturbing the
processor.
So, on receiving the DRQ signal, HRQ signal is sent by the DMA controller (HOLD request ) to the
microprocessor.
The HRQ signal shows the interest of the DMAC to have access to system buses.
So, on receiving HRQ, the CPU tri-states its buses to grant the control to the DMAC.
Once the processor frees the buses, then it sends the HLDA signal to the DMA controller.
And on receiving HLDA signal, the control over the buses is given to the DMA controller and the switch
So, gaining control over the buses, the active cycle of the DMA gets enabled.
Thus, it sends the acknowledge signal DACK to the disk controller that shows that it is now ready for the
transfer of data.
After acknowledging the disk controller, the DMAC loads the control signal over the bus according to the
When IOR signal is received by the disk controller then it loads the required data into the data bus.
Also, MEMW’ signal shows the presence of address on the address bus where the data is to be
transferred.
Thus, the disk controller can directly transfer the data to the desired memory location without the CPU.
Once the data transfer is accomplished then the DMA controller generates an interrupt by varying switch
This indicates the microprocessor about the completion of the data transfer operation.
So, by this, the control of the buses is again transferred to the processor, and it starts executing the
further operation.
Modes of DMA Transfer:
During the DMA Transfer CPU can perform only those operation in which it doesn’t require the access of System Bus which
means mostly CPU will be in blocked (idle) state.
•For how much time CPU remains in the blocked state or we can say for how much time CPU will give the control of DMAC
of system buses will actually depend upon the following modes of DMA Transfer and after that CPU will take back control
of system buses from DMAC.
•DMA controller has four modes for data transfer:
Advantages:
Improved performance: DMA improves system performance by
freeing up the CPU to perform other tasks while data is being
transferred between memory and I/O devices. This allows for faster
Disadvantages: and more efficient data transfer.
Complexity: DMA requires specialized hardware and software to
function, which can add to the complexity of a system. This can Reduced CPU overhead: With DMA, the CPU is not required to be
make it difficult to implement and troubleshoot. involved in data transfer, which reduces the CPU overhead and
Security risks: DMA can be a security risk if not properly allows it to focus on other tasks. This is particularly useful in real-
configured or secured. Hackers can exploit vulnerabilities in DMA time systems where low latency and fast response times are
to gain unauthorized access to a computer system or steal data. important.
Limited control: Since the CPU is not involved in data transfer
with DMA, it has limited control over the transfer process. This Support for high-bandwidth devices: DMA can support high-
can lead to data corruption or errors if the transfer process is not bandwidth devices such as graphics cards and network interfaces
properly managed. that require fast data transfer rates.
Resource conflicts: DMA can lead to resource conflicts if multiple
devices attempt to access memory simultaneously. This can Efficient use of system resources: DMA allows multiple devices to
cause system instability and performance issues if not properly access memory simultaneously, which makes more efficient use of
Operating Modes of 8257:
TC STOP Mode :
If the TC stop bit is set, a channel is disabled (i.e. its enable bit is reset) after the terminal count (TC) output goes high, thus
automatically preventing further DMA operation on that channel.
To enable DMA operation on the channel it is necessary to set enable bit of the corresponding channel in the mode set register.
If the TC STOP bit is not set, the occurrence of the TC output has no effect on the channel enable bits.
Auto Load Mode :
Auto load Mode when enabled, permits block chaining operations, without immediate software intervention between blocks.
In this mode, channel 2 parameters (DMA starting address, terminal count and DMA transfer mode) are initialized as usual for the first
data block.
These parameters are automatically duplicated in the channel 3 registers when channel 2 is initialized.
After the first block of DMA cycles is executed by channel 2 (i.e., after the TC output goes high), the parameters stored in the channel 3
registers are transferred to channel 2 during an ‘update’ cycle and next block of DMA cycle is executed.
This repeat block operations can be used in applications such as CRT refreshing. During the update cycle, it is necessary to prevent the
CPU from inadvertently skipping a data block by overwriting a starting address or terminal count in the channel 3 registers before those
DMA Cycles:
DMA READ : In this cycle, data is transferred from memory to I/O device.
DMA Write : In this cycle, data is transferred from I/O device to memory.
DMA Verify : In this cycle, data is not transferred between memory and I/O.
It is used by the, peripheral device to verify the data that has been recently transferred.
Status Register: It is an 8-bit register that indicates which channel is currently under DMA services or
which channels has reached its terminal count.
It basically gives the status of the channels.
The terminal counts(TC) bits indicates if the channel has reached its terminal count.
If terminal count is reached, the transfers are terminated.
Mode Register: It is an 8 bit register that determines the operating mode, i.e., the transfer mode and other
transfer parameters, for a channel. Each channel has its own mode register which is selected by bit
positions 0 and 1.