完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,
我已将Xilinx CDMA(中央DMA控制器)连接到EDK项目。 现在我需要使用SDK中的C程序来测试它。 我的项目中有DDR3和BRAM。 如何编写C程序通过CDMA将DDR3数据写入BRAM? 谢谢。 以上来自于谷歌翻译 以下为原文 Hi, I have attached a Xilinx CDMA (central DMA controller) to EDK project. Now I need to test this using a C program in SDK. I have DDR3 and BRAM in my project. How to write a C program to write DDR3 data to BRAM via CDMA? Thank you. |
|
相关推荐
8个回答
|
|
Sam,在ASK中,您可以创建一个新的C项目来测试系统中的外围设备。
您可以查看DMA的测试应用程序。 否则,您可以创建一个弓形支撑包并查看牲畜来源。 在那里,您将看到中央DMA的文件夹。 您可以查看xcdma.h,这是中央DMA引擎的API。 您将了解到Dan通过配置DMA执行所需的传输,然后调用传递函数并将源和目标指针与传输大小一起传递给它。 如果您有任何疑问,请回复。 祝你好运! 以上来自于谷歌翻译 以下为原文 Sam, In ASK you can create a new C Project for testing the peripherals in you system. There is a test app for the DMA that you can look at. Otherwise you can create a bowed support package and look at the livestock sources. In there you will see a folder for the central DMA. You can look at xcdma.h, this is the API for the central DMA engine. You will learn that you Dan perform the transfer you want by configuring the DMA, then calling the transfer function and pass it the source and destination pointers along with the transfer size. Post back if you have any questions. Good luck! |
|
|
|
**哔**,我在手机里这样做,我没有拼写检查,自动纠正了我。
更正如下:SDK不是ASKboard没有鞠躬库不是牲畜不能Dan我再也不会在手机中这样做了。 以上来自于谷歌翻译 以下为原文 **bleep**, I am doing this in my phone and I didn't spell check, auto correct got me. Corrections as follows: SDK not ASK board not bowed library not livestock can not Dan I'm never doing this in a phone again. |
|
|
|
嗨,
感谢您的答复。 以下是我试过的基于中断的CDMA数据传输。 在这里,我使用以下API: int XAxiCdma_SimpleTransfer(XAxiCdma * InstancePtr,u32 SrcAddr,u32 DstAddr,int Length,XAxiCdma_CallBackFn SimpleCallBack,void * CallbackRef); 但, 1)以下代码不起作用! 知道为什么会这样吗? 2)比较“轮询模式下的DMA”和“DMA中断模式”时最快的是什么? 3)我可以在XAxiCdma_SimpleTransfer(...)中传输的最大长度是多少? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++ #include“xparameters.h”#include“stdio.h”#include“xutil.h”#include“xaxicdma.h”#include“xil_exception.h”#include“xtmrctr.h”#include“xil_cache.h”volatile static int Done = 0; volatile static int Error = 0; static void Example_CallBack(void * CallBackRef,u32 IrqMask,int * IgnorePtr){if(IrqMask&amp; XAXICDMA_XR_IRQ_ERROR_MASK){Error = 1; } if(IrqMask&amp; XAXICDMA_XR_IRQ_IOC_MASK){Done = 1; int main(void){int i = 0; int状态; int * ddrData = XPAR_DDR3_SDRAM_S_AXI_BASEADDR; int * ptrData = XPAR_DATA_BRAM_CNTLR_0_S_AXI_BASEADDR; XAxiCdma xcdma; //初始化源数据(i = 0; i {*(ddrData + i)= i;} / *内存传输* / XAxiCdma_IntrEnable(&amp; xcdma,XAXICDMA_XR_IRQ_ALL_MASK); Status = XAxiCdma_SimpleTransfer(&amp; xcdma,* ddrData,* ptrData,16,Example_CallBack,(void *)&amp; xcdma); for(i = 0; i {xil_printf(“目标数据:%d n”,*(ptrData + i));}返回0;} ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++ 以上来自于谷歌翻译 以下为原文 Hi, Thank you for the reply. Following is a interrupt based CDMA data transfer I tried. Here, I use following API: int XAxiCdma_SimpleTransfer(XAxiCdma *InstancePtr, u32 SrcAddr, u32 DstAddr, int Length, XAxiCdma_CallBackFn SimpleCallBack, void *CallbackRef); But, 1) Following code is not working! Any idea why is that? 2) What is the fastest when compare "DMA in polling mode" and "DMA in interrupt mode"? 3) What is the maximum length that I can transfer in XAxiCdma_SimpleTransfer(...)? ++++++++++++++++++++++++++++++++++ CODE +++++++++++++++++++++++++++++++++++++++ #include "xparameters.h" #include "stdio.h" #include "xutil.h" #include "xaxicdma.h" #include "xil_exception.h" #include "xtmrctr.h" #include "xil_cache.h" volatile static int Done = 0; volatile static int Error = 0; static void Example_CallBack(void *CallBackRef, u32 IrqMask, int *IgnorePtr) { if (IrqMask & XAXICDMA_XR_IRQ_ERROR_MASK) { Error = 1; } if (IrqMask & XAXICDMA_XR_IRQ_IOC_MASK) { Done = 1; } } int main(void) { int i = 0; int Status; int *ddrData = XPAR_DDR3_SDRAM_S_AXI_BASEADDR; int *ptrData = XPAR_DATA_BRAM_CNTLR_0_S_AXI_BASEADDR; XAxiCdma xcdma; //Initialize source data for (i=0;i<1024;i++) { *(ddrData+i) = i; } /*Memory transfer*/ XAxiCdma_IntrEnable(&xcdma, XAXICDMA_XR_IRQ_ALL_MASK); Status = XAxiCdma_SimpleTransfer(&xcdma, *ddrData, *ptrData, 16, Example_CallBack, (void *) &xcdma); for (i=0;i<16;i++) { xil_printf("Destination Data : %dn",*(ptrData+i)); } return 0; } ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
|
|
好的,您必须在第一次使用DMA之前配置DMA。
您还必须在中断控制器中启用DMA中断。 您将在xparameters.h中看到中断ID,您需要初始化中断控制器并启用DMA中断ID。 你在用什么处理器? 微纤维需要一些额外的步骤。 就轮询与中断驱动而言,中断驱动将允许您在DMA引擎进行传输时执行处理器中的指令。 但是,当DMA是总线主控时,你不能执行任何总线事务。我真的建议查看外设测试代码。 一切都在那里使DMA工作。祝你好运!P.S。 我又在手机上做了这件事......恨自己 以上来自于谷歌翻译 以下为原文 Ok, You have to configure the DMA before you use it the first time. You also have to enable the DMA interrupt in the interrupt controller. You will see the interrupt ID in xparameters.h , you need to initialize the interrupt controller and enable the DMA interrupt ID. What processor are you using? There are some extra steps needed for microblaze. As far as polled vs interrupt driven, interrupt driven will allow you to execute instructions in the processor while the DMA engine is doing the transfer. You cannot however perform any bus transaction while the DMA is the bus master. I would really suggest looking at the peripheral test code. Everything is in there to make the DMA work. Good luck! P.S. I did this on a phone again... Hate myself |
|
|
|
嗨cosgrma,
谢谢您的回复。 我在Virtex-6中使用的是tinylaze处理器。 我尝试了DMA外设测试代码并成功完成了。 关于我的要求,我需要将(1024 * 64)32位字从DDR存储器传输到BRAM,我需要尽快继续这样做.1)最快的方法是什么? Xilinx CDMA是最佳选择吗?2)Xilinx CDMA是否比memcpy(...)更快?我注意到DMA是以字节而不是字的形式执行的。 如果我有32位源缓冲区和目标缓冲区,通过CDMA执行该方法的最快方法是什么。例如,//来自CDMA外设测试代码volatile static u8 SrcBuffer [BUFFER_BYTESIZE] __attribute __((aligned(64))); volatile static u8 DestBuffer [BUFFER_BYTESIZE] __attribute __((aligned(64))); // Requirementint * DDRBuffer = XPAR_DDR3_SDRAM_S_AXI_BASEADDR; // 32位数据* BRAMBuffer = XPAR_DATA_BRAM_CNTLR_0_S_AXI_BASEADDR; // 32位数据3)如何通过DMA将DDRBuffer传输到BRAMBuffer? 谢谢。 以上来自于谷歌翻译 以下为原文 Hi cosgrma, Thank you for your reply. I am using microblaze processor in Virtex-6. I tried the DMA peripheral test code and successful. Regarding my requirement, I need to transfer (1024*64) 32-bit words from DDR memory to BRAM and I need to continue this as fast as possible. 1) What is the fastest method to do that? Is Xilinx CDMA the best option for this? 2) Is Xilinx CDMA faster than memcpy(…)? I have notice that DMA is performed as bytes not words. If I have 32-bit source buffer and destination buffer, what is the fastest way to perform that via CDMA. As example, //From CDMA peripheral test code volatile static u8 SrcBuffer[BUFFER_BYTESIZE] __attribute__ ((aligned (64))); volatile static u8 DestBuffer[BUFFER_BYTESIZE] __attribute__ ((aligned (64))); //Requirement int *DDRBuffer = XPAR_DDR3_SDRAM_S_AXI_BASEADDR; //32-bit data int *BRAMBuffer = XPAR_DATA_BRAM_CNTLR_0_S_AXI_BASEADDR; //32-bit data 3) How to transfer DDRBuffer to BRAMBuffer via DMA? Thank you. |
|
|
|
1)最快的方法是什么?
Xilinx CDMA是最佳选择吗? 专用传输引擎总是比处理器为您完成更快。 当DMA执行其传输操作时,处理器仍然可以执行指令。 CDMA应该是一个很好的选择。 2)Xilinx CDMA是否比memcpy(...)更快? 是的,memcpy将使用处理器执行复制,因此它比专用引擎慢。 3)如何通过DMA将DDRBuffer传输到BRAMBuffer? 因此,我认为您已经研究了外围测试应用程序并知道了首次使用设置DMA的正确步骤。 上面粘贴的测试应用程序中的SrcBuffer / DstBuffer代码只是为传输设置了内存区域,这些区域保存在您指定的.data部分放置在链接描述文件中的任何位置。 如果启用它,通常默认为DDR。 我想你已经运行了内存测试应用程序,所有内存区域都配置正确。 要执行传输,您只需从CDMA API运行传输功能即可。 我没有API,但功能如下: XCDMA_Transfer(void * SrcPointer,void * DstPointer,int length); u32 * SrcPointer =(u32 *)XCDMA_BaseAddress; u32 * DstPointer =(u32 *)DDR_BaseAddress; 您还必须确保刷新并使任何数据缓存无效。 查看测试应用程序以指导您完成此部分。 作为快速测试,您只需更改测试应用中的源或目标。 祝你好运! 以上来自于谷歌翻译 以下为原文 1) What is the fastest method to do that? Is Xilinx CDMA the best option for this? A Dedicated transfer engine will always be faster than having the processor do it for you. The processor can still execute instructions while the DMA is performing its transfer operation. CDMA should be a fine option for this. 2) Is Xilinx CDMA faster than memcpy(…)? Yes, memcpy will use the processor to perform the copy so it will be slower than a dedicated engine. 3) How to transfer DDRBuffer to BRAMBuffer via DMA? So I image that you have studied the peripheral test application and know the proper steps to take to setup the DMA for first use. The SrcBuffer/DstBuffer code from the test app you pasted above simply sets up the memory regions for the transfer, these regions are saved wherever you specified .data sections to be placed in the linker script. It usually defaults to DDR if you have it enabled. I imagine that you have run the memory test app and all of your memory regions are configured properly. To perform the transfer all you need to do is run the transfer function from the CDMA API. I don't have the API with me but the function is like: XCDMA_Transfer(void * SrcPointer, void * DstPointer, int length); u32 *SrcPointer = (u32 *)XCDMA_BaseAddress; u32 *DstPointer = (u32 *)DDR_BaseAddress; You have to also make sure that you flush and invalidate the any data caching. Look at the test app to guide you for this part. As a quick test you could just change either the Source or Destination in the test app. Good Luck! |
|
|
|
嗨,谢谢你的回复。
在我的情况下,我的源数据在DDR3内存中,我需要将数据传输到Block RAM。 所以, 1)在链接器脚本中,我的数据部分应该是什么? 是DDR还是BRAM?关于以下缓冲区,volatile static u32 SrcBuffer [BUFFER_BYTESIZE] __attribute __((aligned(256))); volatile static u32 DestBuffer [BUFFER_BYTESIZE] __attribute __((aligned(256))); 2)是否可能 在BRAM中使用DDR3和DestBuffer制作SrcBuffer? 如果可能的话如何分配它们? 当我分配了以下内容时,它失败了。 u32 * SrcBuffer =(u32 *)DDR3_BASEADDR; u32 * DestBuffer =(u32 *)BRAM_BASEADDR; 3)我不能以这种方式指责指针吗? 关于API,Status = XAxiCdma_SimpleTransfer(InstancePtr,(u32)SrcBuffer,(u32)DestBuffer,Length,NULL,NULL);你声明,u32 * SrcPointer =(u32 *)XCDMA_BaseAddress; 4)这是正确的吗? 或者不应该是DDR3_BaseAddress?当两个缓冲区都在DDR3或BRAM中时,我的代码正常工作。谢谢。 以上来自于谷歌翻译 以下为原文 Hi, Thank you for the reply. In my case, my source data is in DDR3 memory and I need to transfer that data in to Block RAM. So, 1) In linker script, what should be my data section? Is it DDR or BRAM? Regarding the following buffers, volatile static u32 SrcBuffer[BUFFER_BYTESIZE] __attribute__ ((aligned (256))); volatile static u32 DestBuffer[BUFFER_BYTESIZE] __attribute__ ((aligned (256))); 2) Is it possible to make SrcBuffer in DDR3 and DestBuffer in BRAM? If possible how to assign them? When I assigned following, it failed. u32 *SrcBuffer = (u32 *)DDR3_BASEADDR; u32 *DestBuffer = (u32 *)BRAM_BASEADDR; 3) Can't I asign pointers in that way? Regarding the API, Status = XAxiCdma_SimpleTransfer(InstancePtr, (u32)SrcBuffer, (u32)DestBuffer, Length, NULL, NULL); you states that, u32 *SrcPointer = (u32 *)XCDMA_BaseAddress; 4) Is it correct? or shouldn't that be DDR3_BaseAddress? My code is working when both buffers are in either DDR3 or BRAM. Thank you. |
|
|
|
嗨,
关于以下缓冲区,volatile static u32 SrcBuffer [BUFFER_BYTESIZE] __attribute __((aligned(256))); volatile static u32 DestBuffer [BUFFER_BYTESIZE] __attribute __((aligned(256))); 1)是否可以在BRAM中使用DDR3和DestBuffer制作SrcBuffer? 如何分配它们? 2)在上面的例子中,链接器脚本中的数据部分应该是什么? 谢谢。 以上来自于谷歌翻译 以下为原文 Hi, Regarding the following buffers,volatile static u32 SrcBuffer[BUFFER_BYTESIZE] __attribute__ ((aligned (256))); volatile static u32 DestBuffer[BUFFER_BYTESIZE] __attribute__ ((aligned (256))); 1) Is it possible to make SrcBuffer in DDR3 and DestBuffer in BRAM? How to assign them? 2) In the above case, what should be the data section in linker script? Thank you. |
|
|
|
只有小组成员才能发言,加入小组>>
2415 浏览 7 评论
2821 浏览 4 评论
Spartan 3-AN时钟和VHDL让ISE合成时出现错误该怎么办?
2292 浏览 9 评论
3372 浏览 0 评论
如何在RTL或xilinx spartan fpga的约束文件中插入1.56ns延迟缓冲区?
2458 浏览 15 评论
有输入,但是LVDS_25的FPGA内部接收不到数据,为什么?
1081浏览 1评论
请问vc707的电源线是如何连接的,我这边可能出现了缺失元件的情况导致无法供电
579浏览 1评论
求一块XILINX开发板KC705,VC707,KC105和KCU1500
440浏览 1评论
2000浏览 0评论
723浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-20 13:03 , Processed in 1.499764 second(s), Total 91, Slave 75 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号