PDA

View Full Version : SPIN instruction length



HGPL
02-11-2007, 06:37 PM
How many cycles length a SPIN instruction?
I think one spin instruction executed in once per 16 cycles max.

...because the SPIN application are in the Main Memory (mutually-exclusive) and I think that in case give me the sentence in below.
... and it's mean the most sorted SPIN instruction is quite 16 cycle.

It is right ???


Please help me!

parsko
02-11-2007, 11:01 PM
HPGL,

Though, I can't answer your question exactly, I too would ask the same. They say that SPIN operates at around 80k instructions per second. My specific question is; does each command execute in the same length? Writing PASSY code, one can predict and control the exact time to run, but I don't think the same is possible with SPIN.

-Parsko

Mike Green
02-11-2007, 11:47 PM
Spin is an interpreter and takes a variable amount of time to execute each of its byte code instructions. There is no official documentation on the byte codes produced by the compiler and no documentation on the time the interpreter takes to execute them (other than the rough estimate parsko mentioned). The Spin serial I/O routines work up to about 19.2Kbps, so estimating the number of primitive operations involved per bit gives some idea. The commands would vary considerably in time needed to execute, just given the fact that multiplication and division have to be done by subroutine since there is no single instruction to do them. I'm sure the interpreter is very efficient.

Assembly language is a different thing. Each instruction (other than HUB instructions) takes either 4 or 8 cycles to execute with conditional jumps (like DJNZ/TJZ/TJNZ) taking 8 cycles if they don't jump and all non-HUB instructions taking 4 cycles. The Propeller Manual discusses the HUB timing which is variable. There's a table on pages 350-1 of the manual that gives the timings.

Paul Baker
02-12-2007, 04:57 AM
Anyone wanting to investigate the relative execution speed of various spin commands can use the same procedure Tracy Allen used on measuring the execution of PBASIC instructions on the Basic Stamp.

Take an oscilloscope and set it up in positive edge trigger mode where the trigger·level is Vdd/2. Setup a simple program where two consecutive instructions setting a·pin high followed by setting a bit low are executed·then measure the pulse width and record the value. Now place an instruction between those two instructions and measure the pulse width. Take the second measure and subtract from it the first measure and you now have the length of time it took to execute the instruction under test. This procedure can be used to measure the length of time it takes to execute any Spin instruction.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker (mailto:pbaker@parallax.com)
Propeller Applications Engineer
[/url][url=http://www.parallax.com] (http://www.parallax.com)
Parallax, Inc. (http://www.parallax.com)

Post Edited (Paul Baker (Parallax)) : 2/11/2007 9:02:10 PM GMT

HGPL
02-12-2007, 05:36 AM
Thanks for your answers!

I will get the propeller chip about a week (because the suplier wait for my another order (FPU V3)).
I study the whole Propeller Manual several times. And I started predevelop...
My application is very time-sensitive so I think coding assembly.
But the SPIN are the comfortable language and poke my mind.
...however I not anywhere found SPIN relative timing description, only for ASM instructions.
... so I can't analyze the timing with oscilloscope ... yet http://forums.parallax.com/images/smilies/smile.gif

CJ
02-14-2007, 12:44 AM
there really isn't any need for an oscilloscope, you can use the propeller to measure itself,
to get the value to subtract from future measurements use two assignment operators in a row

start_time := cnt
end_time := cnt
time := end_time - start_time

then just tuck any expression you want to time inside the two to get the number of clock cycles for that expression, you could even
do a batch of them and have it display on a tv or monitor very easily with tv/vga text.spin

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who says you have to have knowledge to use it?

I've killed a fly with my bare mind.

Paul Baker
02-14-2007, 02:46 AM
Excellent·point CJ.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker (mailto:pbaker@parallax.com)
Propeller Applications Engineer
[/url][url=http://www.parallax.com] (http://www.parallax.com)
Parallax, Inc. (http://www.parallax.com)

Jamesx
02-14-2007, 11:09 PM
Regarding Paul's comments from a couple of days ago:


Paul said...

Anyone wanting to investigate the relative execution speed of various spin commands can use the same procedure Tracy Allen used on measuring the execution of PBASIC instructions on the Basic Stamp.

Take an oscilloscope and set it up in positive edge trigger mode where the trigger level is Vdd/2. Setup a simple program where two consecutive instructions setting a pin high followed by setting a bit low are executed then measure the pulse width and record the value. Now place an instruction between those two instructions and measure the pulse width. Take the second measure and subtract from it the first measure and you now have the length of time it took to execute the instruction under test. This procedure can be used to measure the length of time it takes to execute any Spin instruction.



I tried a similar test a couple of weeks ago, and got 10 microseconds for a single simple line of spin that transitioned a pin. (I didn't try adding another line of code to see how much additional time that added)

Jim C

CJ
02-14-2007, 11:55 PM
that falls about in line with the values I am getting from this little program I cobbled together for counting the clock cycles and displaying them on a TV, gotta love modular code objects!!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who says you have to have knowledge to use it?

I've killed a fly with my bare mind.