Snitch Runtime
Loading...
Searching...
No Matches
dma.h File Reference

This file provides functions to program the Snitch DMA. More...

Go to the source code of this file.

Macros

#define OP_CUSTOM1   0b0101011
 
#define XDMA_FUNCT3   0b000
 
#define DMSRC_FUNCT7   0b0000000
 
#define DMDST_FUNCT7   0b0000001
 
#define DMCPYI_FUNCT7   0b0000010
 
#define DMCPY_FUNCT7   0b0000011
 
#define DMSTATI_FUNCT7   0b0000100
 
#define DMSTAT_FUNCT7   0b0000101
 
#define DMSTR_FUNCT7   0b0000110
 
#define DMREP_FUNCT7   0b0000111
 
#define R_TYPE_ENCODE(funct7, rs2, rs1, funct3, rd, opcode)
 

Typedefs

typedef uint32_t snrt_dma_txid_t
 A DMA transfer identifier.
 

Functions

uint32_t snrt_dma_start_1d_wideptr (uint64_t dst, uint64_t src, size_t size)
 Start an asynchronous 1D DMA transfer with 64-bit wide pointers.
 
snrt_dma_txid_t snrt_dma_start_1d (void *dst, const void *src, size_t size)
 Start an asynchronous 1D DMA transfer with native-size pointers.
 
snrt_dma_txid_t snrt_dma_start_2d_wideptr (uint64_t dst, uint64_t src, size_t size, size_t dst_stride, size_t src_stride, size_t repeat)
 Start an asynchronous 2D DMA transfer with 64-bit wide pointers.
 
snrt_dma_txid_t snrt_dma_start_2d (void *dst, const void *src, size_t size, size_t dst_stride, size_t src_stride, size_t repeat)
 Start an asynchronous 2D DMA transfer with native-size pointers.
 
snrt_dma_txid_t snrt_dma_start_1d_channel_wideptr (uint64_t dst, uint64_t src, size_t size, uint32_t channel)
 Start an asynchronous 1D DMA transfer with 64-bit wide pointers on a specific channel.
 
snrt_dma_txid_t snrt_dma_start_1d_channel (void *dst, const void *src, size_t size, uint32_t channel)
 Start an asynchronous 1D DMA transfer with native-size pointers on a specific channel.
 
snrt_dma_txid_t snrt_dma_start_2d_channel_wideptr (uint64_t dst, uint64_t src, size_t size, size_t dst_stride, size_t src_stride, size_t repeat, uint32_t channel)
 Start an asynchronous 2D DMA transfer with 64-bit wide pointers on a specific channel.
 
snrt_dma_txid_t snrt_dma_start_2d_channel (void *dst, const void *src, size_t size, size_t dst_stride, size_t src_stride, size_t repeat, uint32_t channel)
 Start an asynchronous 2D DMA transfer with native-size pointers on a specific channel.
 
void snrt_dma_wait (snrt_dma_txid_t tid)
 Block until a DMA transfer finishes.
 
void snrt_dma_wait_channel (snrt_dma_txid_t tid, uint32_t channel)
 Block until a DMA transfer finishes on a specific channel.
 
void snrt_dma_wait_all ()
 Block until all DMA operation ceases.
 
void snrt_dma_wait_all_channel (uint32_t channel)
 Block until a specific DMA channel is idle.
 
void snrt_dma_wait_all_channels (uint32_t num_channels)
 Block until the first num_channels channels are idle.
 
void snrt_dma_start_tracking ()
 Start tracking of dma performance region. Does not have any implications on the HW. Only injects a marker in the DMA traces that can be analyzed.
 
void snrt_dma_stop_tracking ()
 Stop tracking of dma performance region. Does not have any implications on the HW. Only injects a marker in the DMA traces that can be analyzed.
 
void snrt_dma_memset (void *ptr, uint8_t value, uint32_t len)
 Fast memset function performed by DMA.
 
snrt_dma_txid_t snrt_dma_load_1d_tile (void *dst, void *src, size_t tile_idx, size_t tile_size, uint32_t prec)
 Load a tile of a 1D array.
 
snrt_dma_txid_t snrt_dma_store_1d_tile (void *dst, void *src, size_t tile_idx, size_t tile_size, uint32_t prec)
 Store a tile to a 1D array.
 
snrt_dma_txid_t snrt_dma_load_2d_tile (void *dst, void *src, size_t tile_x1_idx, size_t tile_x0_idx, size_t tile_x1_size, size_t tile_x0_size, size_t full_x0_size, uint32_t prec)
 Load a 2D tile of a 2D array.
 
