Shop OBEX P1 Docs P2 Docs Learn Events
Regarding COGID instruction — Parallax Forums

Regarding COGID instruction

sanketsanket Posts: 28
edited 2009-10-08 15:00 in Propeller 1
Hello every one,
I have gone through the manual of propeller.
I got a problem with the instruction COGID (page -365 in propeller manual)
when processor encounter this 32 bit instruction, how can it came to know which COG it is?
Does the last 3 (LSB) bits of the source field specifies the COGID?

For example - 000011 0011 1111 ddddddddd
001
Is above instruction specifies for COG1?
and, 000 in LSB of source indicates for COG0?

Thank You

Comments

  • ericballericball Posts: 774
    edited 2009-10-07 19:18
    sanket said...
    Hello every one,
    I have gone through the manual of propeller.
    I got a problem with the instruction COGID (page -365 in propeller manual)
    when processor encounter this 32 bit instruction, how can it came to know which COG it is?
    Does the last 3 (LSB) bits of the source field specifies the COGID?

    For example - 000011 0011 1111 ddddddddd
    001
    Is above instruction specifies for COG1?
    and, 000 in LSB of source indicates for COG0?

    Thank You
    In PASM, opcode 00011 is a HUBOP, and the 3 LSBs specify which HUBOP (e.g. COGINIT, COGSTOP, COGID) is invoked.· (000 happens to be CLKSET).· So it's not the instruction which determines the cog, but the hub.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
  • sanketsanket Posts: 28
    edited 2009-10-08 06:43
    Thank You ericball for you quick response,
    I understand what you have written in reply.
    If last three digits selcects one of the instruction among the HUB operation then how is it possible to say by seeing COGID instruction that which cog is running? because COGID copies the running COG's number in to destination. So is there anyway to know the running COG's number by seeing 32 bit?


    Thank You
  • kuronekokuroneko Posts: 3,623
    edited 2009-10-08 07:46
    Just to make sure, cogid returns the ID of the calling cog to you (i.e. the cog executing this instruction). All you give the instruction is a destination register (cog memory space) where the ID value is placed. For example:

            cogid   temp
            cogstop temp
    
    temp    res     1
    


    This code fragment stores the cog ID in the register labelled temp, which is then used as an argument to cogstop thereby shutting down the calling cog.

    The knowledge about which cog is executing the instruction is hard-wired into the chip.
  • ericballericball Posts: 774
    edited 2009-10-08 12:18
    sanket said...
    If last three digits selcects one of the instruction among the HUB operation then how is it possible to say by seeing COGID instruction that which cog is running? because COGID copies the running COG's number in to destination. So is there anyway to know the running COG's number by seeing 32 bit?
    Just to be clear.· There is no way to determine which cog is executing from examining the register containing the COGID instruction.· When the COGID instruction is executed, the HUB updates the destination register with the number of the cog which executed the instruction.· (Unless the NR flag is set, of course.)


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-08 15:00
    @sanket,
    Your last question was "how does the COGID instruction know which cog is executing it?".

    The HUB logic knows. Remember that the hub allows access to the shared 32K of memory every 16 clock cycles. Internal to the hub logic is a counter that holds the number of the cog currently accessing the hub. The COGID instruction simply copies this counter to a cog memory location.
Sign In or Register to comment.