99精品伊人亚洲|最近国产中文炮友|九草在线视频支援|AV网站大全最新|美女黄片免费观看|国产精品资源视频|精彩无码视频一区|91大神在线后入|伊人终合在线播放|久草综合久久中文

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

Xilinx FPGA里面的AXI DMA IP核的簡(jiǎn)單用法

C29F_xilinx_inc ? 來(lái)源:賽靈思 ? 作者:賽靈思 ? 2022-02-16 16:21 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

FPGA里面,AXI DMA這個(gè)IP核的主要作用,就是在Verilog語(yǔ)言和C語(yǔ)言之間傳輸大批量的數(shù)據(jù),使用的通信協(xié)議為AXI4-Stream。

Xilinx很多IP核都是基于AXI4-Stream協(xié)議的,例如浮點(diǎn)數(shù)Floating-point IP核,以及以太網(wǎng)Tri Mode Ethernet MAC IP核。要想將Verilog層面的數(shù)據(jù)搬運(yùn)到C語(yǔ)言里面處理,就要使用DMA IP核。

本文以浮點(diǎn)數(shù)Floating-point IP核將定點(diǎn)數(shù)轉(zhuǎn)換為浮點(diǎn)數(shù)為例,詳細(xì)講解AXI DMA IP核的使用方法。

浮點(diǎn)數(shù)IP核的輸入輸出數(shù)據(jù)都是32位,協(xié)議均為AXI4-Stream。C語(yǔ)言程序首先將要轉(zhuǎn)換的定點(diǎn)數(shù)數(shù)據(jù)通過(guò)DMA發(fā)送給浮點(diǎn)數(shù)IP核,浮點(diǎn)數(shù)IP核轉(zhuǎn)換完成后再通過(guò)DMA將單精度浮點(diǎn)數(shù)結(jié)果發(fā)回C語(yǔ)言程序,再通過(guò)printf打印出來(lái)。

定點(diǎn)數(shù)的數(shù)據(jù)類型為int,小數(shù)點(diǎn)定在第四位上,即:XXXXXXX.X。整數(shù)部分占28位,小數(shù)部分占4位。

轉(zhuǎn)換后浮點(diǎn)數(shù)的數(shù)據(jù)類型為float,可以用printf的%f直接打印出來(lái)。

工程下載地址:https://pan.baidu.com/s/1SXppHMdhroFT8vGCIysYTQ(提取碼:u7wf)

MicroBlaze C語(yǔ)言工程的建法不再贅述,請(qǐng)參閱:https://blog.csdn.net/ZLK1214/article/details/111824576

pYYBAGIMpo2AJqjNAAH_MWNrJUU622.png

首先添加Floating-point IP核,作為DMA的外設(shè)端:(主存端為BRAM)

poYBAGIMpo-ANZDbAAA_l0ntfqk097.png

poYBAGIMppCAJxSNAAEGvn8Va34201.png

pYYBAGIMppKAStvHAAEMJT25qmg379.png

poYBAGIMppSAJJnmAAD2VQEXRHw583.png

這里要注意一下,一定要勾選上TLAST,否則DMA接收端會(huì)出現(xiàn)DMA Internal Error的錯(cuò)誤:

pYYBAGIMppaAVBY2AAFE0VbVX3o575.png

下面是Xilinx DMA手冊(cè)里面對(duì)DMA Internal Error錯(cuò)誤的描述:

poYBAGIMppiAHRX6AACbAx3Wn-M539.png

添加AXI DMA IP核:

pYYBAGIMppqARPshAABNz_Q8C2c867.png

IP核添加好了,但還沒有連線:

pYYBAGIMppyAV16VAACq-RthNiM037.png

點(diǎn)擊Run Connection Automation,自動(dòng)連接DMA的S_AXI_LITE接口

pYYBAGIMpp6AMfbJAAE2FppS-0I773.png

poYBAGIMpqKAWFqEAAKoYpB4afY616.png

pYYBAGIMpqSALYymAAEFOXj7KkI879.png

pYYBAGIMpqaAPHUkAAFJHM4rMQI008.png

poYBAGIMpqmAUl7LAAEg29w2F28228.png

自動(dòng)連接浮點(diǎn)數(shù)IP核的時(shí)鐘引腳:

pYYBAGIMpquAEl5bAAFqfrxqB3Q110.png