snrt_dma_txid_t snrt_dma_store_2d_tile (void *dst, void *src, size_t tile_x1_idx, size_t tile_x0_idx, size_t tile_x1_size, size_t tile_x0_size, size_t full_x0_size, uint32_t prec)
 Store a 2D tile to a 2D array.
 

Detailed Description

This file provides functions to program the Snitch DMA.

Macro Definition Documentation

◆ R_TYPE_ENCODE

#define R_TYPE_ENCODE ( funct7,
rs2,
rs1,
funct3,
rd,
opcode )
Value:
((funct7 << 25) | (rs2 << 20) | (rs1 << 15) | (funct3 << 12) | (rd << 7) | \
(opcode))

Function Documentation

◆ snrt_dma_load_1d_tile()

snrt_dma_txid_t snrt_dma_load_1d_tile ( void * dst,
void * src,
size_t tile_idx,
size_t tile_size,
uint32_t prec )
inline

Load a tile of a 1D array.

Parameters
dstPointer to the tile destination.
srcPointer to the source array.
tile_idxIndex of the tile in the 1D array.
tile_sizeNumber of elements within a tile of the 1D array.
precNumber of bytes of each element in the 1D array.

◆ snrt_dma_load_2d_tile()

snrt_dma_txid_t snrt_dma_load_2d_tile ( void * dst,
void * src,
size_t tile_x1_idx,
size_t tile_x0_idx,
size_t tile_x1_size,
size_t tile_x0_size,
size_t full_x0_size,
uint32_t prec )
inline

Load a 2D tile of a 2D array.

Parameters
dstPointer to the tile destination.
srcPointer to the source array.
tile_x1_idxOutermost coordinate of the tile in the 2D array.
tile_x0_idxInnermost coordinate of the tile in the 2D array.
tile_x1_sizeNumber of elements in the outermost dimension of the tile.
tile_x0_sizeNumber of elements in the innermost dimension of the tile.
full_x0_sizeNumber of elements in the innermost dimension of the array.
precNumber of bytes of each element in the 2D array.

◆ snrt_dma_memset()

void snrt_dma_memset ( void * ptr,
uint8_t value,
uint32_t len )
inline

Fast memset function performed by DMA.

Parameters
ptrPointer to the start of the region.
valueValue to set.
lenNumber of bytes, must be a multiple of the DMA bus width.

◆ snrt_dma_start_1d()

snrt_dma_txid_t snrt_dma_start_1d ( void * dst,
const void * src,
size_t size )
inline

Start an asynchronous 1D DMA transfer with native-size pointers.

Parameters
dstThe destination pointer.
srcThe source pointer.
sizeThe size of the transfer in bytes.
Returns
The DMA transfer ID.

◆ snrt_dma_start_1d_channel()

snrt_dma_txid_t snrt_dma_start_1d_channel ( void * dst,
const void * src,
size_t size,
uint32_t channel )
inline

Start an asynchronous 1D DMA transfer with native-size pointers on a specific channel.

Parameters
dstThe destination pointer.
srcThe source pointer.
sizeThe size of the transfer in bytes.
channelThe index of the channel.
Returns
The DMA transfer ID.

◆ snrt_dma_start_1d_channel_wideptr()

snrt_dma_txid_t snrt_dma_start_1d_channel_wideptr ( uint64_t dst,
uint64_t src,
size_t size,
uint32_t channel )
inline

Start an asynchronous 1D DMA transfer with 64-bit wide pointers on a specific channel.

Parameters
dstThe destination address.
srcThe source address.
sizeThe size of the transfer in bytes.
channelThe index of the channel.
Returns
The DMA transfer ID.

◆ snrt_dma_start_1d_wideptr()

uint32_t snrt_dma_start_1d_wideptr ( uint64_t dst,
uint64_t src,
size_t size )
inline

Start an asynchronous 1D DMA transfer with 64-bit wide pointers.

Parameters
dstThe destination address.
srcThe source address.
sizeThe size of the transfer in bytes.
Returns
The DMA transfer ID.

◆ snrt_dma_start_2d()

snrt_dma_txid_t snrt_dma_start_2d ( void * dst,
const void * src,
size_t size,
size_t dst_stride,
size_t src_stride,
size_t repeat )
inline

Start an asynchronous 2D DMA transfer with native-size pointers.

Parameters
dstThe destination address.
srcThe source address.
sizeThe size of every 1D transfer within the 2D transfer in bytes.
dst_strideThe offset between consecutive 1D transfers at the destination, in bytes.
src_strideThe offset between consecutive 1D transfers at the source, in bytes.
repeatThe number of 1D transfers composing the 2D transfer.
Returns
The DMA transfer ID.

◆ snrt_dma_start_2d_channel()

snrt_dma_txid_t snrt_dma_start_2d_channel ( void * dst,
const void * src,
size_t size,
size_t dst_stride,
size_t src_stride,
size_t repeat,
uint32_t channel )
inline

