DIRECT MEMORY ACCESS (DMA)
DMA refers to the transfer of data without involving the µP. The following
DMA transfer combinations are possible:
-
Memory to memory
-
Memory to peripheral
-
Peripheral to memory
-
Peripheral to peripheral
The DMA approach is to "turn off" (i.e. tri-state and electrically disconnect
from the system busses) the µP and let a peripheral device (or memory
- another module or another block of the same module) communicate directly
with the memory (or another peripheral).
ADVANTAGE: Transfer rates approaching that of the memory can be achieved.
DMA latency is <= 6µsec.
DISADVANTAGE: A DMAC is needed, making the system complex and expensive.
DMA requests have priority over all other bus activities, including interrupts.
No interrupts will be recognized during a DMA cycle.
WHY DMA ?
The instruction mov [2],[9]
is illegal.
should be done in two steps:
Thus it is not possible to transfer from one memory location to another without
involving the µP. The same applies to transfer between memory and
peripherals connected to I/O ports. e.g. cannot have out
dport,[6]
.
should be done in two steps:
Similar comments apply to the in
instruction.
Thus the real cause of limited transfer rate is the µP itself.
It acts as an unnecessary "middleman".
Some
Definitions
THE DMA PROTOCOL UNDER MAXIMUM MODE
-
Under the maximum mode, the HOLD and HLDA lines become two bidirectional
request-grant-release lines labelled -RQ0/-GT0 and -RQ1/-GT1.
-
This protocol was designed to transfer control of the CPU local bus between
the CPU and (upto) two alternate bus masters which reside totally on the
local bus and share the complete CPU bus interface including the address
latches, data transceivers, 8288 bus controller and 8289 multi-master bus
arbiter.
-
If the alternate bus masters in the system do not reside directly on the
8086 local bus, system bus arbitration is required rather than local bus
arbitration. To satisfy the need for multi-master system bus arbitration
at each CPU's system interface, the 8289 bus arbiter should be used instead
of the -RQ/-GT protocol.
-RQ/-GT PRIORITY
-
Each -RG/-GT pin of the 8086 supports the full protocol for exchange of bus
control. Thus each can be used independently.
-
-RQ/-GT0 has priority over -RQ/-GT1 for impending requests that have not
yet been granted. e.g., if a request is received on -RQ/-GT1 followed by
a request on -RQ/-GT0 prior to a grant on -RQ/-GT1, -RQ/-GT0 will gain priority
over -RQ/-GT1. However, if -RQ/-GT1 has already received a grant, a request
on -RQ/-GT0 must wait until a release pulse is received on -RQ/-GT1.
-RQ/-GT USAGE
-
The cycle begins with the alternate bus master (coprocessor) requesting the
system bus by pulling the associated -RQ/-GT line low (for TCLCL nanosecs
maximum); and, of course, satisfying the setup and hold times.
-
The 8086 completes the current bus cycle, in the same way as it does in the
minimum mode, and responds by floating the address/data lines, the status
lines (-S0, -S1, -S2), the -RD and -LOCK control lines.
-
This action does not disable the 8288 command outputs from driving the command
bus and does not disable the address latches from driving the address bus
because the 8288 contains internal pull-up resistors on the status lines
(-S0, -S1, -S2) to maintain the passive state (performing idle bus cycles)
while the 8086 outputs are tri-stated. Thus the 8288 is unable to initiate
any commands or activate the DEN signal. If the device issuing the request
does not use the 8288, it must disable the 8288 command outputs by disabling
the 8288 -AEN input. Also, the address latches not used by the requesting
device must be disabled.
-
A low -GT pulse is then output by the 8086 on the same pin where the request
occured.
-
After receiving the grant pulse, and waiting for the "float delay" of the
8086 (TCLAZ), the requesting device may drive the local bus. This precaution
prevents bus contention.
-
To return control of the bus to the 8086, the alternate bus master relinquishes
bus control and issues a release pulse on the same -RQ/-GT line. The 8086
may drive the three status lines, -RD and -LOCK control lines three clock
cycles after detecting the release pulse and the AD bus TCHCLmin after the
status lines. The alternate bus master should be tri-stated off the local
bus and have other 8086 interface circuits (including the 8288 and address
latches) re-enabled within this time.
TYPES OF DMA
DMA cycles are of two types:
-
sequential: the DMAC fetches a byte (a read operation) and then
outputs it (a write operation); in the same way as the µP does. So the
only advantage in this case is that the µP is not involved.
-
simultaneous: the read and write operations are performed at the
same time. Both control signals are active simultaneously and data does not
flow through the DMAC at all. Thus this is the fastest way to accomplish
a transfer.
In both cases the data transfer is done completely in hardware without involving
the CPU and thus there is no associated software overhead.
OPTIONS FOR THE DMAC
-
BYTE or SINGLE MODE: release the bus after transferring a byte of
data and request control again when needed. This lets the CPU perform other
jobs also.
-
BURST or DEMAND MODE: release the bus when the peripheral's buffer
is full. request control again when buffer becomes available. This mode is
intended for peripherals that have high-speed data buffers (i.e. internal
memory) or for memory to memory transfers.
-
CONTINUOUS or BLOCK MODE: retain control of the bus until the entire
block of data has been transferred.
Some Notes
(N1, N2, N3, N6b, N6c, N6d, N6e, N8, N9)