Shop OBEX P1 Docs P2 Docs Learn Events
Hardware requirements for running large C programs — Parallax Forums

Hardware requirements for running large C programs

wrmiller19wrmiller19 Posts: 17
edited 2012-01-30 08:12 in Propeller 1
Hey guys,

What type of non-volatile memory will support running large (>256k) C programs? I noticed that ICCV7 (ImageCraft) supports 'large' memory models. How exactly does this work. Are there better solutions?

I'm asking because I may have to support an existing product written in Spin, and I'd like to rewrite it if possible. Current implementation has 6 of the 7 top objects stored on a SD card, and they are loaded onto the Propeller as needed by a fat16 driver running in hub ram (I think).

If I wrote C program that compiled to say, 180k, how could I run this on a Propeller?

TIA,
Bill

Comments

  • jazzedjazzed Posts: 11,803
    edited 2012-01-19 14:58
    Hi Bill.

    Large Memory Model (LMM) is something of a misnomer. It just means that special PASM variant programs can be saved in HUB memory and executed by a COG "interpreter". Instructions are read one at a time from HUB memory and executed "as-is" by the COG hardware in most cases. This method is considered "Large" relative to the amount of memory provided by a COG.

    To run a program that is 180KB requires a compiler that can fetch/execute programs from an external device such as Flash or SRAM. This is called XMM (and/or XMMC in the case of Propeller GCC). The same kind of trick used by LMM is used for XMM programs except that code is fetched from external memory.

    Propeller GCC is the only officially supported Parallax product that can do this today. Propeller GCC is entering Beta phase soon but is available for testing now. Propeller GCC XMMC mode supports relatively fast Flash, SdCard, and Eeprom program execution. XMMC programs can also be run from SRAM/SDRAM if necessary. Propeller GCC XMM programs are slower than XMMC programs but allows access to larger blocks of memory stored in program data space (XMMC data is limited to HUB memory).

    There are also third-party alternatives such as Catalina and xBasic that support external memory programs. ICC for Propeller does not support XMM programs and is no longer supported by ImageCraft.

    Hope this helps.
    --Steve
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-01-19 15:29
    Catalina C runs on the prop with various implementations of external sram and possibly flash. Catalina uses ANSI C and has been around for quite some time and is supported by Ross. It is free although a donation for professional use is encouraged. I think he sells some extra features quite cheaply. See the latest Catalina 3.4 thread here http://forums.parallax.com/showthread.php?135424-Catalina-3.4&highlight=catalina+3.4

    Catalina compiles code to LMM/XMM PASM which is pasm instructions with special jumps. In LMM, each instruction (32bits) is fetched from hub into the cog and executed. Therefore it is slower than real pasm executing in a cog. XMM fetches the code from external memory such as SRAM into the cog for execution.

    Catalina runs on my platforms such as the RamBlade and the new RamBlade3 and the older TriBlade. These are the fastest implementations (512KB of 55ns SRAM) but consume the whole propeller because the address lines are not latched - a microSD is on this prop. This method requires two props with the second prop performing the I/O. Catalina also runs on the DracBlade that uses a latched design and therefore has I/O available for the program to use.

    I hope this helps.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-01-19 16:08
    What type of non-volatile memory will support running large (>256k) C programs?

    In theory, any external memory chip that you can write a driver for. A 512k parallel chip is popular. There are a number of serial ram solutions, which are slower, but more recently there has been some fascinating work on caching that means the speed of the external ram is much less important. I believe Jazzed has even done a 32mb solution.

    In both GCC and Catalina, there are drivers for different ram chips and these drivers generally run in a cog and fetch the data as needed. You can specify which driver to use when the program is compiled.

    One nice feature of C is that you can write a little program and compile it to "hub", ie LMM, and then with one change to the compilation, recompile it for XMM. Both are useful, as downloading to hub ram is quicker, so you can test bits of code by running them in LMM, then put them all together and download a bigger XMM program.

    I've written 200-300k sized programs and at that size, the download time is just starting to get a little tedious.

    One question to consider with any external memory is how many propeller pins you want to use to talk to the memory, and how many other pins you need free to talk to other things like keyboard, mouse, display, sd card, real world I/O.
  • RossHRossH Posts: 5,512
    edited 2012-01-20 04:44
    wrmiller19 wrote: »
    Hey guys,

    What type of non-volatile memory will support running large (>256k) C programs? I noticed that ICCV7 (ImageCraft) supports 'large' memory models. How exactly does this work. Are there better solutions?

    I'm asking because I may have to support an existing product written in Spin, and I'd like to rewrite it if possible. Current implementation has 6 of the 7 top objects stored on a SD card, and they are loaded onto the Propeller as needed by a fat16 driver running in hub ram (I think).

    If I wrote C program that compiled to say, 180k, how could I run this on a Propeller?

    TIA,
    Bill

    Hi Bill.

    As others have said, you need to learn a little about LMM to understand how the Prop supports "large" C programs. LMM programs execute instructions out of the 32 kilobytes of Hub RAM rather than the 496 longs of Cog RAM, at speeds around 1/4 of Cog RAM programs (but something like 10 times faster than the equivalent Spin programs).

    As well as LMM programs there are external memory (XMM) programs, where the program is executed out of RAM external to the Propeller chip itself. This is slower again than LMM, but allows programs to be megabytes in size.

    ICC supported LMM programs (i.e. up to 32k) but not XMM programs - and support for this product has now been discontinued by the original supplier in any case.

    I don't think anyone here would recommend ICC as a long term option. You should look at Catalina or GCC instead.

    Ross.
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-01-20 06:49
    Here's the timing results of a couple of simple benchmarks we ran on PropGCC for LMM and XMMC with various external memory configurations.
                     LMM  C3 XMMC C3F XMMC  EEPROM XMMC SSF XMMC SSF2 XMMC SDRAM XMMC SDCARD XMMC
                     ---  ------- --------  ----------- -------- --------- ---------- -----------
    Transpose (msec)  887     902      902          904      902       902        902         903
    sprintf (msec)    531   27386     5486        10046     3515      3415       3886       34262
    
    The Transpose benchmark transposes an NxM matrix. It is a small routine, so it gets fully cached the first time it runs, which is why the XMMC times are almost as fast as the LMM time. The sprintf benchmark calls the C library sprintf function many times. This represents more random code, and the execution times depend on the speed of external memory access. The SSF and SSF2 configurations are the fastest. These were run on Jazzed's SpinSocket boards, which I believe uses flash memory with byte-wide access.

    I not sure what the SDRAM uses. Maybe Steve can comment on this. The C3 and C3F are the times on the C3 card. The C3F cache driver only supports the flash chip, whereas the C3 driver divides the cache memory between the flash and the external RAM. The EEPROM driver uses the Prop's boot PROM, and the SDCARD driver executes directly out of an SD card.
  • wrmiller19wrmiller19 Posts: 17
    edited 2012-01-20 10:22
    Thanks for all the input guys! Not sure if this will satisfy the requirements, but it's worth looking into.

    Will Hanno's ViewPort work with C programs? (think I read this somewhere?)
  • jazzedjazzed Posts: 11,803
    edited 2012-01-20 11:38
    Dave Hein wrote: »
    I not sure what the SDRAM uses. Maybe Steve can comment on this.
    The Propeller Platform SDRAM module has an ISSI 32MB SDRAM accessible in byte bursts, an SDCARD slot, TV Audio/Video RCA connectors, and a single latch. All Propeller pins are used on this design. A companion I2C Mouse/Keyboard is available to those who want all components required for a TV/PC.

    The SpinSocket-Flash (SSF) modules have byte-wide Quad-SPI Flash and have 18 free Propeller pins (20 if you count serial port pins). A Propeller Platform interconnect board is available for SSF. The free pins, fast startup time (SDCARD not requied), no default hardware connections except Flash/EEPROM/serial port, and small package differentiate the two designs.

    As Dave's table shows, there is very little performance difference between the two designs with Propeller GCC XMMC. The SDRAM board will work with Propeller GCC XMM mode which uses volatile storage. There is an SSF-SRAM accessory board design that will be useful with XMM.

    The key advantage to performance with most of these designs is the ability to read or write data with a single clock after setup which is a good match with caching.
  • HannoHanno Posts: 1,130
    edited 2012-01-23 17:32
    Hi Bill,
    ViewPort supports the Ross' excellent Catalina C compiler and integrates with the BlackCat debugger. See attached for screenshots of ViewPort's project editor, code highlighter. To compile/load either a single C file or complete project just click "run".
    Hanno
    1006 x 720 - 110K
    824 x 504 - 68K
    c1.png 110.3K
    c.png 68.4K
  • wrmiller19wrmiller19 Posts: 17
    edited 2012-01-26 14:19
    I cannot seem to find the BlackCat debugger anywhere on the 'net. Is it available somewhere? TIA...
  • RossHRossH Posts: 5,512
    edited 2012-01-26 17:21
    wrmiller19 wrote: »
    I cannot seem to find the BlackCat debugger anywhere on the 'net. Is it available somewhere? TIA...

    Hi wrmiller,

    Originally I think it was available in the forums, but I can't find that thread in a quick search - it may have been lost when we switched to the new forum software. According to this thread, it is also supposed to be available in the OBEX, but when I tried it says it is still locked awaiting approval. Since I already have a copy (as probably does Hanno) we never needed to download it, so we never noticed.

    I'll check and see if there is a copy available elsewhere. Bob Anderson may still visit the forums - perhaps he will chime in as well.

    Ross.
  • HannoHanno Posts: 1,130
    edited 2012-01-26 20:34
    I too have been unable to find it- I think you're right Ross that it got lost with the forum change :(
    I'll shoot Bob and email to see if he's ok with me/Ross hosting it.
    Hanno
  • wrmiller19wrmiller19 Posts: 17
    edited 2012-01-28 20:48
    Yea, I saw the "awaiting approval" in the OBEX. Thanks guys for any and all help! :)
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-01-28 20:52
    RossH wrote: »
    it may have been lost when we switched to the new forum software.
    Remember that the old forum is now read-only at http://forums.parallaxinc.com/forums/default.aspx
  • RossHRossH Posts: 5,512
    edited 2012-01-28 23:13
    Remember that the old forum is now read-only at http://forums.parallaxinc.com/forums/default.aspx

    Thanks, but it seems you cannot search the old forums. I tried scanning back manually, but I couldn't spot it.

    Ross.
  • jazzedjazzed Posts: 11,803
    edited 2012-01-29 12:09
    RossH wrote: »
    Thanks, but it seems you cannot search the old forums. I tried scanning back manually, but I couldn't spot it.

    Ross.
    Looking for this?
  • Ding-BattyDing-Batty Posts: 302
    edited 2012-01-29 12:18
    jazzed wrote: »
    Looking for this?

    I managed to find it in the full ObEx zip file put together over a year ago -- see this thread. But just that package is just under 2 MB, while the entire ObEx from a year ago is almost 40 MB.
  • jazzedjazzed Posts: 11,803
    edited 2012-01-29 12:23
    Ding-Batty wrote: »
    I managed to find it in the full ObEx zip file put together over a year ago -- see this thread. But just that package is just under 2 MB, while the entire ObEx from a year ago is almost 40 MB.

    Last year Parallax pulled most of the C stuff out of the OBEX since ImageCraft no longer supports ICC.
    They accidently took down the BlackCat package at that time. I found it in the archive posted in another thread.
  • RossHRossH Posts: 5,512
    edited 2012-01-29 16:23
    jazzed wrote: »
    Last year Parallax pulled most of the C stuff out of the OBEX since ImageCraft no longer supports ICC.
    They accidently took down the BlackCat package at that time. I found it in the archive posted in another thread.

    Thanks, Jazzed!
  • wrmiller19wrmiller19 Posts: 17
    edited 2012-01-30 08:12
    Yes! Thanks to Jazzed and all who've helped! :)
Sign In or Register to comment.