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 read from 32 bit wide BRAM

Accepted Solution Solved
Highlighted
Visitor
Posts: 8
Registered: ‎04-21-2017
Accepted Solution

How to read from 32 bit wide BRAM

Hello,

 

I just recently moved to the Vivado and Zynq architecture and I'm trying to learn the ropes.

In my project, I'm trying to use BRAM to exchange data from PL to PS. BRAM is configured as Simple Dual Port, width is 32, length 8192 records. Writing (port A) is done RTL code and is worinkg fine, reading (port B) is managed by AXI BRAM Controller. For testing pusrposes, I'm currently writing address value as data. So at address 0 there is 0x00000000, 0x00000001 at adress 1 and so on.

In embedded ARM, I'm trying to access contents of BRAM directly, with a pointer, like this:

 

u32 * addrPtr = 0x40000000; // BRAM base address
u32 loopcnt; // loop counter
...
for (loopcnt = 0; loopcnt< 10; loopcnt +=1){
xil_printf("iter %d, data %x, addr %x\r\n",loopcnt,*addrPtr,addrPtr);
addrPtr += 1;
}

And getting this output:

 

iter 0, data 0, addr 40000000
iter 1, data 4, addr 40000004
iter 2, data 8, addr 40000008
iter 3, data C, addr 4000000C
iter 4, data 10, addr 40000010
iter 5, data 14, addr 40000014
iter 6, data 18, addr 40000018
iter 7, data 1C, addr 4000001C
iter 8, data 20, addr 40000020
iter 9, data 24, addr 40000024

 

I can see that write works fine, and read works too, but only with increments of 4 (beacuse in ARM, space is adressed byte-wise and in my BRAM, there are 4 bytes for each adress). But I would like to be able to read each item from BRAM (not just inrements of 4). As I'm new to Zynq architecture, I'm wondering what is the best method to solve this - by use DMA or am I restricted to use 8 bits wide BRAM for this purpose? Maybe there is other solution that I'm not aware of.

 

Thank you for advice,

Jan


Accepted Solutions
Teacher
Posts: 5,146
Registered: ‎03-31-2012

Re: How to read from 32 bit wide BRAM

@galia this should be very easy to debug. Just put an ILA at the A port of the BRAM and see what address you're applying to it and what data you are writing. I am sure the problem will be obvious.

 

One question is how you are connecting the address bits of the read port. In your design as described, you should connect axi address bits 2:15 to the BRAM. Is this what you are doing? 

- 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.

View solution in original post


All Replies
Scholar
Posts: 2,189
Registered: ‎04-26-2015

Re: How to read from 32 bit wide BRAM

@galia I can't see any problems with what you're doing here. Could you post the RTL code that's filling the RAM?

 

Visitor
Posts: 8
Registered: ‎04-21-2017

Re: How to read from 32 bit wide BRAM

Thank you for your swift response.

I've attached RTL code. It's input is 320x240 pixel video frame (VGA-like signal - 3x 8bits color vectors, HSync, VSync and pixel valid_in (synchronization)). The code samples valid_in and on rising edge treshold input pixel with given threshold. After capturing 32 bits, BRAM is written and after whole frame is received, IRQ signal is set to notify ARM. Currently, for testing, BRAM data is not sampled value, but adress counter. The BRAM is actually used to hold two received frames (MSB bit in address is used to distinguish one from another).

Also, in this project I was trying to migrate from two-process FSM coding to one-process, so I hope the code is understandable.

 

Jan

Visitor
Posts: 8
Registered: ‎04-21-2017

Re: How to read from 32 bit wide BRAM

I don't think that the problem is in writing to the BRAM. I've already tried to initialize BRAM with .coe file and read it. Result was the same as before - I was able to read only every 4th item from the BRAM, so I think the issue should be probably somewhere in configuration or reading of the BRAM. 

Teacher
Posts: 5,146
Registered: ‎03-31-2012

Re: How to read from 32 bit wide BRAM

@galia this should be very easy to debug. Just put an ILA at the A port of the BRAM and see what address you're applying to it and what data you are writing. I am sure the problem will be obvious.

 

One question is how you are connecting the address bits of the read port. In your design as described, you should connect axi address bits 2:15 to the BRAM. Is this what you are doing? 

- 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.
Visitor
Posts: 8
Registered: ‎04-21-2017

Re: How to read from 32 bit wide BRAM

Hi muzaffer,

thank you very much for your input, I was able to fix the problem. Because I wanted AXI BRAM Controller to access all 8192 32bit items in BRAM, I have set address range for that memory to 32k. This meant that address vector from AXI BRAM Controller was 15 bit wide, not 13 that I need for memory. So I simply manually "wired" the highest 13 bits into BRAM and left out two lowest bits, just as you suggested.

 

Jan