Shop OBEX P1 Docs P2 Docs Learn Events
Cog Memory Object (UPDATED!!) — Parallax Forums

Cog Memory Object (UPDATED!!)

tpw_mantpw_man Posts: 276
edited 2008-08-02 01:20 in Propeller 1
This adds some somewhat slow memory to a propeller application. It uses a cog and the spare memory within the cog to add ~1560 bytes. It can be used for an application where not much main memory is left, but a cog or two can be spared. It can support up to 8 cogs and weighs in at about 170 longs. The demo only takes up 2/3 of the memory capacity it adds smile.gif Attached is the object along with a simple demo that lights up an LED when memory values read and written are the same. If anybody spots any ways to make it smaller or any potential bugs it would be appreciated. A version that supports block reads/writes will come soon. I hope it will be of use!

EDIT: Updated to support block reads/writes.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I am 1011, so be surprised!


Advertisement sponsored by dfletch:
Come and join us on the Propeller IRC channel for fast and easy help!
Channel: #propeller
Server: irc.freenode.net or freenode.net
If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
tongue.gif

Post Edited (tpw_man) : 8/2/2008 12:51:22 AM GMT

Comments

  • SeariderSearider Posts: 290
    edited 2008-07-31 23:50
    That rocks. So now to answer the PropII question of more COGS or RAM, we should want COGS because with this object we can trade Cogs for RAM but not the otherway around.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Searider
  • tpw_mantpw_man Posts: 276
    edited 2008-07-31 23:57
    The best part is that you can store the object in the cog itself. So even if you have one cog, you are always gaining memory. You can also fit the assembly code in, so you can use the assembly in the object code as space, and retrieve the assembly when you need to launch a new cog.
    EDIT: I think they decided to go with 16 cogs and 256K of ram to get the best of both props.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1011, so be surprised!


    Advertisement sponsored by dfletch:
    Come and join us on the Propeller IRC channel for fast and easy help!
    Channel: #propeller
    Server: irc.freenode.net or freenode.net
    If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
    tongue.gif
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-07-31 23:59
    Nice object! A good idea!

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with the Protoboard? - Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card? - PropDOS
    Need a part? Got spare electronics? - The Electronics Exchange
  • tpw_mantpw_man Posts: 276
    edited 2008-08-01 23:19
    It has now been updated to V 2.0 to support block reads/writes. It really needs some trimming, as the code is quite big, unfortunately.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1011, so be surprised!


    Advertisement sponsored by dfletch:
    Come and join us on the Propeller IRC channel for fast and easy help!
    Channel: #propeller
    Server: irc.freenode.net or freenode.net
    If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
    tongue.gif
  • TimmooreTimmoore Posts: 1,031
    edited 2008-08-01 23:35
    tpw_man, A question why dont you use the cog id (i.e. return from cognew) as the ref number rather than messing with get_id and random numbers? each return from cognew is unique which is all you want.
  • tpw_mantpw_man Posts: 276
    edited 2008-08-01 23:41
    @Timmoore
    I had a reason when I started, but I entirely forget now. I will try and fix it to not need that.

    EDIT: Fixed it to not need the random numbers and cog id. Thanks for the suggestion, it shaved off 20 longs [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1011, so be surprised!


    Advertisement sponsored by dfletch:
    Come and join us on the Propeller IRC channel for fast and easy help!
    Channel: #propeller
    Server: irc.freenode.net or freenode.net
    If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
    tongue.gif

    Post Edited (tpw_man) : 8/1/2008 11:48:39 PM GMT
  • TimmooreTimmoore Posts: 1,031
    edited 2008-08-02 00:02
    If I understanding you addressing correctly, I think you have a byte addressing bug, you 'and' the address with #2 and shl #3. You are getting how much to shift the long around to get a byte. I think you need to 'and' with 3 not 2.
  • tpw_mantpw_man Posts: 276
    edited 2008-08-02 00:18
    @Timmoore
    It ands it with 2 to get the 'sub address' which is the portion of the long to read/write from. It then shifts left 3 to multiply by 8 to get the byte shifting number. It then uses the byte shifting number to position the appropriate byte at bits 0-7 in at the long. It should be that way to work right.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1011, so be surprised!


    Advertisement sponsored by dfletch:
    Come and join us on the Propeller IRC channel for fast and easy help!
    Channel: #propeller
    Server: irc.freenode.net or freenode.net
    If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
    tongue.gif
  • TimmooreTimmoore Posts: 1,031
    edited 2008-08-02 00:28
    if you ask it to read address 1, I assume you are reading the byte at address 1. So in read-data temp is #mem+1 so you are reading the 2nd long (shouldn't this be the 1st long?), then temp2 is 1 & 2 = 0, then * 3, to get 0, so you read the long at address 1 and dont shift it.
    dont you want to read the long at address 0 and shift it by 8 to get the 2nd byte?
  • tpw_mantpw_man Posts: 276
    edited 2008-08-02 00:43
    Wait, it should be and #3, shl #3. Thanks for catching that, and not thanks to me for not understanding that :P It is #mem, not #mem+1 unless I am not understanding myself again :P It is updated for that error. I also messed up my estimate on how much space it gives you. I am NOT thinking today tongue.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1011, so be surprised!


    Advertisement sponsored by dfletch:
    Come and join us on the Propeller IRC channel for fast and easy help!
    Channel: #propeller
    Server: irc.freenode.net or freenode.net
    If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
    tongue.gif
  • jazzedjazzed Posts: 11,803
    edited 2008-08-02 01:20
    Nice idea.
    Junking the single read/writes would save some memory. Having a buffered
    transaction of one long for single accesses is better than adding extra stuff.
    The current spin read and write API signatures could remain the same.
    Is it possible to make the spin functions do the shifting?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sign In or Register to comment.