poYBAGIMpq-ASKUlAAQhpFjGMvY547.png

poYBAGIMprGAOAtYAAFr6mSyUyY366.png

pYYBAGIMprOAElDjAAFLHFr0bfQ712.png

pYYBAGIMprWAKbr4AAKKtr6QNo8705.png

添加BRAM控制器

poYBAGIMpraAWb5LAAAQUOLl1YU793.png

pYYBAGIMpriAEAvhAAG3KfwYg_8873.png

最終的連線結(jié)果:

pYYBAGIMprqAfAw4AAK-1KrBJC4019.png

修改新建的BRAM的容量為64KB:

pYYBAGIMpryARkB4AAFxBvZe0Bg340.png

pYYBAGIMpr-AbUYfAAGA3kbuYQ8313.png

最終的地址分配方式:

poYBAGIMpsGAOpbRAAF_bEy5vaE460.png

保存Block Design,然后生成Bitstream:

pYYBAGIMpsOATBaGAAEszSUAiCM178.png

Bitstream生成后,導(dǎo)出xsa文件:

poYBAGIMpsSADsPbAAD1JA0uxRY519.png

Vitis Platform工程重新導(dǎo)入xsa文件:

poYBAGIMpsaARsBwAACII8fJ-zA463.png

poYBAGIMpsmAVEo0AAT3WAEPq1E727.png

修改C程序(helloworld.c)的代碼:

(這里面XPAR_BRAM_2_BASEADDR最好改成0xc0000000,因?yàn)樯傻膞parameters.h配置文件里面BRAM號(hào)可能有變化)
/******************************************************************************
*
* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/

/*
* helloworld.c: simple test application
*
* This application configures UART 16550 to baud rate 9600.
* PS7 UART (Zynq) is not initialized by this application, since
* bootrom/bsp configures it to baud rate 115200
*
* ------------------------------------------------
* | UART TYPE BAUD RATE |
* ------------------------------------------------
* uartns550 9600
* uartlite Configurable only in HW design
* ps7_uart 115200 (configured by bootrom/bsp)
*/

#include
#include
#include "platform.h"

// DMA無(wú)法通過(guò)AXI Interconnect訪問(wèn)Microblaze本身的BRAM內(nèi)存
// 只能訪問(wèn)掛接在AXI Interconnect上的內(nèi)存
#define _countof(arr) (sizeof(arr) / sizeof(*(arr)))
typedef struct
{
int numbers_in[40];
float numbers_out[40];
} BRAM2_Data;

static BRAM2_Data *bram2_data = (BRAM2_Data *)XPAR_BRAM_2_BASEADDR;
static XAxiDma xaxidma;

int main(void)
{
int i, ret = 0;
XAxiDma_Config *xaxidma_cfg;

init_platform();

printf("Hello World\n");
printf("Successfully ran Hello World application\n");

// 初始化DMA
xaxidma_cfg = XAxiDma_LookupConfig(XPAR_AXIDMA_0_DEVICE_ID);
XAxiDma_CfgInitialize(&xaxidma, xaxidma_cfg);
ret = XAxiDma_Selftest(&xaxidma);
if (ret != XST_SUCCESS)
{
printf("XAxiDma_Selftest() failed! ret=%d\n", ret);
goto err;
}

// 初始化DMA的輸入數(shù)據(jù)
printf("numbers_in=%p, numbers_out=%p\n", bram2_data->numbers_in, bram2_data->numbers_out);
for (i = 0; i numbers_in); i++)
{
bram2_data->numbers_in[i] = 314 * (i + 1);
if (i & 1)
bram2_data->numbers_in[i] = -bram2_data->numbers_in[i];
}

// DMA開始發(fā)送數(shù)據(jù) (Length參數(shù)的單位為字節(jié))
ret = XAxiDma_SimpleTransfer(&xaxidma, (uintptr_t)bram2_data->numbers_in, sizeof(bram2_data->numbers_in), XAXIDMA_DMA_TO_DEVICE);
if (ret != XST_SUCCESS)
{
printf("XAxiDma_SimpleTransfer(XAXIDMA_DMA_TO_DEVICE) failed! ret=%d\n", ret);
goto err;
}

