Mixed memory models?
Erik Friesen
Posts: 1,071
Perhaps this is obvious, I haven't dug real deep. I haven't followed the C thing very close, but I was poking around and took a look at the propgcc site, and saw the three memory models listed. I think the possibility of cog + lmm would be quite handy. Inter cog communication could be interesting I suppose, but should work, especially with structs now available.
Perhaps something like, #pragma config COGMODEL, or #define COGMODEL ??? or LMMMODEL??
Perhaps something like, #pragma config COGMODEL, or #define COGMODEL ??? or LMMMODEL??
Comments
Hi Erik.
Builtin defines for propeller-gcc and memory models are.
__propeller__
__PROPELLER__
__PROPELLER_XMM__
__PROPELLER_XMMC__
__PROPELLER_LMM__
__PROPELLER_COG__
__PROPELLER_64BIT_DOUBLES__
__PROPELLER_32BIT_DOUBLES__
These macros are defined depending on the flags passed to propeller-gcc.
__PROPELLER_XMM__ is a mode where code and global data normally live in external memory.
__PROPELLER_XMMC__ is a mode where code normally lives in external memory and all data lives in HUB.
The macros HUBTEXT and HUBDATA can force any code or data to live in HUB memory.
This info is also provided here (now) https://sites.google.com/site/propellergcc/supplements/propgcc-compiler
Erik, if you want to mix LMM and COG code you generally have to put them in separate C files and compile them with different options (-mlmm for the LMM files and -mcog for the COG files). I'm not sure that SimpleIDE supports this yet, although perhaps it does.
SimpleIDE supports this, fortunately. This is probably a very common setup for Propeller projects, after all. Just put the COG c code in modules with names that end in .cogc (instead of .c). The .cogc modules are compiled with -mcog (COG memory model) regardless of the memory model in the project settings. All other modules are compiled in the project's memory model. One of the Toggle sample projects demonstrates how this works.
I'm not sure if there's a way to compile a COG module in C++ (name it .cogcpp perhaps?) but I would recommend against that anyway because C++ has the potential of adding a lot of overhead.
===Jac
Don't think it would make much sense to anyway given the very restrictive environment of the COG. Can't imagine what you can use C++ to do in there given the tiny amount of resources and restrictions on stack and calling functions.
I know a lot of folks like spin and prop asm, but after learning c, I find it rather liberating. It is so much easier to use bitfields, as a small example. Spin is a good springboard to learn c, I think.
I am pleased to see that the IDE is QT based.