With a neat schematic diagram, explain about DMA controller and its mode of data transfer.
With a neat schematic diagram, explain about DMA controller and its mode of data transfer.
Quick answer
A DMA controller is a hardware unit that lets I/O devices transfer data to or from memory directly, without the CPU moving each word. It takes control of the system buses from the CPU for the time of the transfer.
Schematic of the DMA controller
The controller has an address register for the memory address, a word count register for the number of words, and a control register for the direction and mode. It has a data buffer to connect to the data bus. It also has the lines DMA request and DMA acknowledge to the device, and bus request and bus grant to the CPU. A register select input lets the CPU read and write its registers.
Working of the transfer
The CPU first programs the controller with the starting address, the word count and the direction. The device then raises a DMA request. The controller asks the CPU for the bus. The CPU finishes the present bus cycle and grants the bus. The controller puts the address on the address bus, sends the read or write signals, and the word moves between the device and memory. The address is incremented and the count is decremented. When the count is zero, the controller releases the bus and interrupts the CPU.
Modes of data transfer in DMA
Burst mode (block mode). The controller keeps the bus until the whole block is transferred. The transfer is very fast. But the CPU cannot use the bus for the whole time and may be idle for long. This suits high speed devices such as disks.
Cycle stealing mode. The controller takes the bus for one word, then releases it. The CPU gets the bus in between. The transfer is slower, but the CPU is delayed only by one cycle for each word. This suits slow or medium speed devices.
Transparent mode (hidden mode). The controller uses the bus only in those cycles when the CPU is not using it, for example while the CPU is decoding an instruction. The CPU is never slowed. But the transfer can be delayed, and the circuit is more complex.
Direction of transfer
In a DMA read, data goes from memory to the device. In a DMA write, data goes from the device to memory. A third form, memory to memory transfer, is possible in some controllers.
Comparison of the modes
| Mode | Bus use by DMA | Effect on CPU | Speed |
|---|---|---|---|
| Burst | Whole block together | CPU waits for long | Highest |
| Cycle stealing | One word at a time | Slight delay | Medium |
| Transparent | Only in free cycles | No delay | Lowest |
Advantages
The main gains of DMA are higher speed and a free CPU. The cost is the extra hardware and the need to share the bus.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.
Up nextDiscuss the design of a typical input or output interface.