// DMA開始接收數(shù)據(jù)
ret = XAxiDma_SimpleTransfer(&xaxidma, (uintptr_t)bram2_data->numbers_out, sizeof(bram2_data->numbers_out), XAXIDMA_DEVICE_TO_DMA);
if (ret != XST_SUCCESS)
{
printf("XAxiDma_SimpleTransfer(XAXIDMA_DEVICE_TO_DMA) failed! ret=%d\n", ret);
goto err;
}

// 等待DMA發(fā)送完畢
i = 0;
while (XAxiDma_Busy(&xaxidma, XAXIDMA_DMA_TO_DEVICE))
{
i++;
if (i == 200000)
{
// 必須確保DMA訪問(wèn)的內(nèi)存是直接掛接在AXI Interconnect上的
// 否則這里會(huì)報(bào)DMA Decode Error的錯(cuò)誤 (the address request points to an invalid address)
printf("DMA Tx timeout! DMASR=0x%08lx\n", XAxiDma_ReadReg(xaxidma.RegBase + XAXIDMA_TX_OFFSET, XAXIDMA_SR_OFFSET));
goto err;
}
}
printf("DMA Tx complete!\n");

// 等待DMA接收完畢
i = 0;
while (XAxiDma_Busy(&xaxidma, XAXIDMA_DEVICE_TO_DMA))
{
i++;
if (i == 200000)
{
// floating-point IP核的配置里面一定要把A通道的tlast復(fù)選框勾選上, 使輸入端和輸出端都有tlast信號(hào)
// 否則s_axis_s2mm_tlast一直為0, DMA以為數(shù)據(jù)還沒接收完, 就會(huì)報(bào)DMA Internal Error的錯(cuò)誤
// (the incoming packet is bigger than what is specified in the DMA length register)
printf("DMA Rx timeout! DMASR=0x%08lx\n", XAxiDma_ReadReg(xaxidma.RegBase + XAXIDMA_RX_OFFSET, XAXIDMA_SR_OFFSET));
goto err;
}
}
printf("DMA Rx complete!\n");

err:
for (i = 0; i numbers_out); i++)
printf("numbers_out[%d]=%f\n", i, bram2_data->numbers_out[i]);

cleanup_platform();
return 0;
}

C程序的運(yùn)行結(jié)果:

pYYBAGIMpsuAAHqIAAOtyw3zrA4278.png

Hello World
Successfully ran Hello World application
numbers_in=0xc0000000, numbers_out=0xc00000a0
DMA Tx complete!
DMA Rx complete!
numbers_out[0]=19.625000
numbers_out[1]=-39.250000
numbers_out[2]=58.875000
numbers_out[3]=-78.500000
numbers_out[4]=98.125000
numbers_out[5]=-117.750000
numbers_out[6]=137.375000
numbers_out[7]=-157.000000
numbers_out[8]=176.625000
numbers_out[9]=-196.250000
numbers_out[10]=215.875000
numbers_out[11]=-235.500000
numbers_out[12]=255.125000
numbers_out[13]=-274.750000
numbers_out[14]=294.375000
numbers_out[15]=-314.000000
numbers_out[16]=333.625000
numbers_out[17]=-353.250000
numbers_out[18]=372.875000
numbers_out[19]=-392.500000
numbers_out[20]=412.125000
numbers_out[21]=-431.750000
numbers_out[22]=451.375000
numbers_out[23]=-471.000000
numbers_out[24]=490.625000
numbers_out[25]=-510.250000
numbers_out[26]=529.875000
numbers_out[27]=-549.500000
numbers_out[28]=569.125000
numbers_out[29]=-588.750000
numbers_out[30]=608.375000
numbers_out[31]=-628.000000
numbers_out[32]=647.625000
numbers_out[33]=-667.250000
numbers_out[34]=686.875000
numbers_out[35]=-706.500000
numbers_out[36]=726.125000
numbers_out[37]=-745.750000
numbers_out[38]=765.375000
numbers_out[39]=-785.000000

poYBAGIMps6AYy8nAAS7yU8SJ_8640.png

