[invalid][puzzle] Nine Cycles of Hell
kuroneko
Posts: 3,623
Disclaimer: This is more of an anti challenge as it may be impossible to solve, i.e. the result may differ from the set target.
The datasheet notes a 7..22 cycle timing for hub ops. A hub window being 16 cycles results in a nine cycle window before the next hub op can be issued (or rather is processed, 16 - 7 = 9). So let's not waste those nine cycles and fill them with a 4 cycle insn and a 5+ cycle insn of your choice, the latter set to minimum execution time.
With all the measurement going on it seems that everyone is happy with capturing cnt before and after, take the difference and adjust for overhead, e.g.
should clock in with 16 consumed cycles. It's part of the challenge to make sure that the cogid is sync'd to the hub window (and reading mark is aligned accordingly, i.e. hub window - 4).
The datasheet notes a 7..22 cycle timing for hub ops. A hub window being 16 cycles results in a nine cycle window before the next hub op can be issued (or rather is processed, 16 - 7 = 9). So let's not waste those nine cycles and fill them with a 4 cycle insn and a 5+ cycle insn of your choice, the latter set to minimum execution time.
With all the measurement going on it seems that everyone is happy with capturing cnt before and after, take the difference and adjust for overhead, e.g.
neg mark, cnt ... ' instruction(s) to be measured add mark, cnt sub mark, #4What I want is proof that there are nine cycles to spare. Basically, the sequence
neg mark, cnt [COLOR="Red"]cogid cnt ' 7[/COLOR] ... ' 9 cycle consumer add mark, cnt sub mark, #4
should clock in with 16 consumed cycles. It's part of the challenge to make sure that the cogid is sync'd to the hub window (and reading mark is aligned accordingly, i.e. hub window - 4).
Comments
AFAIK the only way to do this is to delay 2 hub cycles and use the waitcnt to do the timing. I am busy with other thinks otherwise I would try.
The timing will be updated in the next revision of the documention along with the actual values for waitpxx/waitcnt and waitvid (6+/4+).
Blimey, no wonder Zog is so slow:)
If you run this code and look at a scope...
... the HIGH time will be 100ns. However if you run this code ...
... the HIGH time will be 125ns and I think (<-THAT) is where the confusion came from and how it was miscalculated and made it's way into the documentation. Intuitively if you think 100ns for a command that you know to take 4 clocks, and then look at a command that indicates 125ns, then you just assume there is a 5th clock.
What your not considering is the processing overhead time required for making the pin HIGH, and then LOW again. Look at this code ...
... the HIGH time is 50ns. So in the above scenario you should be comparing 50ns and 75ns by subtracting 50ns from your original readings.
50ns = 100ns - 50ns
75ns = 125ns - 50ns
... So if 50ns is equal to 4 clock cycles (12.5ns * 4 = 50ns) then 75ns is equal to 6 clock cycles (12.5ns * 6 = 75ns)
Citation needed?
That's great! Accurate documentation is a must. Thank you for being on the case.
and the output:
-Phil
Seriously? Don't you think the docs should match reality?
Not everyone has the PASM chops to figure it out for themselves. I for one don't understand what your program does. Care to elucidate, please?
I think you misunderstood my comment. (In fact, I hadn't read your comment when I posted my code, else I might have phrased mine differently.) Of course, accurate documentation is a must. I was only responding to Kuroneko's statement, "As of today Parallax have officially (enough for me) acknowledged that hub ops take 8..23 cycles..." Some might interpret this to imply that it's not real until Parallax verifies that it's real. What I was trying to get across is this: Always trust your own experience before you trust anything "official".
tonyp12,
Thanks for commenting my code for me. In my haste to post, I left out that important detail. My apologies to the forum.
-Phil
Personally I don't need any official word. But mismatching documentation somehow gets up my nose especially when it's this easy to fix. As for evidence, why would a newcomer to PASM even question the data sheet? Some of us did for their own reasons and as I'm usually a nice person I don't see why other people should find out the hard way (as it's just an irritating distraction).
Don't read too much into it, it wasn't meant in the way you suggested it could be interpreted I could have simply said they'll update the documention.
@mpark: re: citation, ATM I'm sorting out some other issues with Jeff Martin, he confirmed this in an email and I'm free to spill the beans. That has to be enough for now.
-Phil
Hell, I'm impressed you even got a response. Well done!
I have looked on this datasheet and still see ERRORS.
On page 5 in Schematics I Don't see any decoupling capacitor. In my opinion it is why all NEW user's on PEKit build theirs experiments on breadboard Without that capacitors and in some cases have problems.
Yes - we need BE
That are good to all - Both Parallax and us to have manual that are correct.