UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Reply

How to work with VDMA

Highlighted
Contributor
Posts: 30
Registered: ‎09-21-2016

How to work with VDMA

Hi everyone,

 

I want to know what is the correct combination for VDMA. Actually, I am discussing this thing to make myself more clear. Your valuable suggestion will be helpful to me. VDMA has two channels, for write and read. and every channel has following parameters:

  1. Memory mapped data width : Set parameter value 32.  In the memory, Data will be stored as 32-bit width data.
  2. Write/read burst size : In case of read, if we set 32, we will read data from the memory as 32-bit data at a time. 
  3. Stream Data width : This actual data width.
  4. Line Buffer depth : The line buffer depth for  depth for S2MM/MM2S channel.

Actually, I am not so clear about no 2 & no. 4 parameters definition. Suppose, for 24 bit RGB, 1280*1024 resolution what will be the correct value for no.2 and no.4 parameters. I also attached my whole design.

 

 

1.png

I am trying to display 24 bit rgb data. I have assigned the data at SDK. At the end, I don’t have any output. The configuration for VDMA

2.PNG

The read operation is only enable as I am writing data manually by myself through SDK.

 

The SDK codes:

/////ro_vdma.c/////
/******************** Include files **********************************/ #include "xaxivdma.h" #include "xparameters.h" #include "ro_vdma.h" typedef struct vdma_handle { /* The device ID of the VDMA */ unsigned int device_id; /* The state variable to keep track if the initialization is done*/ unsigned int init_done; /** The XAxiVdma driver instance data. */ XAxiVdma* InstancePtr; /* The XAxiVdma_DmaSetup structure contains all the necessary information to * start a frame write or read. */ XAxiVdma_DmaSetup ReadCfg; //XAxiVdma_DmaSetup WriteCfg; /* Horizontal size of frame */ unsigned int hsize; /* Vertical size of frame */ unsigned int vsize; /* Buffer address from where read and write will be done by VDMA */ unsigned int buffer_address; }vdma_handle; vdma_handle vdma_context[XPAR_XAXIVDMA_NUM_INSTANCES]; static unsigned int context_init=0; static int ReadSetup(vdma_handle *vdma_context); //static int WriteSetup(vdma_handle *vdma_context); static int StartTransfer(XAxiVdma *InstancePtr); int single_frame_buffer(XAxiVdma* InstancePtr, int DeviceId, int hsize,\ int vsize, int buf_base_addr){ int Status,i; XAxiVdma_Config *Config; if(context_init==0) { for(i=0;i<XPAR_XAXIVDMA_NUM_INSTANCES;i++) { vdma_context[i].InstancePtr = NULL; vdma_context[i].device_id = -1; vdma_context[i].hsize = 0; vdma_context[i].vsize = 0; vdma_context[i].init_done = 0; vdma_context[i].buffer_address = 0; } context_init = 1; } Config = XAxiVdma_LookupConfig(DeviceId); if(vdma_context[DeviceId].init_done ==0) { vdma_context[DeviceId].InstancePtr = InstancePtr; /* Initialize DMA engine */ Status = XAxiVdma_CfgInitialize(vdma_context[DeviceId].InstancePtr, Config, Config->BaseAddress); vdma_context[DeviceId].init_done = 1; } vdma_context[DeviceId].device_id = DeviceId; vdma_context[DeviceId].vsize = vsize; vdma_context[DeviceId].buffer_address = buf_base_addr; vdma_context[DeviceId].hsize = hsize * 2; Status = ReadSetup(&vdma_context[DeviceId]); /* Start the DMA engine to transfer */ Status = StartTransfer(vdma_context[DeviceId].InstancePtr); return XST_SUCCESS; } static int ReadSetup(vdma_handle *vdma_context) { int Index; u32 Addr; int Status; vdma_context->ReadCfg.VertSizeInput = vdma_context->vsize; vdma_context->ReadCfg.HoriSizeInput = vdma_context->hsize; vdma_context->ReadCfg.Stride = vdma_context->hsize; vdma_context->ReadCfg.FrameDelay = 0; /* This example does not test frame delay */ vdma_context->ReadCfg.EnableCircularBuf = 1; vdma_context->ReadCfg.EnableSync = 1; /* Gen-Lock */ vdma_context->ReadCfg.PointNum = 0; vdma_context->ReadCfg.EnableFrameCounter = 0; /* Endless transfers */ vdma_context->ReadCfg.FixedFrameStoreAddr = 0; /* We are not doing parking */ /* Configure the VDMA is per fixed configuration, THis configuration is being used by majority * of customer. Expert users can play around with this if they have different configurations */ Status = XAxiVdma_DmaConfig(vdma_context->InstancePtr, XAXIVDMA_READ, &vdma_context->ReadCfg); if (Status != XST_SUCCESS) { xil_printf( "Read channel config failed %d\r\n", Status); return XST_FAILURE; } /* Initialize buffer addresses * * These addresses are physical addresses */ Addr = vdma_context->buffer_address; for(Index = 0; Index < vdma_context->InstancePtr->MaxNumFrames; Index++) { vdma_context->ReadCfg.FrameStoreStartAddr[Index] = Addr; /* Initializing the buffer in case of Debug mode */ Addr += vdma_context->hsize * vdma_context->vsize; } /* Set the buffer addresses for transfer in the DMA engine * The buffer addresses are physical addresses */ Status = XAxiVdma_DmaSetBufferAddr(vdma_context->InstancePtr, XAXIVDMA_READ, vdma_context->ReadCfg.FrameStoreStartAddr); if (Status != XST_SUCCESS) { xil_printf( "Read channel set buffer address failed %d\r\n", Status); return XST_FAILURE; } return XST_SUCCESS; } static int StartTransfer(XAxiVdma *InstancePtr) { int Status; /* Start the write channel of VDMA */ /* Status = XAxiVdma_DmaStart(InstancePtr, XAXIVDMA_WRITE); if (Status != XST_SUCCESS) { xil_printf( "Start Write transfer failed %d\r\n", Status); return XST_FAILURE; } */ /* Start the Read channel of VDMA */ Status = XAxiVdma_DmaStart(InstancePtr, XAXIVDMA_READ); if (Status != XST_SUCCESS) { xil_printf( "Start read transfer failed %d\r\n", Status); return XST_FAILURE; } return XST_SUCCESS; }
///// main.c///////


