DMA Controller

There is a DMA (Direct Memory Access) Controller which can perform block transfers between the SRAM, SDRAM, Audio FIFOs, and VGA Adapter. It can only transfer blocks less than 65536 bytes.

DeviceDMA Controller
ConfigurationMaximum 65536 byte blocks, connects SRAM, SDRAM, Audio FIFOs, and VGA Adapter
Input/Outputboth
Address Base0xff1180
Address Map
AddressR/WDescription
baseR/WStatus Register contains status bits see Note 1
base+4R/WReadAddress Register stores memory location to read from
base+8R/WWriteAddress Register stores memory location to write to
base+12R/WLength Register stores number of bytes to transfer
base+16R/WNot used
base+20R/WNot used
base+24R/WControl Register - See Note 2
InitializationNone
Interrupts
TriggeredWhen DONE bit is high (ie. A DMA transaction has completed)
IRQ Line13
EnableSet I_EN bit in Control register high
AcknowledgeWrite zero to Status register
Hardware SetupNone
Reference Altera DMA Controller Datasheet

Notes

  1. The Status Register uses only the least significant 5 bits, the pinout is as follows:
    BitNameDescription
    0DONEIndicates the transaction finished, write zero here to clear it
    1BUSYA transaction is in progress
    2REOPRead side end-of-packet (unused)
    3WEOPWrite side end-of-packet (unused)
    4LENLength register was decremented to 0

  2. The Control Register uses only the least significant 7 bits, the pinout is as follows:
    BitNameDescription
    0BYTESpecifies byte at-a-time transfer
    1HWORDSpecifies half-word (16-bit) at-a-time transfer
    2WORDSpecifies word (32-bit) at-a-time transfer
    3GOEnables DMA transactions
    4I_ENEnable interrupts - occur when DONE is high
    5REENEnd on read-side end-of-packet (unused)
    6WEENEnd on write-side end-of-packet (unused)
    7LEENEnd transaction after Length register reaches zero
    8RCONReads from a constant address when RCON=1
    9WCONWrites to a constant address when WCON=1
    10DWORDSpecifies double-word at-a-time transfer
    11QWORDSpecifies quad-word at-a-time transfer

Assembly Example: Copy a string on the SDRAM to the SRAM

.equ ADDR_SRAM, 0x800000
.equ ADDR_SDRAM, 0x1000000
.equ ADDR_DMA, 0xff1180

  movia r2,ADDR_DMA

  movia r3,STRING
  stwio r3,4(r2)      /* Set DMA Read Address */

  movia r3,ADDR_SRAM
  stwio r3,8(r2)      /* Set DMA Write Address */

  movia r3,STRINGLENGTH
  stwio r3,12(r2)     /* Set DMA length */

  movi  r3,0b10001001 /* Set control bits:  bit0 - byte at a time */
                                      /*    bit3 - GO */
                                      /*    bit7 - Till length goes to 0 */
  stwio r3,24(r2)     /* Set DMA control */

WAIT:
  ldwio r3,0(r2)
  andi  r3,r3,1
  beq   r3,r0,WAIT    /* Spin until DONE bit goes high */

  stwio r0,(r2)       /* Clear status register - zero DONE flag */
  stwio r0,24(r2)     /* Clear control register - zeros GO bit */

STOP: br STOP

.equ STRINGLENGTH, 80
STRING:
.asciz "Hello World! I should be transferred from SDRAM to SRAM using the DMA controller"