COG internals
Buddha
Posts: 25
The documentation states that MIPS = Freq in MHz / 4 * Number of Active Cogs.
This seems to indicate that either the Cogs are clocked at 1/4 Freq internally, or that they have a 4-stage fetch-execute cycle. My best guess so far is something along the lines of:
Fetch (instruction)
Load (data)
Execute (instruction)
Store (data)
Is this how a Cog processes an instruction every 4 clocks, or is that way off base?
Thanks! [noparse]:)[/noparse]
This seems to indicate that either the Cogs are clocked at 1/4 Freq internally, or that they have a 4-stage fetch-execute cycle. My best guess so far is something along the lines of:
Fetch (instruction)
Load (data)
Execute (instruction)
Store (data)
Is this how a Cog processes an instruction every 4 clocks, or is that way off base?
Thanks! [noparse]:)[/noparse]
Comments
0:· Read S for Inst
1: ·Read D for Inst
2:· Read Inst+1
3:· Write D for Inst, Inst++, loop
This way, the ALU has two clocks to settle in before D must be written back.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
What happens starting at cycle zero, when a COG is first started? Does it idle for a few cycles so it can execute step 2 and come back around to 0 (i.e. the very first instruction on startup takes 8 cycles)?
Or does it execute a special "read first instruction" step for one cycle (i.e. the first instruction takes 5 cycles)?
Or does something else happen, like the HUB stuffs the first instruction into the internal CPU register before it starts execution?
RDLONG· 0, START+0*4
RDLONG· 1, START+1*4
RDLONG· 2, START+2*4
....
RDLONG· 511, START+511*4
YOUR CODE $000
YOUR CODE $001
....
So, you can see that after loading all 512 locations using forced RDLONG instructions, the COG program counter rolls over, right into your code at $000. BTW, the last 16 RDLONGs read 0's, clearing the RAM behind the I/O registers. The DIRA, CTRA, CTRB, and VCFG I/O registers are all cleared asynchronously as long as the COG is inactive (COG reset is held low). This way, as long as (or immediately when) a COG is inactive, its influence completely ceases as its important I/O registers are cleared. When the next program gets loaded, all the registers from $1F0-$1FF get cleared to 0, as well. This means that you can rely on all I/O registers, except the read-only's PAR, CNT, INA, INB, being cleared when your program starts.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
Post Edited (Chip Gracey (Parallax)) : 6/28/2006 2:38:56 AM GMT
So, does this mean that a read from INA will be latched at the second cycle of the instruction? That's good info.
What's the latency in cycles for COGINIT (from start of COGINIT to start of first instruction in the other COG)?
More generally, is it possible to get two COGs running 2 (or 1 or 3) cycles out of sync, so they could interleave reads from INA?
Chip Gracey
Parallax, Inc.
Of course! I'm spending so much time on single-cycle-instruction machines lately that I missed this entirely.
How silly of me. Thanks!
The booter is·at $F800 and the interpreter is at $F004. You will not be able to disassemble these programs, though, since the data is scrambled and only gets unscrambled by the HUB during launching. This is the only 'code protection' that the chip has and it's designed to slow down others from making me-too Propeller-like chip products. This issue has never come up before, but I figured your next post·would be something about·"How·come this code·looks jumbled?" I would like to share the booter and interpreter with our interested customers, but I don't want to let it out because I don't want to make it too simple for a competitor to get started. If they have to write their own interpreter in 496 longs that is compatible with ours, it may never happen, but if we publish the code, then·they'll make an innocuous change here and their and claim it as their own. I don't want that to happen.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
Post Edited (Chip Gracey (Parallax)) : 7/6/2006 6:46:07 AM GMT
That's completely understandable. Thanks for the info! That definitely saved me some time from banging my head against a glass wall that I wouldn't even know was there. [noparse]:)[/noparse]