Shop OBEX P1 Docs P2 Docs Learn Events
Multi-cog system application image — Parallax Forums

Multi-cog system application image

00000000 Posts: 11
edited 2012-04-24 10:02 in Propeller 1
Hello,

I'm wondering how the propeller manage a multi-cog application image.
Assembly code is loaded from Main RAM (the application image) into Cog RAM and executed directly, which is why it is so much faster than Spin code.

That means, at the boot up procedure, the propeller will execute the first public method thanks to his
spin interpreter and on each cognew() it will copy part of image into the corresponding cog's RAM?
There are so many things about the propeller which are undocumented, it looks like a magical microcontroller.

Comments

  • KyeKye Posts: 2,200
    edited 2012-04-24 06:55
    So... this stuff is documented. Please see the Propeller Q&A. http://www.parallax.com/portals/0/help/P8X32A/QnaWeb/

    When you compile code for the propeller it is converted either into SPIN byte-code or assembly tokens. That stuff then sits in the hub memory which can be read or written to by all of the eight processors. The other processors must be started first be they do anything. Only core 0 turns on by default and executes the first PUB in your code.

    Then, the cognew command just tells the next free core to load up its personal cog ram with part of the main ram and start executing whatever code that was it just loaded up in ASM. Alternative the cognew command can tell a core to start running the SPIN interpreter ASM program which is located in the propeller chip's ROM. This gives you the ability to startup multiple SPIN interpreters which can execute SPIN byte-code.
  • 00000000 Posts: 11
    edited 2012-04-24 07:15
    That's what i thought but when you call cognew you only give it the absolute address of code and not the size of code.
    When that code is a COGNEW(AsmAddress…) or COGINIT(AsmAddress…) command, the Propeller starts the designated cog to load its Cog RAM with 496 consecutive longs of data from Main RAM, starting at the AsmAddress location. (This overwrites any code or data that may have been in the target cog's RAM). The cog then executes the assembly code directly from its Cog RAM, beginning at address 0.

    And what happens if the AsmAddress is near the end of the global RAM? e.g. COGNEW(0x7FF0)
  • KyeKye Posts: 2,200
    edited 2012-04-24 09:15
    The cog always copies 496 longs. If it runs off the end of memory it starts from the beginning again.

    You the programmer, must assume that any un-initialized registers will contain junk. So, if you write code that takes up 130 longs... then any of the last (496 - 130) = 369 registers will just have junk in them. The last 16 special purpose registers are always initialized to 0 on startup.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-04-24 10:02
    Remember also that the Propeller has 32K of masked ROM which is at addresses $8000 to $FFFF. If you're loading up a cog's memory and the 496 long block goes past the end of RAM, the content of ROM is used. There's a description of the content of ROM in the Propeller Manual and the Datasheet.
Sign In or Register to comment.