Memory Models
Dr_Acula
Posts: 5,484
I've been doing some experimenting with memory models as described here http://propgcc.googlecode.com/hg/doc/Memory.html and wondering if there is a model where one can tell the program whether an array is to be stored in hub or in external ram.
Take this simple spin program
run it through spin2cpp and it produces this code
The external memory is a SPI sram chip and the memory model is XMMC
My understanding is that the data in the array in the code will be stored in hub if XMMC is used.
I was wondering about a memory model where it is possible to have one array that is stored in hub and another array that ends up being stored in external ram?
I'm not sure what such a model would be called. It is closer to XMM but on the setup I have, XMM is not an option, only XMM-Single or XMM-Split (neither of these two work, though they do compile and download). LMM works.
Playing to the strengths of the propeller, I'd like to devote most of the hub to a screen buffer. I think the stack and the caches need to be in hub too, so maybe that takes 10k in total and so 22k is free for a screen buffer?
So some code needs to explicitly state 'this array is reserved for the screen and it needs to be in hub', and another array needs to state 'this array needs to be in external ram'. Of course, that external ram array will be slower, but if it ends up being part of the cache it won't matter so much.
Is there a memory model that could do this?
Take this simple spin program
CON _clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz _xinfreq = 5_000_000 VAR byte myarray[10] OBJ text: "tv_text" PUB main text.start(16) text.clearscreen text.str(string("Test memory")) text.out(10) text.out(13) myarray[5] := 20 text.dec(myarray[5]) repeat
run it through spin2cpp and it produces this code
// // automatically generated by spin2cpp v1.02 on Sun Apr 14 22:57:03 2013 // spin2cpp --main Test.spin // #include <propeller.h> #include "Test.h" #ifdef __GNUC__ #define INLINE__ static inline #define Yield__() __asm__ volatile( "" ::: "memory" ) #define PostEffect__(X, Y) __extension__({ int32_t tmp__ = (X); (X) = (Y); tmp__; }) #else #define INLINE__ static static int32_t tmp__; #define PostEffect__(X, Y) (tmp__ = (X), (X) = (Y), tmp__) #define Yield__() #endif int32_t TestSpin::Main(void) { Text.Start(16); Text.Clearscreen(); Text.Str((int32_t)"Test memory"); Text.Out(10); Text.Out(13); Myarray[5] = 20; Text.Dec(Myarray[5]); while (1) { Yield__(); } return 0; } TestSpin MainObj__; int main() { return MainObj__.Main(); }
The external memory is a SPI sram chip and the memory model is XMMC
My understanding is that the data in the array in the code will be stored in hub if XMMC is used.
I was wondering about a memory model where it is possible to have one array that is stored in hub and another array that ends up being stored in external ram?
I'm not sure what such a model would be called. It is closer to XMM but on the setup I have, XMM is not an option, only XMM-Single or XMM-Split (neither of these two work, though they do compile and download). LMM works.
Playing to the strengths of the propeller, I'd like to devote most of the hub to a screen buffer. I think the stack and the caches need to be in hub too, so maybe that takes 10k in total and so 22k is free for a screen buffer?
So some code needs to explicitly state 'this array is reserved for the screen and it needs to be in hub', and another array needs to state 'this array needs to be in external ram'. Of course, that external ram array will be slower, but if it ends up being part of the cache it won't matter so much.
Is there a memory model that could do this?
Comments
Eric
Hmm - one thought. I'm using XMMC. Is that the same as XMM?
XMMC is XMM for just code. All the data is in hub. It's still OK to add HUBDATA to the variable declarations, but it's redundant since in XMMC all data gets put into hub by default.
If you want some variables to be in external memory, you'll have to use XMM, not XMMC. On some boards there are variants XMM-SINGLE (all the code and data go into an external RAM) and XMM-SPLIT (code goes into external flash/EEPROM, data goes into external RAM); both of these are OK too. The basic idea of XMM is that both code and data are external by default. You can put code into hub with HUBTEXT and data into hub with HUBDATA.
Eric