Main Site Documentation

Filling and accessing continuous memory


#1

Hello all,

My G30 application works fine using large collections of arrays and structs but I want to go smaller and faster.

I do not need the extra memory used to reference my arrays because my program essentially just computes what the next element to run through a short process should be. So instead I would have small arrays holding a few key memory addresses needed to compute which of many many memory addresses I need. No need to store every address used because the data is continuous in nature with a few options to branch around.

So the question: Is it possible for me to accesses memory directly in a word aligned manner on the G30?

Thank you Kindly


#2

Yes using register class but I do not think this is going to help you.


#3

@ Gus - Thanks Gus. Do you think you could elaborate on why this wouldn’t help me?

Perhaps it would help if I make this analogy:

Let’s say my application is a video player for a choose your own adventure video series. So all the video frames are stored in continues memory cells ( because my frames are 32 bits). Typically the player just plays a frame then increments the address by 4. Occasionally an address is identified as a stopping point and based on user interaction a different memory address can be chosen instead of the next one. This way I’m only storing references to the beginning and end addresses of let’s call them video clips.

Using register class to make this happen would not reduce my ram usage as compared to using an Array which holds references to every entry?


#4

Register class does a lot of operations to get you to the memory. It will be slow. I am not sure there is a way today to cover what you need. Maybe TinyCLR will cover that?


#5

@ Gus - Okay thank you for that. To go back to my analogy the frame rate is not super fast or consistent. Ten or so milliseconds period at the fastest, usually about 50, but the other threads need their time too. I’ll have to experiment with the register class and see if any hit to latency outweighs the gain in free RAM. Appreciate the suggestion.


#6

@ jwizard93 - while you can access memory via the register class, you will not be able to do anything with it. NETMFis also allocating memory, and their is no way to coordinate memory usage.


#7

If someone posed your question to me as a spec request based on fast sequential access to blocks of memory (and what sounds like fixed-address read-only or read-mostly constructs), then I would suggest creating RLP code to manage and access those blocks. And, if the contents of the blocks are known at compile-time, then I might recommend that you write them to a flash sector. If your timescale is tens of mS, you could probably even afford the mem-to-mem copy required to surface the blocks as .net arrays.

Unfortunately, you mentioned G30 which does not support RLP, so you either need a different CPU, some future feature of TinyCLR, or custom firmware to pull off any of these optimizations…