cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Adventurer
Adventurer
903 Views
Registered: ‎05-31-2019

Reading data from a memory location in Vivado

Jump to solution

Hi all,

This is a general query regarding how read/write operations can be done in Verilog to a particular memory location. For example, I write some data to a memory address say 0x500 using memcopy in C. Now my hardware design wants to read data from this location. How can I write a Verilog snippet in Vivado to get the data from the specified location (which I can also hardcode in the hardware design)? In this case, we can assume that there is always some data written to that specific address and I just want the hardware to read the data so I can do some processing with it.

Bit of background: I am using a ZCU104 board and Vivado 2019.1 and Petalinux 2019.1 to run an application. The application I am running consists of hardware design and a software interface to communicate with that design. I am writing some value to a memory address as I mentioned using the software application. Now when the software interacts with the hardware design, I want that design to be able to do its functionalities along with reading the data from that specific address which is already known to us.

I tried looking this up but did not find any suitable answers which match my query. Any help and suggestions will be highly appreciated. Thank You!

0 Kudos
Reply
1 Solution

Accepted Solutions
Scholar
Scholar
609 Views
Registered: ‎05-21-2015

@ansarimo,

No, that's not it at all.  This user wants to write to memory with the PS, and read it from the PL.

@maju42,

You'll have a couple of problems.

  1. The PL can't read (or modify) what's in the cache
  2. The PS sees a different address space from the PL due to a (potentially active) MMU
  3. Virtual memory isn't locked.  The memory manager can move it around, or even off memory to disk, any time it wants.

Once you've kicked the data out of the cache, and placed it into a locked address where it won't move, then I have two resources you might find valuable to get you the next step of the way.  The first describes how to write to a physical memory location, and the second how to build a simple and basic AXI master, something you'll need to read from PS memory from the PL. 

Hope that gets you closer, but there's still a way to go to a full answer.

Dan

View solution in original post

3 Replies
Xilinx Employee
Xilinx Employee
615 Views
Registered: ‎12-04-2019

Hi @maju42 ,

Here's a sample code on how to read data from a .txt file and write it into memory.

module example; 
integer i;
 reg [7:0] mem [0 : 7];    //8 x 8 Memory declaration 
 
initial
 $readmemb(“file.txt”, mem); // readmemb for binary data and //readmemh for hex data

initial
 for (i=0; i<=7; i= i + 1) 
 $display(“Value at location %d is =%b”, i, mem[i]);
 endmodule 

Hope this helps.

 

Thanks and Regards,

Ansari Hunen

-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------

0 Kudos
Reply
Scholar
Scholar
610 Views
Registered: ‎05-21-2015

@ansarimo,

No, that's not it at all.  This user wants to write to memory with the PS, and read it from the PL.

@maju42,

You'll have a couple of problems.

  1. The PL can't read (or modify) what's in the cache
  2. The PS sees a different address space from the PL due to a (potentially active) MMU
  3. Virtual memory isn't locked.  The memory manager can move it around, or even off memory to disk, any time it wants.

Once you've kicked the data out of the cache, and placed it into a locked address where it won't move, then I have two resources you might find valuable to get you the next step of the way.  The first describes how to write to a physical memory location, and the second how to build a simple and basic AXI master, something you'll need to read from PS memory from the PL. 

Hope that gets you closer, but there's still a way to go to a full answer.

Dan

View solution in original post

Adventurer
Adventurer
565 Views
Registered: ‎05-31-2019

@dgisselq That is right. I had followed the same link you provided to create a simple AXI master to read a value from memory.

0 Kudos
Reply