Shop OBEX P1 Docs P2 Docs Learn Events
How to determine the number of Cogs? — Parallax Forums

How to determine the number of Cogs?

Is there a quick way of finding out programmatically the number of cogs actually present on a Propeller chip? I know there are actually 8 on all current chips, but I also know there are potentially versions of the Propeller 2 with other numbers of cogs. So how can a program find out from within an executing program how many there actually are?

It is easy enough from within a program to count the number of free cogs, but this is not what I need - I need the total number of cogs, where some cogs may be busy and cannot be interrupted.

I am sure there must be a simple trick (e.g. it just occurred to me as I wrote this that you could probably calculate it from the number of clock ticks taken between two hub instructions) but I wonder if there is actually an easier or more "official" method?

Ross.

Comments

  • @RossH said:
    I am sure there must be a simple trick (e.g. it just occurred to me as I wrote this that you could probably calculate it from the number of clock ticks taken between two hub instructions) but I wonder if there is actually an easier or more "official" method?

    That sounds pretty easy.

    There is a chip version letter somewhere in the ROM. It would likely be more work to do anything with that than counting the hub cycles.

  • RossHRossH Posts: 5,462
    edited 2023-01-29 07:26

    @SaucySoliton said:

    @RossH said:
    I am sure there must be a simple trick (e.g. it just occurred to me as I wrote this that you could probably calculate it from the number of clock ticks taken between two hub instructions) but I wonder if there is actually an easier or more "official" method?

    That sounds pretty easy.

    There is a chip version letter somewhere in the ROM. It would likely be more work to do anything with that than counting the hub cycles.

    Thanks, I'll look it up. But it may be easier than I thought ... this was my first attempt:

    int cog_counter() {
      return PASM(
         "cogid r1\n"
         "getct r1\n"
         "cogid r0\n"
         "getct r0\n"
         "sub r0,r1\n");
    }
    
    void main() {
       printf("Cogs = %d\n", cog_counter());
    }
    

    This prints:

    Cogs = 8

  • I do hope very much, that on a future Propeller the hub eggbeater would be configurable. I often need only less than 8 cogs and it would be very good, if only 4 cogs are used, they would have double memory bandwidth.

  • TonyB_TonyB_ Posts: 2,178
    edited 2023-01-31 17:44

    deleted

  • RossHRossH Posts: 5,462

    @SaucySoliton said:

    There is a chip version letter somewhere in the ROM. It would likely be more work to do anything with that than counting the hub cycles.

    I found this in an old P2 ROM listing ...

            ver             =       "A"             'Prop123-A9 / BeMicro-A9, 8 cogs, 64 smart pins
    '       ver             =       "B"             'DE2-115
    '       ver             =       "C"             'DE0-Nano / DE0-Nano Bare
    '       ver             =       "D"             'BeMicro-A2
    '       ver             =       "E"             'Prop123-A7
    '       ver             =       "F"             'Prop123-A9 / BeMicro-A9, 16 cogs, 12 smart pins
    
    

    But the only place 'ver' seems to be used is in the prompt text string ...

    text_ver        byte    13,10,"Prop_Ver ",ver,13,10,0,0
    
    

    So there are several problems with using this method ...

    1. There seems to be no guarantee about where you will find the version letter in the ROM
    2. There is no knowing what the letter actually means
    3. Looking up a table to convert - say 'F' to 16 - would take more time and memory than calculating the number of cogs yourself
    4. The table would have to be updated for every new version of the chip.

    However, this was from an old P2 ROM listing (2018!). Is there a more up to date one?

    Ross.

  • evanhevanh Posts: 15,914

    https://forums.parallax.com/discussion/169695/new-fpga-files-for-next-silicon-version-5th-final-release-contains-new-rom/p1

    '   ver     =   "A"     'Prop123-A9 / BeMicro-A9, 8 cogs, 64 smart pins
    '   ver     =   "B"     'DE2-115
    '   ver     =   "C"     'DE0-Nano / DE0-Nano Bare
    '   ver     =   "D"     'BeMicro-A2
    '   ver     =   "E"     'Prop123-A7
    '   ver     =   "F"     'Prop123-A9 / BeMicro-A9, 16 cogs, 12 smart pins
        ver     =   "G"     'Prop2 Silicon v2
    
  • since the boot-message states # of COGs there should be some rom location containing it.

    But after running debug rom is gone. On the other hand I guess a "P3" will take some more years to appear, so no worries @RossH :)

    Mike

  • RossHRossH Posts: 5,462
    edited 2023-02-01 05:59

    @msrobots said:

    On the other hand I guess a "P3" will take some more years to appear, so no worries @RossH :)

    Mike

    I'll be long gone by the time the P3 comes along. But I am hoping to see a 16 cog P2 before I pop my clogs!

    Ross.

  • evanhevanh Posts: 15,914

    I think Chip will be happy with just a family of Prop2s as well. Fix the errors and use finer fabrication processes.

Sign In or Register to comment.