Shop OBEX P1 Docs P2 Docs Learn Events
SPIN instruction length — Parallax Forums

SPIN instruction length

HGPLHGPL Posts: 15
edited 2007-02-14 15:55 in Propeller 1
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!

Comments

  • parskoparsko Posts: 501
    edited 2007-02-11 15:01
    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 GreenMike Green Posts: 23,101
    edited 2007-02-11 15:47
    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 BakerPaul Baker Posts: 6,351
    edited 2007-02-11 20:57
    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
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 2/11/2007 9:02:10 PM GMT
  • HGPLHGPL Posts: 15
    edited 2007-02-11 21:36
    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 smile.gif
  • CJCJ Posts: 470
    edited 2007-02-13 16:44
    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 BakerPaul Baker Posts: 6,351
    edited 2007-02-13 18:46
    Excellent·point CJ.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • JamesxJamesx Posts: 132
    edited 2007-02-14 15:09
    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
  • CJCJ Posts: 470
    edited 2007-02-14 15:55
    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.
Sign In or Register to comment.