接下來(lái)講一下我們剛才禁用掉的Scatter Gather接口的用法。取消禁用后,之前的C代碼就不能運(yùn)行了。
之前沒有啟用Scatter Gather的時(shí)候,我們一次只能提交一個(gè)DMA請(qǐng)求,等這個(gè)DMA請(qǐng)求的數(shù)據(jù)傳輸完畢后,我們才能提交下一個(gè)DMA傳輸請(qǐng)求。
有了Scatter Gather接口,我們就可以一次性提交很多很多DMA請(qǐng)求,然后CPU去干其他的事情。這可以大大提高傳輸效率。
除此以外,Scatter Gather還可以將多個(gè)位于不同內(nèi)存地址的緩沖區(qū)合并成一個(gè)AXI4-Stream數(shù)據(jù)包傳輸。

下面的示例演示了如何利用Scatter Gather功能批量收發(fā)3組數(shù)據(jù)包。
啟用了Scatter Gather后,DMA里面多出了一個(gè)M_AXI_SG接口,點(diǎn)擊Run Connection Automation,連接到AXI Interconnect上:

pYYBAGIMptCAMQ6zAAKe7D5xcpo553.png

pYYBAGIMptKAF2XMAAZpvcPD86o959.png

Vivado工程Generate Bitstream,然后導(dǎo)出xsa文件。回到Vitis后,必須把Platform工程刪了重建,不然XPAR_AXI_DMA_0_INCLUDE_SG的值得不到更新。

poYBAGIMptSAe0AnAADlJnJWhCw515.png

pYYBAGIMptaAS3wVAAbTkOJjG3o749.png

pYYBAGIMptiAXaiaAAg2skXUvyM504.png

原有的C程序不再可用,修改一下程序代碼
/******************************************************************************
*
* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/

/*
* helloworld.c: simple test application
*
* This application configures UART 16550 to baud rate 9600.
* PS7 UART (Zynq) is not initialized by this application, since
* bootrom/bsp configures it to baud rate 115200
*
* ------------------------------------------------
* | UART TYPE BAUD RATE |
* ------------------------------------------------
* uartns550 9600
* uartlite Configurable only in HW design
* ps7_uart 115200 (configured by bootrom/bsp)
*/

#include
#include
#include "platform.h"

/* Xilinx的官方例程:C:\Xilinx\Vitis\2020.1\data\embeddedsw\XilinxProcessorIPLib\drivers\axidma_v9_11\examples\xaxidma_example_sg_poll.c */

// DMA無(wú)法通過(guò)AXI Interconnect訪問(wèn)Microblaze本身的BRAM內(nèi)存
// 只能訪問(wèn)掛接在AXI Interconnect上的內(nèi)存
#define _countof(arr) (sizeof(arr) / sizeof(*(arr)))
typedef struct
{
int numbers_in[40];
float numbers_out[40];
} BRAM2_Data;

typedef struct
{
uint8_t txbuf[640];
uint8_t rxbuf[640];
} BRAM2_BdRingBuffer;

static BRAM2_Data *bram2_data = (BRAM2_Data *)0xc0000000;
static BRAM2_BdRingBuffer *bram2_bdringbuf = (BRAM2_BdRingBuffer *)0xc0008000;
static XAxiDma xaxidma;

