8257 DMA Controller: Architecture & Bus Mastership
4 independent DMA channels, cycle stealing vs burst mode, HOLD/HLDA handshaking, address/count registers, and high-speed I/O.
Knova editors11 min readQuick checkSources
The 8257 Direct Memory Access (DMA) Controller
In standard programmed I/O and interrupt-driven transfers, every data byte moving between a high-speed peripheral (such as a hard disk drive, network interface, or optical drive) and memory must pass through the CPU registers (such as Accumulator or ).
This software-driven path incurs severe overhead: the CPU must fetch the instruction, decode the opcode, read from the I/O port, compute the memory address, and write the byte to RAM. For mass storage devices transferring millions of bytes per second, this bottleneck limits system bandwidth.
Architecture and Channel Structure of the 8257
The Intel 8257 is a 4-channel programmable DMA controller housed in a 28-pin DIP package. It can manage four independent peripheral devices concurrently through Channels 0, 1, 2, and 3.
Each channel features two 16-bit internal registers:
- DMA Address Register (16-bit): Holds the starting memory address for the DMA transfer. It automatically increments after each byte is successfully transferred.
- Terminal Count Register (14-bit Count + 2-bit Type): The lower 14 bits () store the programmed number of byte transfers minus one (), allowing transfers of up to per sequence. The counter decrements after each byte transferred.
- The upper two bits () encode the DMA cycle type:
DMA Transfer Cycle Type 0 0 DMA Verify Cycle (Generates addresses without asserting strobes) 0 1 DMA Write Cycle (Transfers data from Peripheral to Memory) 1 0 DMA Read Cycle (Transfers data from Memory to Peripheral) 1 1 Illegal / Reserved
- The upper two bits () encode the DMA cycle type:
8257 Signal Descriptions and Bus Arbitration
The 8257 operates in two alternating operational states: Slave Mode (when programmed by the CPU) and Master Mode (when controlling the buses during DMA transfers).
- (DMA Request Inputs): Asynchronous request lines asserted by peripherals requesting DMA service.
- (DMA Acknowledge Outputs): Active-low lines from the 8257 notifying the peripheral that its request is being serviced.
- HRQ (Hold Request Output): Connected to the CPU's
HOLDpin. The 8257 pulls HRQ high to request the CPU to float its buses. - HLDA (Hold Acknowledge Input): Connected to the CPU's
HLDApin. When high, the CPU has tri-stated its buses, giving the 8257 full bus mastership. - AEN (Address Enable Output): Disables the CPU's bus buffers and peripheral decoders, preventing bus contention during DMA cycles.
- ADSTB (Address Strobe Output): Pulses high to latch the higher-order memory address byte () from data pins into an external 74LS373 latch.
- TC (Terminal Count Output): Asserts high when the terminal count register reaches , signaling the peripheral that the programmed block transfer is complete.
- MARK (Output): Generates a pulse every 128 bytes of transfer to assist peripheral sector and block framing.
Data Transfer Modes: Cycle Stealing vs. Burst Mode
- Cycle Stealing Mode (Single Byte Transfer): The peripheral requests DMA for a single byte. The 8257 requests the bus, transfers one byte, and immediately releases the bus back to the CPU. This mode allows the CPU to continue processing code concurrently with slow I/O devices.
- Burst Transfer Mode (Block Transfer): The 8257 retains control of the buses continuously until the entire block of data is transferred (until the Terminal Count reaches zero). This provides maximum possible data throughput for ultra-high-speed devices.
Step-by-Step DMA Transfer Sequence
- The peripheral asserts its DMA Request line ().
- The 8257 evaluates channel priority and asserts its Hold Request () pin high to the CPU.
- The CPU finishes its current machine cycle, floats its address, data, and control lines into high impedance, and returns Hold Acknowledge () high.
- The 8257 asserts Address Enable () high and activates DMA Acknowledge () to the peripheral.
- The 8257 outputs the memory address: lower byte directly on , and upper byte on with an pulse into an external latch.
- For a DMA Write (Peripheral to Memory), the 8257 asserts both and simultaneously. Data flows directly from the peripheral into memory across the system data bus in a single clock cycle!
- The DMA address register increments, and the terminal count decrements.
- When the count reaches zero, the 8257 asserts high, drops low, and relinquishes the bus back to the CPU.
Intel 8257 DMA Transfer & Bus Arbitration Engine
Stage 1: Peripheral Asserts DMA Request (DRQ)
The I/O peripheral (e.g. disk controller or high-speed ADC) is ready to transfer data. It asserts DRQ (DMA Request) on Channel 2 of the 8257. The 8085 CPU continues executing normal program instructions on the system bus.
Internal Control and Status Registers
The 8257 contains two dedicated internal control and status registers accessed when :
1. Mode Set Register (Write-Only, Port Address )
| AL | TCS | EW | RP | EN3 | EN2 | EN1 | EN0 |
- AL (Auto Load, Bit 7): . When Channel 2 reaches Terminal Count, it automatically reloads its initial address and count from Channel 3 registers (ideal for continuous CRT refresh).
- TCS (TC Stop, Bit 6): . Prevents further transfers on that channel until re-enabled by CPU.
- EW (Extended Write, Bit 5): by 1 clock state to accommodate slower memory chips.
- RP (Rotating Priority, Bit 4):
- .
- The channel that was just serviced rotates to the lowest priority rank, preventing high-bandwidth devices on Channel 0 from starving other channels.
- EN3-EN0 (Channel Enables, Bits 3-0): Individual channel enables (, ).
2. Status Register (Read-Only, Port Address )
| 0 | 0 | 0 | UP | TC3 | TC2 | TC1 | TC0 |
- UP (Update Flag, Bit 4): Set to during Channel 2 Auto-Load update.
- TC3-TC0 (Terminal Count Status, Bits 3-0): Set to when the corresponding channel reaches Terminal Count. Cleared automatically upon reading the status register.
3. Architectural Comparison: Intel 8257 vs. Intel 8237
| Feature | Intel 8257 | Intel 8237 (High Performance) |
|---|---|---|
| Data Transfer Rate | ||
| Memory-to-Memory | Not supported (I/O to Mem only) | Supported using Channel 0 and 1 |
| Transfer Modes | Single byte / Burst | Single, Block, Demand, Cascade |
| Active Edge Polarity | Fixed active high DRQ | Programmable DREQ/DACK polarities |
| Auto-Initialization | Channel 2 only (via CH3) | All 4 channels supported independently |