#include "xparameters.h"
#include "xstatus.h"
#include "xintc.h"
#include "xil_exception.h"
#include "xil_assert.h"
#include "xaxivdma.h"
#include "xaxivdma_i.h"
#include "ro_vdma.h"


#define VDMA_IMG_B1_BASE		((XPAR_MIG7SERIES_0_BASEADDR  + 0x1000000) + 1280*1024*2)

unsigned int srcBuffer = (XPAR_MIG7SERIES_0_BASEADDR  + 0x1000000);
void MemInit();

int main(){

	xil_printf("\n--- Entering main() --- \r\n");
	int Status;
	XAxiVdma InstancePtr;

	xil_printf("Starting the first VDMA \n\r");

	/* Calling the API to configure and start VDMA without frame counter interrupt */
	Status = single_frame_buffer(&InstancePtr,0,1280,1024,srcBuffer);
	if (Status != XST_SUCCESS){
		xil_printf("Transfer of frames failed with error = %d\r\n",Status);
		return XST_FAILURE;
	}
	else
	{
		xil_printf("Transfer of frames started \r\n");
	}
	while(1){
		MemInit();
	}
}


void MemInit()
{
	u32 *pM1 = (u32 *)srcBuffer;
	u32 i, j;

	for(i = 0; i < 1024; i++)
	{
		for(j = 0; j < 1280; j++)
		{
			pM1[i*1280 + j] = 255;
		}
	}
}

I have tried to follow to Xilinx vdma example design but not so much helpful to me. Any suggestion will be very helpful.

 

Thank you

Rappy Saha

 

Teacher
Posts: 4,667
Registered: ‎03-31-2012

Re: How to work with VDMA

@rappysaha

 

>> Memory mapped data width : Set parameter value 32.  In the memory, Data will be stored as 32-bit width data.

No. this parameter defines the width of the axi interface used to write the data. Data size can be different, ie if you  have a monochrome 8 bit data, 4 bytes would be packed and would be written as a single 32 bit transaction.

 

>> Write/read burst size : In case of read, if we set 32, we will read data from the memory as 32-bit data at a time. 

No,  burst size is the number of transactions within a single burst ie one address transaction is generated per 32 data transactions.

 

>> Line Buffer depth : The line buffer depth for  depth for S2MM/MM2S channel.

 

Line buffer length is independent of the resolution. 

- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.