int main(void)
{
int i, n, ret = 0;
XAxiDma_Bd *bd, *p;
XAxiDma_BdRing *txring, *rxring;
XAxiDma_Config *cfg;

init_platform();

printf("Hello World\n");
printf("Successfully ran Hello World application\n");

// 初始化DMA
cfg = XAxiDma_LookupConfig(XPAR_AXIDMA_0_DEVICE_ID);
XAxiDma_CfgInitialize(&xaxidma, cfg);
ret = XAxiDma_Selftest(&xaxidma);
if (ret != XST_SUCCESS)
{
printf("XAxiDma_Selftest() failed! ret=%d\n", ret);
goto err;
}

if (!XAxiDma_HasSg(&xaxidma))
{
printf("XPAR_AXI_DMA_0_INCLUDE_SG=%d\n", XPAR_AXI_DMA_0_INCLUDE_SG);
printf("Please recreate and build Vitis platform project!\n");
goto err;
}

// 初始化DMA的輸入數(shù)據(jù)
printf("[0] numbers_in=%p, numbers_out=%p\n", bram2_data[0].numbers_in, bram2_data[0].numbers_out);
printf("[1] numbers_in=%p, numbers_out=%p\n", bram2_data[1].numbers_in, bram2_data[1].numbers_out);
printf("[2] numbers_in=%p, numbers_out=%p\n", bram2_data[2].numbers_in, bram2_data[2].numbers_out);
for (i = 0; i {
bram2_data[0].numbers_in[i] = 314 * (i + 1);
bram2_data[1].numbers_in[i] = -141 * (i + 1);
bram2_data[2].numbers_in[i] = -2718 * (i + 1);
if (i & 1)
{
bram2_data[0].numbers_in[i] = -bram2_data[0].numbers_in[i];
bram2_data[1].numbers_in[i] = -bram2_data[1].numbers_in[i];
bram2_data[2].numbers_in[i] = -bram2_data[2].numbers_in[i];
}
}

// 配置DMA發(fā)送描述符
txring = XAxiDma_GetTxRing(&xaxidma);
n = XAxiDma_BdRingCntCalc(XAXIDMA_BD_MINIMUM_ALIGNMENT, sizeof(bram2_bdringbuf->txbuf));
ret = XAxiDma_BdRingCreate(txring, (uintptr_t)bram2_bdringbuf->txbuf, (uintptr_t)bram2_bdringbuf->txbuf, XAXIDMA_BD_MINIMUM_ALIGNMENT, n);
if (ret != XST_SUCCESS)
{
printf("XAxiDma_BdRingCreate(txring) failed! ret=%d\n", ret);
goto err;
}
printf("BdRing Tx count: %d\n", n);

ret = XAxiDma_BdRingAlloc(txring, 3, &bd);
if (ret != XST_SUCCESS)
{
printf("XAxiDma_BdRingAlloc(txring) failed! ret=%d\n", ret);
goto err;
}

p = bd;
for (i = 0; i {
XAxiDma_BdSetBufAddr(p, (uintptr_t)bram2_data[i].numbers_in);
XAxiDma_BdSetLength(p, sizeof(bram2_data[i].numbers_in), txring->MaxTransferLen);
XAxiDma_BdSetCtrl(p, XAXIDMA_BD_CTRL_TXSOF_MASK | XAXIDMA_BD_CTRL_TXEOF_MASK);
XAxiDma_BdSetId(p, i);
p = (XAxiDma_Bd *)XAxiDma_BdRingNext(txring, p);
}

ret = XAxiDma_BdRingToHw(txring, 3, bd);
if (ret != XST_SUCCESS)
{
printf("XAxiDma_BdRingToHw(txring) failed! ret=%d\n", ret);
goto err;
}

// 配置DMA接收描述符
rxring = XAxiDma_GetRxRing(&xaxidma);
n = XAxiDma_BdRingCntCalc(XAXIDMA_BD_MINIMUM_ALIGNMENT, sizeof(bram2_bdringbuf->rxbuf));
ret = XAxiDma_BdRingCreate(rxring, (uintptr_t)bram2_bdringbuf->rxbuf, (uintptr_t)bram2_bdringbuf->rxbuf, XAXIDMA_BD_MINIMUM_ALIGNMENT, n);
if (ret != XST_SUCCESS)
{
printf("XAxiDma_BdRingCreate(rxring) failed! ret=%d\n", ret);
goto err;
}
printf("BdRing Rx count: %d\n", n);

ret = XAxiDma_BdRingAlloc(rxring, 3, &bd);
if (ret != XST_SUCCESS)
{
printf("XAxiDma_BdRingAlloc(rxring) failed! ret=%d\n", ret);
goto err;
}

p = bd;
for (i = 0; i {
XAxiDma_BdSetBufAddr(p, (uintptr_t)bram2_data[i].numbers_out);
XAxiDma_BdSetLength(p, sizeof(bram2_data[i].numbers_out), rxring->MaxTransferLen);
XAxiDma_BdSetCtrl(p, 0);
XAxiDma_BdSetId(p, i);
p = (XAxiDma_Bd *)XAxiDma_BdRingNext(rxring, p);
}

ret = XAxiDma_BdRingToHw(rxring, 3, bd);
if (ret != XST_SUCCESS)
{
printf("XAxiDma_BdRingToHw(rxring) failed! ret=%d\n", ret);
goto err;
}

// 開始發(fā)送數(shù)據(jù)
ret = XAxiDma_BdRingStart(txring);
if (ret != XST_SUCCESS)
{
printf("XAxiDma_BdRingStart(txring) failed! ret=%d\n", ret);
goto err;
}

// 開始接收數(shù)據(jù)
ret = XAxiDma_BdRingStart(rxring);
if (ret != XST_SUCCESS)
{
printf("XAxiDma_BdRingStart(rxring) failed! ret=%d\n", ret);
goto err;
}

// 等待收發(fā)結(jié)束
n = 0;
while (n {
// 檢查發(fā)送是否結(jié)束
ret = XAxiDma_BdRingFromHw(txring, XAXIDMA_ALL_BDS, &bd);
if (ret != 0)
{
n += ret;
p = bd;
for (i = 0; i {
printf("DMA Tx%lu Complete!\n", XAxiDma_BdGetId(p));
p = (XAxiDma_Bd *)XAxiDma_BdRingNext(txring, p);
}

ret = XAxiDma_BdRingFree(txring, ret, bd);
if (ret != XST_SUCCESS)
printf("XAxiDma_BdRingFree(txring) failed! ret=%d\n", ret);
}

// 檢查接收是否結(jié)束
ret = XAxiDma_BdRingFromHw(rxring, XAXIDMA_ALL_BDS, &bd);
if (ret != 0)
{
n += ret;
p = bd;
for (i = 0; i {
printf("DMA Rx%lu Complete!\n", XAxiDma_BdGetId(p));
p = (XAxiDma_Bd *)XAxiDma_BdRingNext(rxring, p);
}

ret = XAxiDma_BdRingFree(rxring, ret, bd);
if (ret != XST_SUCCESS)
printf("XAxiDma_BdRingFree(rxring) failed! ret=%d\n", ret);
}
}

err:
for (i = 0; i printf("numbers_out[%d]=%f,%f,%f\n", i, bram2_data[0].numbers_out[i], bram2_data[1].numbers_out[i], bram2_data[2].numbers_out[i]);

cleanup_platform();
return 0;
}

程序運(yùn)行結(jié)果:

Hello World
Successfully ran Hello World application
[0] numbers_in=0xc0000000, numbers_out=0xc00000a0
[1] numbers_in=0xc0000140, numbers_out=0xc00001e0
[2] numbers_in=0xc0000280, numbers_out=0xc0000320
BdRing Tx count: 10
BdRing Rx count: 10
DMA Tx0 Complete!
DMA Tx1 Complete!
DMA Tx2 Complete!
DMA Rx0 Complete!
DMA Rx1 Complete!
DMA Rx2 Complete!
numbers_out[0]=19.625000,-8.812500,-169.875000
numbers_out[1]=-39.250000,17.625000,339.750000
numbers_out[2]=58.875000,-26.437500,-509.625000
numbers_out[3]=-78.500000,35.250000,679.500000
numbers_out[4]=98.125000,-44.062500,-849.375000
numbers_out[5]=-117.750000,52.875000,1019.250000
numbers_out[6]=137.375000,-61.687500,-1189.125000
numbers_out[7]=-157.000000,70.500000,1359.000000
numbers_out[8]=176.625000,-79.312500,-1528.875000
numbers_out[9]=-196.250000,88.125000,1698.750000
numbers_out[10]=215.875000,-96.937500,-1868.625000
numbers_out[11]=-235.500000,105.750000,2038.500000
numbers_out[12]=255.125000,-114.562500,-2208.375000
numbers_out[13]=-274.750000,123.375000,2378.250000
numbers_out[14]=294.375000,-132.187500,-2548.125000
numbers_out[15]=-314.000000,141.000000,2718.000000
numbers_out[16]=333.625000,-149.812500,-2887.875000
numbers_out[17]=-353.250000,158.625000,3057.750000
numbers_out[18]=372.875000,-167.437500,-3227.625000
numbers_out[19]=-392.500000,176.250000,3397.500000
numbers_out[20]=412.125000,-185.062500,-3567.375000
numbers_out[21]=-431.750000,193.875000,3737.250000
numbers_out[22]=451.375000,-202.687500,-3907.125000
numbers_out[23]=-471.000000,211.500000,4077.000000
numbers_out[24]=490.625000,-220.312500,-4246.875000
numbers_out[25]=-510.250000,229.125000,4416.750000
numbers_out[26]=529.875000,-237.937500,-4586.625000
numbers_out[27]=-549.500000,246.750000,4756.500000
numbers_out[28]=569.125000,-255.562500,-4926.375000
numbers_out[29]=-588.750000,264.375000,5096.250000
numbers_out[30]=608.375000,-273.187500,-5266.125000
numbers_out[31]=-628.000000,282.000000,5436.000000
numbers_out[32]=647.625000,-290.812500,-5605.875000
numbers_out[33]=-667.250000,299.625000,5775.750000
numbers_out[34]=686.875000,-308.437500,-5945.625000
numbers_out[35]=-706.500000,317.250000,6115.500000
numbers_out[36]=726.125000,-326.062500,-6285.375000
numbers_out[37]=-745.750000,334.875000,6455.250000
numbers_out[38]=765.375000,-343.687500,-6625.125000
numbers_out[39]=-785.000000,352.500000,6795.000000

審核編輯:符乾江

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • FPGA
    +關(guān)注

    關(guān)注

    1645

    文章

    22050

    瀏覽量

    618532
  • Xilinx
    +關(guān)注

    關(guān)注

    73

    文章

    2185

    瀏覽量

    125363
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    RDMA over RoCE V2設(shè)計(jì)2:ip 整體框架設(shè)計(jì)考慮

    設(shè)計(jì)IP需要考慮如下因素: 1)基于 IBTA 1.5 協(xié)議規(guī)范,支持 RoCE v2 標(biāo)準(zhǔn)協(xié)議傳輸,同時(shí)支持 ARP協(xié)議和 ICMP 協(xié)議。 2)基于 Xilinx CMAC 集成塊進(jìn)行開發(fā)并獨(dú)立
    發(fā)表于 07-16 08:51

    NVMe IP高速傳輸卻不依賴便利的XDMA設(shè)計(jì)之三:系統(tǒng)架構(gòu)

    應(yīng)用環(huán)境中, 并提供簡(jiǎn)易的操作方式實(shí)現(xiàn)數(shù)據(jù)的傳輸與存儲(chǔ)。 因此, 設(shè)計(jì)需要采用標(biāo)準(zhǔn)化接口, 實(shí)現(xiàn)盡可能低的資源占用率, 并具備 DMA 數(shù)據(jù)傳輸功能。 基于以上需求, 本IP擬基于 FPGA
    發(fā)表于 06-29 17:42

    NVMe IPAXI4總線分析

    廣泛應(yīng)用 。隨著時(shí)間的推移,AXI4的影響不斷擴(kuò)大。目前,由Xilinx提供的大部分IP接口都支持AXI4總線,使得系統(tǒng)中不同模塊之間的互連更加高效。這也讓基于這些
    發(fā)表于 06-02 23:05

    Xilinx Shift RAM IP概述和主要功能

    Xilinx Shift RAM IP 是 AMD Xilinx 提供的一個(gè) LogiCORE IP ,用于在
    的頭像 發(fā)表于 05-14 09:36 ?347次閱讀

    一文詳解AXI DMA技術(shù)

    AXI直接數(shù)值存取(Drect Memory Access,DMAIPAXI4內(nèi)存映射和AXI
    的頭像 發(fā)表于 04-03 09:32 ?1005次閱讀
    一文詳解<b class='flag-5'>AXI</b> <b class='flag-5'>DMA</b>技術(shù)

    一文詳解Video In to AXI4-Stream IP

    Video In to AXI4-Stream IP用于將視頻源(帶有同步信號(hào)的時(shí)鐘并行視頻數(shù)據(jù),即同步sync或消隱blank信號(hào)或者而后者皆有)轉(zhuǎn)換成AXI4-Stream接口形
    的頭像 發(fā)表于 04-03 09:28 ?1313次閱讀
    一文詳解Video In to <b class='flag-5'>AXI</b>4-Stream <b class='flag-5'>IP</b><b class='flag-5'>核</b>

    AXI 接口設(shè)計(jì)避坑指南:AXI接口筆記

    ? AXI接口筆記 第一章?問(wèn)題記錄 第1節(jié)?接收數(shù)據(jù)全0或全1 1.1?問(wèn)題現(xiàn)象 上圖中,pixel_data_o是EC IP輸出的圖像數(shù)據(jù),正確的話會(huì)如上圖所示,圖像數(shù)據(jù)每個(gè)時(shí)鐘會(huì)變化并且值
    的頭像 發(fā)表于 03-10 17:21 ?471次閱讀
    <b class='flag-5'>AXI</b> 接口設(shè)計(jì)避坑指南:<b class='flag-5'>AXI</b>接口筆記

    使用IP和開源庫(kù)減少FPGA設(shè)計(jì)周期

    FPGA 開發(fā)的目標(biāo)是按時(shí)、按質(zhì)交付項(xiàng)目。 然而,這一目標(biāo)說(shuō)起來(lái)簡(jiǎn)單,實(shí)現(xiàn)起來(lái)老費(fèi)勁了。根據(jù)業(yè)內(nèi)最廣泛的調(diào)查之一,西門子威爾遜集團(tuán) 2022 年的調(diào)查(https
    的頭像 發(fā)表于 01-15 10:47 ?700次閱讀
    使用<b class='flag-5'>IP</b><b class='flag-5'>核</b>和開源庫(kù)減少<b class='flag-5'>FPGA</b>設(shè)計(jì)周期

    ZYNQ基礎(chǔ)---AXI DMA使用

    Xilinx官方也提供有一些DMAIP,通過(guò)調(diào)用API函數(shù)能夠更加靈活地使用DMA。 1. AXI D
    的頭像 發(fā)表于 01-06 11:13 ?2337次閱讀
    ZYNQ基礎(chǔ)---<b class='flag-5'>AXI</b> <b class='flag-5'>DMA</b>使用

    FPGA里面例化了8個(gè)jesd204B的ip同步接收8塊AFE芯片的信號(hào),怎么連接設(shè)備時(shí)鐘和sysref到AFE和FPGA?

    各位有人用過(guò)AFE58JD48嗎,我在FPGA里面例化了8個(gè)jesd204B的ip同步接收8塊AFE芯片的信號(hào),怎么連接設(shè)備時(shí)鐘和sysref到AFE和
    發(fā)表于 11-18 07:51

    【米爾-Xilinx XC7A100T FPGA開發(fā)板試用】+02.PCIE接口測(cè)試(zmj)

    通信速率可高達(dá) 5G bit 帶寬。本例程中通過(guò)利用 XILINX 的 XDMA IP 來(lái)實(shí)現(xiàn) PCIE 的發(fā)送和接收速度測(cè)試。 1.1參考電路 米爾-Xilinx XC7A100T FPGA
    發(fā)表于 11-12 16:05

    芯驛電子 ALINX 推出全新 IP 產(chǎn)品線,覆蓋 TCP/UDP/NVMe AXI IP

    10GBe/40GBe UDP 協(xié)議棧 IP 、10GbE TCP/IP 協(xié)議棧 IP 和 NVMe
    的頭像 發(fā)表于 10-30 17:39 ?901次閱讀
     芯驛電子 ALINX 推出全新 <b class='flag-5'>IP</b> <b class='flag-5'>核</b>產(chǎn)品線,覆蓋 TCP/UDP/NVMe <b class='flag-5'>AXI</b> <b class='flag-5'>IP</b> <b class='flag-5'>核</b>

    芯驛電子ALINX推出全新IP產(chǎn)品線

    /40GBe UDP 協(xié)議棧 IP 、10GbE TCP/IP 協(xié)議棧 IP 和 NVMe AXI
    的頭像 發(fā)表于 10-30 11:53 ?695次閱讀
    芯驛電子ALINX推出全新<b class='flag-5'>IP</b><b class='flag-5'>核</b>產(chǎn)品線

    Xilinx DDS IP的使用和參數(shù)配置

    用RAM實(shí)現(xiàn)一個(gè)DDS,從原理上來(lái)說(shuō)很簡(jiǎn)單,在實(shí)際使用的時(shí)候,可能沒有直接使用官方提供的IP來(lái)的方便。這個(gè)博客就記錄一下,最近使用到的這個(gè)DDS IP
    的頭像 發(fā)表于 10-25 16:54 ?3947次閱讀
    <b class='flag-5'>Xilinx</b> DDS <b class='flag-5'>IP</b><b class='flag-5'>核</b>的使用和參數(shù)配置

    如何申請(qǐng)xilinx IP的license

    在使用FPGA的時(shí)候,有些IP是需要申請(qǐng)后才能使用的,本文介紹如何申請(qǐng)xilinx IP的l
    的頭像 發(fā)表于 10-25 16:48 ?1409次閱讀
    如何申請(qǐng)<b class='flag-5'>xilinx</b> <b class='flag-5'>IP</b><b class='flag-5'>核</b>的license