Main Site Documentation

Possible to access LUTs from flash rather than have them consume RAM?


#1

HI,
I have a bunch of look up tables but there are large and I am already lows on RAM

I’ve tried this:

public static readonly float[] quantisationLUT = new float[]
{
1.0f, 1.0f…

but that chews up RAM.
Is there anyway to having them be accessed directly out of program flash memory rather than RAM?
Thanks


#2

I remember something but not sure. I think of you add a binary resource then you can read it right from flash. Not that is a bytes array. I am not sure about float.

Either way, your is something we can definitely look into in the future.


#3

Another thought! If the byte array works then you can use native code to cast float into that array.


#4

Try…

public const float[] quantisationLUT = new float[]
{
1.0f, 1.0f…


#5

Thanks Gus. I found some some docs on the old site about resources :slight_smile:
What do you mean by ‘can use native code to cast float into that array’? Specially Native Code in this context?


#6

Hey Mike, Sadly that wouldn’t compile. I gives:
A const field of a reference type other than string can only be initialized with null

doing some digging I found this explanation on stack overflow:

Actually you are trying to make the array - which is a reference type - const - this would not affect mutability of its values at all (you still can mutate any value within the array) - making the array readonly would make it compile, but not have the desired effect either. Constant expressions have to be fully evaluated at compile time, hence the new operator is not allowed.


#7

try

public const float[] quantisationLUT = {1.0, 2.0};


#8

Hi Mike, same error. you can’t have const arrays :frowning:


#9

:angry:

Sorry… my C# is a bit rusty…