Start an asynchronous 2D DMA transfer with native-size pointers on a specific channel.

Parameters
dstThe destination address.
srcThe source address.
sizeThe size of every 1D transfer within the 2D transfer in bytes.
dst_strideThe offset between consecutive 1D transfers at the destination, in bytes.
src_strideThe offset between consecutive 1D transfers at the source, in bytes.
repeatThe number of 1D transfers composing the 2D transfer.
channelThe index of the channel.
Returns
The DMA transfer ID.

◆ snrt_dma_start_2d_channel_wideptr()

snrt_dma_txid_t snrt_dma_start_2d_channel_wideptr ( uint64_t dst,
uint64_t src,
size_t size,
size_t dst_stride,
size_t src_stride,
size_t repeat,
uint32_t channel )
inline

Start an asynchronous 2D DMA transfer with 64-bit wide pointers on a specific channel.

Parameters
dstThe destination address.
srcThe source address.
sizeThe size of every 1D transfer within the 2D transfer in bytes.
dst_strideThe offset between consecutive 1D transfers at the destination, in bytes.
src_strideThe offset between consecutive 1D transfers at the source, in bytes.
repeatThe number of 1D transfers composing the 2D transfer.
channelThe index of the channel.
Returns
The DMA transfer ID.

◆ snrt_dma_start_2d_wideptr()

snrt_dma_txid_t snrt_dma_start_2d_wideptr ( uint64_t dst,
uint64_t src,
size_t size,
size_t dst_stride,
size_t src_stride,
size_t repeat )
inline

Start an asynchronous 2D DMA transfer with 64-bit wide pointers.

Parameters
dstThe destination address.
srcThe source address.
sizeThe size of every 1D transfer within the 2D transfer in bytes.
dst_strideThe offset between consecutive 1D transfers at the destination, in bytes.
src_strideThe offset between consecutive 1D transfers at the source, in bytes.
repeatThe number of 1D transfers composing the 2D transfer.
Returns
The DMA transfer ID.

◆ snrt_dma_start_tracking()

void snrt_dma_start_tracking ( )
inline

Start tracking of dma performance region. Does not have any implications on the HW. Only injects a marker in the DMA traces that can be analyzed.

Deprecated

◆ snrt_dma_stop_tracking()

void snrt_dma_stop_tracking ( )
inline

Stop tracking of dma performance region. Does not have any implications on the HW. Only injects a marker in the DMA traces that can be analyzed.

Deprecated

◆ snrt_dma_store_1d_tile()

snrt_dma_txid_t snrt_dma_store_1d_tile ( void * dst,
void * src,
size_t tile_idx,
size_t tile_size,
uint32_t prec )
inline

Store a tile to a 1D array.

Parameters
dstPointer to the destination array.
srcPointer to the source tile.
tile_idxIndex of the tile in the 1D array.
tile_sizeNumber of elements within a tile of the 1D array.
precNumber of bytes of each element in the 1D array.

◆ snrt_dma_store_2d_tile()

snrt_dma_txid_t snrt_dma_store_2d_tile ( void * dst,
void * src,
size_t tile_x1_idx,
size_t tile_x0_idx,
size_t tile_x1_size,
size_t tile_x0_size,
size_t full_x0_size,
uint32_t prec )
inline

Store a 2D tile to a 2D array.

Parameters
dstPointer to the destination array.
srcPointer to the source tile.
tile_x1_idxOutermost coordinate of the tile in the 2D array.
tile_x0_idxInnermost coordinate of the tile in the 2D array.
tile_x1_sizeNumber of elements in the outermost dimension of the tile.
tile_x0_sizeNumber of elements in the innermost dimension of the tile.
full_x0_sizeNumber of elements in the innermost dimension of the array.
precNumber of bytes of each element in the 2D array.

◆ snrt_dma_wait()

void snrt_dma_wait ( snrt_dma_txid_t tid)
inline

Block until a DMA transfer finishes.

Parameters
dstThe DMA transfer ID.

◆ snrt_dma_wait_all_channel()

void snrt_dma_wait_all_channel ( uint32_t channel)
inline

Block until a specific DMA channel is idle.

Parameters
channelThe index of the channel.

◆ snrt_dma_wait_all_channels()

void snrt_dma_wait_all_channels ( uint32_t num_channels)
inline

Block until the first num_channels channels are idle.

Parameters
num_channelsThe number of channels to wait on.

◆ snrt_dma_wait_channel()

void snrt_dma_wait_channel ( snrt_dma_txid_t tid,
uint32_t channel )
inline

Block until a DMA transfer finishes on a specific channel.

Parameters
dstThe DMA transfer ID.