DMA :
Reading Data from Memory:
- When the CPU initiates a read operation, it sends a request to the DMA controller indicating the memory address from which it wants to read data.
- The DMA controller responds by activating the appropriate control lines to enable the read operation.
- It places the memory address on the address bus and initiates the read operation. This allows the CPU to fetch the requested data from memory via the data bus.
- Writing Data to Memory:
- When the CPU wants to write data to memory, it communicates with the DMA controller, providing the memory address where the data should be written.
- The DMA controller then activates the necessary control lines to enable the write operation.
- It places the memory address on the address bus and waits for the CPU to send the data to be written via the data bus.
- Once the CPU sends the data, the DMA controller facilitates the writing process to the specified memory address.
Block diagram for DMA:
Working of DMA controller :
- Initiation of DMA Request:
- When a peripheral device, such as a disk drive or network adapter, requires data transfer to or from memory, it sends a DMA request to the DMA controller.
- CPU Handoff:
- Upon receiving the DMA request, the DMA controller signals the CPU by activating the BUSREQ (Bus Request) line.
- The CPU responds by relinquishing control of the system buses, including the address and data buses, by asserting the BG (Bus Grant) signal.
- DMA Configuration:
- Once the CPU relinquishes control, the DMA controller configures itself for the data transfer operation.
- It determines the memory addresses involved in the transfer, the direction of data flow (read from memory or write to memory), and other relevant parameters.
- Addressing:
- The DMA controller places the memory address of the data to be transferred onto the address bus.
- For a read operation, it initiates the appropriate control signals (e.g., RD for read).
- For a write operation, it initiates the appropriate control signals (e.g., WR for write).
- Data Transfer:
- If the operation involves reading data from memory, the DMA controller reads the data from memory and transfers it to the peripheral device.
- If the operation involves writing data to memory, the DMA controller receives data from the peripheral device and writes it to the specified memory location.
- Completion and Handback:
- Once the data transfer is complete, the DMA controller signals the peripheral device with a DMA acknowledgement (DMAACK).
- If additional data transfers are required, the DMA controller may initiate subsequent transfers without involving the CPU.
- Once all data transfers are completed, the DMA controller releases control of the system buses by deactivating the BUSREQ signal.
- CPU Reacquisition:
- Upon completion of the DMA operation, the CPU regains control of the system buses by asserting the BUSACK (Bus Acknowledge) signal.
- The CPU resumes its normal operations, potentially processing the transferred data or handling other tasks.
Bidirectional Control Lines:
- The read and write control lines in the DMA controller serve dual purposes: they enable both reading from and writing to memory.
- These control lines are bidirectional to accommodate the two-way communication between the CPU and the DMA controller.
- Depending on the operation initiated by the CPU (read or write), the DMA controller appropriately activates either the read or write control line.
- This bidirectional nature allows the DMA controller to seamlessly facilitate data transfer between memory and other devices, optimizing efficiency by offloading data transfer tasks from the CPU.