简体   繁体   English

从 PS 和 PL 访问 Zynq BRAM

[英]Access Zynq BRAM from PS and PL

I'm trying to write some Data to a Dual Port BRAM and read it from PL.我正在尝试将一些数据写入双端口 BRAM 并从 PL 中读取。 I created a customised BRAM from the IP Catalog and put it in a wrapper so i can use it in the Block diagram.我从 IP 目录中创建了一个定制的 BRAM,并将其放入包装器中,以便我可以在框图中使用它。 PORTA width is 32-bit and PORTB width is 256-bit. PORTA 宽度为 32 位,PORTB 宽度为 256 位。 I need to transfer 1024 8-bit values, so PORTA depth is 256 (8bit) and PORTB depth is 32 (5bit).我需要传输 1024 个 8 位值,因此 PORTA 深度为 256(8 位),而 PORTB 深度为 32(5 位)。 I use the standard BRAM-Controller in 32-bit mode (depth is 2048, but this shouldn't matter?).我在 32 位模式下使用标准 BRAM 控制器(深度为 2048,但这不重要吗?)。

Block Diagram框图

To write Data to the BRAM over the AXI-Interface i use the function Xil_Out32(BASE_ADDR+0, 0xFFFFFFFF) .要通过 AXI 接口将数据写入 BRAM,我使用 function Xil_Out32(BASE_ADDR+0, 0xFFFFFFFF) When i want to access the next 32-bit of data in the BRAM is use Xil_Out32(BASE_ADDR+4, 0xFFFFFFFF) .当我想访问 BRAM 中的下一个 32 位数据时,使用Xil_Out32(BASE_ADDR+4, 0xFFFFFFFF) +4 cause the memory is byte aligned, right? +4 导致 memory 是字节对齐的,对吧? (When i use +1 my program crashes). (当我使用 +1 时,我的程序崩溃了)。

To read Data from the BRAM over PL i simply put a Address on addrb[4:0] and get my data two clock cycles later out of doutb[255:0] .要通过 PL 从 BRAM 读取数据,我只需在addrb[4:0]上放置一个地址,然后在两个时钟周期后从doutb[255:0]获取我的数据。 Cause "addrb" is only 5 bit, this can't be byte aligned, so every time i add +1 to addrb i get the next 256-bit from BRAM, right?.因为“addrb”只有 5 位,这不能是字节对齐的,所以每次我向 addrb 添加 +1 时,我都会从 BRAM 获得下一个 256 位,对吧?

OK.好的。 Now to my problem: I execute the following on PS:现在我的问题:我在 PS 上执行以下操作:

Xil_Out32(BASE_ADDR+0, 0xFFFFFFFF);
Xil_Out32(BASE_ADDR+4, 0xAAAAAAAA);

and read address 0x00 on my 256-bit output from PL the output looks like this:并从 PL 读取我的 256 位 output 上的地址 0x00,output 如下所示:

0x000000000000000000000000AAAAAAAA000000000000000000000000FFFFFFFF

I also put this in a little Diagram, to make it more clear:我还把它放在一个小图中,以使其更清楚:

Problem Description问题描述

I hope someone can put me in the right direction...我希望有人能把我引向正确的方向......

Cause "addrb" is only 5 bit, this can't be byte aligned, so every time i add +1 to addrb i get the next 256-bit from bram, right?.因为“addrb”只有 5 位,这不能是字节对齐的,所以每次我向 addrb 添加 +1 时,我都会从 bram 获得下一个 256 位,对吧?

That conclusion is a bit too fast.这个结论有点太快了。 It greatly depends how all your address buses are connected.这在很大程度上取决于所有地址总线的连接方式。 Standard the AXI address bus always has the LS address bits even if they are never used.标准 AXI 地址总线始终具有 LS 地址位,即使它们从未使用过。

For example my a AXI DMA engine has a 128 wide data bus.例如,我的 AXI DMA 引擎有一个 128 宽的数据总线。 The address port still has:地址端口仍然有:

output logic  [31:0] m_axi_awaddr,

However the bottom 4 address bits [3:0] are always zero.然而,底部 4 个地址位 [3:0] 始终为零。 I MUST increment my address bus in steps of 16 (16 bytes is 128 bits) if I want to write consecutive locations in memory.如果我想在 memory 中写入连续位置,我必须以 16 步(16 字节为 128 位)递增地址总线。

But elsewhere I have an VGA adapter with 8bits wide 4K deep BRAM where I connect AXI[2] to BRAM A[0].但在其他地方,我有一个带有 8 位宽 4K 深 BRAM 的 VGA 适配器,我将 AXI[2] 连接到 BRAM A[0]。 Now I have to increment my address bus in steps of 4 if I want to write consecutive byte locations in BRAM memory.现在,如果我想在 BRAM memory 中写入连续的字节位置,我必须以 4 步递增地址总线。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM