2080 3

CSC213 ยท 2080 ยท 10 marks

What is DMA? Explain the DMA controller with block diagram. How the DMA interact with I/O device.

What is DMA? Explain the DMA controller with block diagram. How the DMA interact with I/O device.[10]

Computer ArchitectureChapter 8: Input Output OrganizationDirect Memory Access, Input-Output Processor, DMA vs. IOP

Quick answer

Direct Memory Access (DMA) is a process for data transfer between memory and I/O devices, controlled by an external circuit called the DMA controller, without the involvement of the CPU. Most data that is input or output from a computer is processed by the CPU, but some data does not require CPU processing or can be processed by another device. In these situations, DMA saves processing time and is a more efficient way to move data from the computer's memory to other devices.

Direct Memory Access (DMA)

Definition

Example: A PCI controller and a hard drive controller each have their own set of DMA channels.


Block Diagram of DMA Controller

         +------------------+
         |       CPU        |
         |  (HOLD)  (HLDA)  |
         +--------+---------+
                  |
         +--------+---------+
         |   System Buses   |
         | (Address / Data) |
         +--+----------+----+
            |          |
   +--------+--+    +--+--------+
   |   Memory  |    |    DMA    |
   |   (RAM)   |    | Controller|
   +--------+--+    +--+---+----+
                       |   |
                    BR/BG  RS/DS
                       |   |
                  +----+---+----+
                  |  I/O Device |
                  | (Peripheral)|
                  +-------------+

Internal Structure of DMA Controller

+-----------------------------------------------+
|              DMA Controller                   |
|                                               |
|  +------------------+  +------------------+  |
|  | Address Register |  |  Word Count Reg  |  |
|  +------------------+  +------------------+  |
|                                               |
|  +------------------+  +------------------+  |
|  |  Data Register   |  |  Control/Status  |  |
|  +------------------+  |    Register      |  |
|                         +------------------+  |
|                                               |
|   Control Lines: BR, BG, RD, WR, RS, DS      |
+-----------------------------------------------+

Key Registers in DMA Controller

RegisterPurpose
Address RegisterHolds the memory address for data transfer
Word Count RegisterHolds the number of words to be transferred
Data RegisterTemporarily holds data during transfer
Control/Status RegisterStores control bits and status of transfer

Control Signals Used in DMA Operation

The CPU has two special pins used for DMA operation:

1. Bus Request (BR)

  • Used by the DMA controller to request the CPU to release the buses.
  • When BR is active, the CPU:
    • Terminates execution of the current instruction
    • Places the address bus, data bus, and read/write lines into high impedance state

2. Bus Grant (BG)

  • CPU activates the BG output to inform the DMA that buses are now available.
  • DMA takes control and conducts memory transfers without CPU involvement.
  • When DMA finishes the transfer:
    • It disables the BR line
    • CPU disables BG and returns to normal operation

Sequence of Events During DMA Operation

Step 1: I/O device sends DMA Request to DMA Controller
         |
Step 2: DMA Controller activates BR line --> CPU
         |
Step 3: CPU completes current instruction, releases buses
         CPU activates BG line --> DMA
         |
Step 4: DMA puts address register value onto Address Bus
        DMA initiates RD and WR signals
        DMA sends DMA Acknowledge to I/O device
         |
Step 5: Data transfer takes place between Memory and I/O
        (without CPU involvement)
         |
Step 6: DMA disables BR line after transfer completes
        CPU disables BG and resumes normal operation

How DMA Interacts with I/O Devices

The interaction between DMA and I/O devices follows the steps below (based on the DMA transfer mechanism):

Step-by-Step Interaction

  1. CPU Initiates the Setup:

    • The CPU communicates with the DMA controller through the address and data buses.
    • The DMA has its own address, which activates the RS (Register Select) and DS (DMA Select) lines.
    • CPU loads the DMA controller with:
      • Starting memory address
      • Word count (number of words to transfer)
      • Direction of transfer (read/write)
  2. I/O Device Sends DMA Request:

    • When a peripheral device is ready for data transfer, it sends a DMA Request signal to the DMA controller.
  3. DMA Requests the Bus:

    • The DMA controller activates the BR (Bus Request) line, informing the CPU to release the buses.
  4. CPU Grants the Bus:

    • The CPU responds by activating BG1 (Bus Grant) line.
    • When BG1 = 0: RD and WR signals allow the CPU to communicate with internal DMA registers.
    • When BG1 = 1: DMA communicates with RAM through RD and WR lines directly.
  5. DMA Performs the Transfer:

    • DMA puts the current value of its address register onto the address bus.
    • Initiates RD and WR signals as required.
    • Sends a DMA Acknowledge to the peripheral device.
    • Data is transferred directly between I/O device and Memory.
  6. Transfer Completion:

    • After all words are transferred (word count reaches zero), DMA disables the BR line.
    • CPU regains control of the buses and resumes normal operation.

Types of DMA Transfer

TypeDescription
Burst TransferDMA takes control of the bus and transfers a block of data at once before returning control to CPU
Cycle StealingDMA transfers one word at a time, stealing one bus cycle from the CPU, then returns control

Summary

DMA is an efficient I/O technique that lets a peripheral device transfer data directly to and from memory without CPU intervention on every word, using the DMA controller as a temporary bus master to drive the address and control lines. This significantly speeds up bulk data transfers compared to programmed I/O, since the CPU is freed to execute other instructions while the transfer proceeds in the background and is only notified (typically by an interrupt) once the transfer is complete.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.