Difference between revisions of "System DMA Block"
(→SDMA_SRC_ADDY) |
(→System DMA Registers) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 17: | Line 17: | ||
# If the source of the data is in system RAM, set SDMA_SRC_ADDY. | # If the source of the data is in system RAM, set SDMA_SRC_ADDY. | ||
# If the destination of the data is in system RAM, set SDMA_DST_ADDY. | # If the destination of the data is in system RAM, set SDMA_DST_ADDY. | ||
− | # If the transfer is a 1D operation, set the size (number of bytes) in | + | # If the transfer is a 1D operation, set the size (number of bytes) in SDMA_SIZE. If the transfer is a 2D operation, set the width in SDMA_X_SIZE, and the height in SDMA_Y_SIZE. |
# If the transfer is a 2D operation, set the source and destination stride values. | # If the transfer is a 2D operation, set the source and destination stride values. | ||
# Set the SDMA_CTRL0_Start_TRF bit of SDMA_CONTROL_REG0 to begin the actual transfer. | # Set the SDMA_CTRL0_Start_TRF bit of SDMA_CONTROL_REG0 to begin the actual transfer. | ||
Line 30: | Line 30: | ||
! Start Address | ! Start Address | ||
! Stop Address | ! Stop Address | ||
− | ! Register | + | ! Register Name |
! Additional Info | ! Additional Info | ||
|- | |- | ||
Line 57: | Line 57: | ||
| $AF:0421 || $AF:0421 || SDMA_CTRL_REG1 || Reserved for future use | | $AF:0421 || $AF:0421 || SDMA_CTRL_REG1 || Reserved for future use | ||
|- | |- | ||
− | | $AF:0422 || $AF: | + | | $AF:0422 || $AF:0424 || SDMA_SRC_ADDY || 24-bit address of the source (if system RAM is the source) |
+ | |||
|- | |- | ||
− | | $AF: | + | | $AF:0425 || $AF:0427 || SDMA_DST_ADDY || 24-bit address of the destination (if system RAM is the destination) |
+ | |||
|- | |- | ||
− | | $AF: | + | | $AF:0428 || $AF:042A || SDMA_SIZE || If 1D transfer, the size of the transfer in bytes (24-bits). |
+ | |||
|- | |- | ||
− | | $AF: | + | | $AF:0428 || $AF:0429 || SDMA_X_SIZE || If 2D transfer, the 16-bit width of the block. |
|- | |- | ||
− | | $AF: | + | | $AF:042A || $AF:042B || SDMA_Y_SIZE || If 2D transfer, the 16-bit height of the block. |
+ | |||
|- | |- | ||
− | | $AF: | + | | $AF:042C || $AF:042D || SDMA_SRC_STRIDE || If 2D transfer, the number of bytes per row in the over-all source image (16-bits). |
|- | |- | ||
− | + | | $AF:042E || $AF:042F || SDMA_DST_STRIDE || If 2D transfer, the number of bytes per row in the over-all destination image (16-bits). | |
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | | $AF:042E || $AF: | ||
− | |||
− | |||
|- | |- | ||
| $AF:0430 || $AF:0430 || SDMA_STATUS_REG / SDMA_BYTE_2_WRITE || On write, the byte to write to memory. | | $AF:0430 || $AF:0430 || SDMA_STATUS_REG / SDMA_BYTE_2_WRITE || On write, the byte to write to memory. | ||
Line 129: | Line 120: | ||
== SDMA_DST_ADDY == | == SDMA_DST_ADDY == | ||
− | This register is the 3-byte address of the destination of the data (if it is in system RAM | + | This register is the 3-byte address of the destination of the data (if it is in system RAM). |
== SDMA Size == | == SDMA Size == | ||
− | The size of the block to transfer is specified in one of two ways. For a 1-D or linear transfer (bit SDMA_CTRL_1D_2D in the control register is clear), the size is specified as a 24-bit integer using | + | The size of the block to transfer is specified in one of two ways. For a 1-D or linear transfer (bit SDMA_CTRL_1D_2D in the control register is clear), the size is specified as a 24-bit integer using SDMA_SIZE. If the transfer is a 2-D or block transfer (bit SDMA_CTRL_1D_2D in the control register is set), the size is specified as a 16-bit width stored in SDMA_X_SIZE, and a 16-bit height stored in SDMA_Y_SIZE. |
== Stride == | == Stride == | ||
For a 2-D transfer, there is the notion of a "stride," which is the total number of bytes in a row of a source or destination image. The block being transferred may be narrower than the total image. The stride along with the width of the block tells Vicky how many bytes to skip between rows. Source and destination images can have different widths and therefore different strides. The stride of the source is specified by the two-byte register SDMA_SRC_STRIDE, and the stride of the destination by SDMA_DST_STRIDE. | For a 2-D transfer, there is the notion of a "stride," which is the total number of bytes in a row of a source or destination image. The block being transferred may be narrower than the total image. The stride along with the width of the block tells Vicky how many bytes to skip between rows. Source and destination images can have different widths and therefore different strides. The stride of the source is specified by the two-byte register SDMA_SRC_STRIDE, and the stride of the destination by SDMA_DST_STRIDE. | ||
+ | |||
+ | The relationship between stride, width, and height of a block can be seen in the diagram below: | ||
+ | |||
+ | [[File:Vicky_Stride.png]] |
Latest revision as of 16:59, 18 January 2021
Contents
Overview
The System DMA block is a portion of the Vicky II chip which is responsible for high speed memory transfers to or from system memory. The block supports several types of memory operations:
- Copying a contiguous block of data from one section of memory to another (1D or linear transfers)
- Copying a rectangular subset of a larger image from one section of memory to another (2D or block transfers)
- Filling a contiguous block of addresses in video memory with a single byte (1D fill)
- Filling a rectangular subset of a larger image with a single byte (2D fill)
SDMA can copy data between different locations within system RAM, it can be used in conjunction with the Video DMA Block to transfer data between video RAM and system RAM.
IMPORTANT! SDMA halts the processor while it is in operation. The CPU will be unable to perform any tasks while an SDMA transfer is in operation. This includes handling interrupts of any sort.
Setting up a SDMA
The process of starting a SDMA is as follows:
- Set the SDMA_CONTROL_REG0 bits to enable the SDMA block, set 1D or 2D operation, set transfer or fill, and indicate if the source or destination is system RAM. If your code will use interrupts, you may enable SDMA interrupts with the SDMA_CTRL0_Int_Enable bit. Do not set SDMA_CTRL0_Start_TRF at this point.
- If the source of the data is in system RAM, set SDMA_SRC_ADDY.
- If the destination of the data is in system RAM, set SDMA_DST_ADDY.
- If the transfer is a 1D operation, set the size (number of bytes) in SDMA_SIZE. If the transfer is a 2D operation, set the width in SDMA_X_SIZE, and the height in SDMA_Y_SIZE.
- If the transfer is a 2D operation, set the source and destination stride values.
- Set the SDMA_CTRL0_Start_TRF bit of SDMA_CONTROL_REG0 to begin the actual transfer.
NOTE: If you are transferring data between system RAM and video RAM, you will have to set up both an SDMA and a VDMA operation, which has special considerations. Please see System and Video RAM DMA for details.
System DMA Registers
Start Address | Stop Address | Register Name | Additional Info | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
$AF:0420 | $AF:0420 | SDMA_CTRL_REG0 | SDMA control register 0
| ||||||||||||||||||||||||
$AF:0421 | $AF:0421 | SDMA_CTRL_REG1 | Reserved for future use | ||||||||||||||||||||||||
$AF:0422 | $AF:0424 | SDMA_SRC_ADDY | 24-bit address of the source (if system RAM is the source) | ||||||||||||||||||||||||
$AF:0425 | $AF:0427 | SDMA_DST_ADDY | 24-bit address of the destination (if system RAM is the destination) | ||||||||||||||||||||||||
$AF:0428 | $AF:042A | SDMA_SIZE | If 1D transfer, the size of the transfer in bytes (24-bits). | ||||||||||||||||||||||||
$AF:0428 | $AF:0429 | SDMA_X_SIZE | If 2D transfer, the 16-bit width of the block. | ||||||||||||||||||||||||
$AF:042A | $AF:042B | SDMA_Y_SIZE | If 2D transfer, the 16-bit height of the block. | ||||||||||||||||||||||||
$AF:042C | $AF:042D | SDMA_SRC_STRIDE | If 2D transfer, the number of bytes per row in the over-all source image (16-bits). | ||||||||||||||||||||||||
$AF:042E | $AF:042F | SDMA_DST_STRIDE | If 2D transfer, the number of bytes per row in the over-all destination image (16-bits). | ||||||||||||||||||||||||
$AF:0430 | $AF:0430 | SDMA_STATUS_REG / SDMA_BYTE_2_WRITE | On write, the byte to write to memory.
On read, the status of the SDMA:
|
SDMA_CTRL_REG0
This register is the main control register for system DMA. The bits are explained in the table above, but the source and destination bits deserve further attention here. The bits should be interpreted as a pair:
SDMA_CTRL0_SysRAM_Src | SDMA_CTRL0_SysRAM_Dst | Tranfer |
---|---|---|
0 | 0 | SRAM to SRAM |
1 | 0 | SRAM to VRAM |
0 | 1 | VRAM to SRAM |
1 | 1 | Reserved |
SDMA_SRC_ADDY
This register is the 3-byte address of the source of the data (if it is in system RAM).
SDMA_DST_ADDY
This register is the 3-byte address of the destination of the data (if it is in system RAM).
SDMA Size
The size of the block to transfer is specified in one of two ways. For a 1-D or linear transfer (bit SDMA_CTRL_1D_2D in the control register is clear), the size is specified as a 24-bit integer using SDMA_SIZE. If the transfer is a 2-D or block transfer (bit SDMA_CTRL_1D_2D in the control register is set), the size is specified as a 16-bit width stored in SDMA_X_SIZE, and a 16-bit height stored in SDMA_Y_SIZE.
Stride
For a 2-D transfer, there is the notion of a "stride," which is the total number of bytes in a row of a source or destination image. The block being transferred may be narrower than the total image. The stride along with the width of the block tells Vicky how many bytes to skip between rows. Source and destination images can have different widths and therefore different strides. The stride of the source is specified by the two-byte register SDMA_SRC_STRIDE, and the stride of the destination by SDMA_DST_STRIDE.
The relationship between stride, width, and height of a block can be seen in the diagram below: