COGINIT execution time?
ManAtWork
Posts: 2,359
in Propeller 2
Does anybody know how much cycles it takes for a cog started with COGINIT in COGEXEC mode until it executes the first instruction? Of course, the COGINIT instruction itself only takes 2 cycles in the starter cog. But the target cog then has to load all of its cog RAM. I thought due to the clever "rotating" bus bars of the egg beater it should be able to load one long per cycle. But this is not true. I did some experiments and it actually takes >300µs at a clock frequency of 200MHz, so that's more than 60,000 cycles instead of only 512.
Does the cog execute some sort of software boot loader from a small built-in ROM instead of executing a hard-wired memory copy? I've found nothing about this in the assembler manual.

Comments
No, takes
2..9, +2 if resultcycles to run COGINIT.This is the cog boot ROM: https://p2docs.github.io/mirror/p2silicon.html#boot-rom--debug-rom
After coginit the warmstart ROM will run first, which means if you're starting in COGEXEC it'll load 504 longs from hub RAM using a regular SETQ+RDLONG instruction. The rest of the ROM should only take 10 cycles to execute. So it should only take 522 cycles.
If you have the debugger loaded and are getting INIT/LOAD messages in the terminal, that is actually breaking (when? after the boot rom?) and printing the message in the started cog, so it will take a lot longer to get to your actual code than it normally would. But this is a property of the debugger code.
Yeah, sounds like debug is enabled.
I think Ada's estimate of 522 cycles or so is a good one. I get 548 cycles reported from just before the coginit (
cpuin BASIC) until the first instruction of the new cog (agetctin this case) completes. There's a bit of overhead of course so this isn't exact, but it should be close.Output is: