From Thursday, May 23rd (05:00 PM CDT) through Friday, April 24th (1:30 AM CDT), 2024, will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.


Showing results for 
Search instead for 
Did you mean: 

How do I programatically determine the total number of elements in an FPGA memory?

Go to solution

Hi, I need to run through all the elements in an FPGA memory.  The size is set in project explorer where the memory was defined.  Is there any way to get access to this size either during compile time or runtime?  I don't want to define it as a constant on my diagram as it may change in future.

0 Kudos
Message 1 of 5

Hi AnthonV,


You can access the memory at any time during runtime, either for modifying the values or accessing the data. 


Check this link


There are more ways to store data in an FPGA so take a look here




0 Kudos
Message 2 of 5

Hi Pedro, I am asking if there is a way to know how many elements a FPGA memory item contains. Sure i can set the memory to a size (say 4096) and then in my fpga vi use a constant with the same value 4096 to loop through all the elements. But is there a way that i dont gave to use this constant, in other words can I use for instance a property node on the memory reference to get its length? (by the way no you cannot use a property node)

0 Kudos
Message 3 of 5
Accepted by AnthonV



I am afraid there isn't a straightforward procedure to get the block size. I know if you set a memory block of 1024 elements and you try to write in the 1025th, you won't get an error but you can read that value and see if the data you try to write was written.


So, it's simply a while loop writing a random number to a memory address and just after that read the value and compare. When you hit the MAX + 1 address in memory, you'll see the value is 0 so MAX is the size of the block.




0 Kudos
Message 4 of 5

This wasn't the solution I was hoping for but I will implement it nonetheless seeing as there is no other way.  

Thank you!

0 Kudos
Message 5 of 5