Shop OBEX P1 Docs P2 Docs Learn Events
Main RAM vs. Cog RAM — Parallax Forums

Main RAM vs. Cog RAM

coryco2coryco2 Posts: 107
edited 2014-04-10 11:28 in Propeller 1
I am reading through "Introducing the Propeller Chip" in the Propeller Manual, and have a few questions in regards to the relationship of Main RAM usage to Cog RAM usage at run-time.

As I understand it, at run-time the Propeller loads a Boot Loader from ROM to RAM, which then runs in Cog 0 and downloads the user program (from a host or EEPROM) into Main RAM. The user program then runs in one or more cogs. If any of the code is Spin, an interpreter is also loaded from ROM. My questions:

1. Is this boot loader loaded into and run from Cog 0's RAM or the Main RAM?

2. Similarily, is the user program loaded from Main RAM into the Cog(s) RAM when run, or does it run directly from Main RAM?

3. Where are variables, constants and data items? (e.g. are global variables stored in Main RAM and local variables stored in Cog RAM, ?)

Thanks!

Comments

  • coryco2coryco2 Posts: 107
    edited 2014-04-10 10:19
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-04-10 11:12
    1. The boot loader is loaded into cog 0 and run from there.

    2. A user program can be a mix of Spin and PASM. Initially, everything is loaded into hub RAM. Then the Spin interpreter replaces the boot loader in cog 0 and begins interpreting the top-level Spin program's byte codes from hub RAM. If the top-level program requests additional cogs for Spin programs, additional copies of the interpreter are loaded into cogs to interpret them -- again from the hub. If cogs are requested for PASM programs, those programs themselves are loaded into additional cogs and executed directly.

    3. VAR variables exist in the hub, one copy for each instance of the object that uses them. DAT variables also exist in the hub to start, only one copy for all instances of their host object. If the PASM block that includes any DAT variables gets started in a cog, those variables are also loaded into the cog, where they can be local variables for the PASM program. Changing them in the cog does not affect their values in the hub, though. Local variables for Spin programs exist only in the interpreter stack, which lives in the hub.

    -Phil
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-04-10 11:28
    The only time you'll deal with cog RAM is with PASM.

    All variables accessible through Spin are in hub RAM.

    You can't access the cog RAM through Spin without some sort of PASM program designed to let you access it.

    Launching a new cog does not change the way variables are accessed.
Sign In or Register to comment.