PDA

View Full Version : [puzzle] back in line



kuroneko
04-01-2012, 02:12 AM
Something I came across recently ...

You have 4 cogs with IDs N, N+1, N+2 and N+3. At some point they will be synchronised on a waitcnt. This also means that they may or may not by in sync with their respective hub window, e.g. if cog N+1 has its hub window immediately following the waitcnt then cog N just missed it (N+2 and N+3 would be fine). So executing a hubop would happen in the following order N+1, N+2, N+3, N.

What I'm looking for is a single piece of code (the same for each cog) which is run in each cog after the waitcnt which is then followed by a hubop (say a rdlong). Requirement being that said rdlongs are then executed in order N..N+3. The cogs know who they are, i.e. first or last in sequence. Ideally the carry flag isn't used.

Phil Pilgrim (PhiPi)
04-01-2012, 06:47 AM
Well after trying it, I know one thing that does not work. It seemed so reasonable to assume that the hub access hardware used cnt to determine which cog's turn it is: i.e. (cnt >> 1) & 7. If that were the case, all you would have to do is make sure that the last four bits of the waitcnt sync value equaled the right magic number.

But no.

-Phil

kuroneko
04-01-2012, 03:58 PM
To make it a bit easier I added a test program to the top post. Just fill in the relevant PASM sections and see if it works.

Phil Pilgrim (PhiPi)
04-01-2012, 04:25 PM
To make it a bit easier ...
With a four-channel scope, it's easier still. :)

-Phil