Shop OBEX P1 Docs P2 Docs Learn Events
Is there a simulator available for the Propeller? — Parallax Forums

Is there a simulator available for the Propeller?

sstandfastsstandfast Posts: 39
edited 2008-08-31 08:51 in Propeller 1
Hello,

Well it has happened, I have finally written a program that is complex enough I can't debug it without being able to "see" what is going on.· Not that it was too terribly difficult to do since I've only been playing with the Propeller off and on now for just under a month.· I am just now starting to get·a feel for the chip although I must say it is a much bigger leap from the PICMicro's than I first thought it was going to be.· One tool that would be of great assistance would be a simulator.· I have found pPropellerSim by Ale but I haven't quite got the hang of it yet and it appears to only be capable of supporting one cog.··Add to it the fact that it can only shows variables as their physical addresses with no ability to map which variable is which from code at compile time makes it very difficult to use.· Especially for someone who is still trying to figure out the in's and out's of the Propeller.

I know I'm asking alot, but it would be really nice to have a debugging toolset similar MPLAB SIM for the PICmicro's.· Something that you can have your code open in one window with a register map in a second window and the ability to step through your code line by line and watch how the registers change.· Perhaps as I get more experience with the Propeller I won't need a simulator anymore but for right now, it would be a big help.

In the mean time, I suppose I could start a second thread and post the code that doesn't quite work as expected and see if anyone can help me.

Thanks for putting up with my rantings.
Shawn

Comments

  • AribaAriba Posts: 2,690
    edited 2008-08-23 01:11
    sstandfast said...
    ... Something that you can have your code open in one window with a register map in a second window and the ability to step through your code line by line and watch how the registers change...

    PASD can do this, but you can debug only 1 cog at a time (and only Assembly), but it is a realtime emulator, not a simulator:
    www.insonix.ch/propeller/prop_pasd.html.

    And then there is another simulator, called GEAR. Search for it with 'search.parallax.com'.

    Andy
  • sstandfastsstandfast Posts: 39
    edited 2008-08-23 01:25
    Thanks for the quick reply! I had searched the forums using the forum search feature for this before I posted but only turned up Ale's pPropellerSim. I will check both of these out.

    Shawn
  • mirrormirror Posts: 322
    edited 2008-08-23 01:28
    Gear is an emulator for the Propeller - it can be found at:

    http://forums.parallax.com/showthread.php?p=701256
  • AleAle Posts: 2,363
    edited 2008-08-23 09:48
    [noparse][[/noparse]quote]

    I have found pPropellerSim by Ale but I haven't quite got the hang of it yet and it appears to only be capable of supporting one cog. Add to it the fact that it can only shows variables as their physical addresses with no ability to map which variable is which from code at compile time makes it very difficult to use. Especially for someone who is still trying to figure out the in's and out's of the Propeller.


    If you use the built-in editor and compile your code using the built-in compiler you will have all your symbols loaded at the right positions. Can you explain what did not work for you and what you did ?. I always look for ways of improving it.
  • sstandfastsstandfast Posts: 39
    edited 2008-08-31 02:12
    "If you use the built-in editor and compile your code using the built-in compiler you will have all your symbols loaded at the right positions. Can you explain what did not work for you and what you did ?. I always look for ways of improving it."

    Thanks for that!· That does help at least decipher a little bit about what's going on.· But I am still having trouble with this simulator.· I am running an example program written by Mike Green that demonstrates indexing into a look-up table.· The code was found in the ASM tutorial "Sticky" on this forum.· Here is a link: http://forums.parallax.com/showthread.php?p=601870· The code is about 3/4 of the way down the page.· When I copied and pasted this code into pPropellerSim, at first I had a bear of a time getting it to compile.· I kept getting a "line 9: Too few arguments for directive(DAT)" error.· Removing the ORG 0 and moving the first line of assembly onto the same line as the DAT statement gave a slightly different error.· This time it said "Line 9: Argument(s) Missing".· It took probably 20 min. to figure out that the DAT directive was the problem.· It didn't need to be there.· Did I just miss that in the documentation somewhere?

    Deleting the DAT statement and altering the symbol name from "test" to "testa" to avoid conflict with the instruction of the same name I was able to get a successful compilation! Yea!· However, when the code was run in the simulator the results were not what was expected.· Attached is a screen shot of the simulator and it's contents.· Line 0 is label testa and contains mov ptr,#2 as expected.· Line 1 is call #look, also as expected.· Label Look is located at $00C and contains jmp #testa.· So basically all this program does is jump to "Look" where instead of executing it's code, it simply returns immediately.· What I expected to see this code do is jump to·"Look" which would then retrieve the third element from the look-up table, store that into variable "data" and then branch to an infinate idle loop.· This is definately not what I am seeing.· The symbol "data" remains 0 and the actual table look-up portion of the code is never executed.· I'm not sure if this is a problem with the simulator, Mike's code, or I just don't know what I'm doing.· The answer is probably the last one so if either you or Mike would be willing to lend some advise I'd greatly appreciate it.

    Thanks,

    Shawn
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-31 02:26
    If you compare my original routine with what you have, you'll see that they're not at all equivalent.
    What was the label "look_ret" is now being treated as "look" and the original "look" label is gone along
    with other labels like "table" and "mask". I don't know how things got that way, but maybe you should
    fix them. You can take the original program and stick an "x" in front of each label. For the labels starting
    with ":", use an "x" instead for the ":", then try to use the simulator on the new version and see what
    happens.
  • sstandfastsstandfast Posts: 39
    edited 2008-08-31 06:58
    Hi Mike,
    Thanks for the prompt reply.· Like I said earlier, all I did was copy and paste directly from your previous post.· The only changes I made were to remove the DAT ORG 0 line and add an "a" to label "test" so that the assembler did not confuse it with a command.· So I'm not sure how my code compiles so much differently than yours does.· Either I'm not doing something right or there is a problem somewhere else.
    I tried adding the "x's" to the front of all the labels as you suggested but that only changed the label names.· It had no effect on the generated code.· Just to make sure we are all on the same page, here is the code I am trying to simulate using pPropellerSim.
    '' Here's a simple example of table lookup in assembly.
    '' This particular example takes a table index in "ptr"
    '' and sets the "data" to the word value from the table.
    '' There's no range checking.  If you want long values,
    '' just eliminate the shifts and masks (*).  You can use
    '' the same kind of logic for byte values.
    testa    mov   ptr,#2        ' for an example, get third value
             call  #look            ' note table indices are 0 to n-1
    :stop    jmp   #:stop        ' no checking for out of range
    look     mov    data,ptr      ' ptr is a table index (0 to n-1)
             shr   data,#1       ' divide input value by 2 to get (*)
             add   data,#table    '   long word index, add table address
             movs  :inline,data   ' have to use instruction modification
             nop                        ' need pause here for pipelining
    :inline  mov    data,0-0         ' get long value from table
             test   ptr,#1   wz     ' do we want odd or even half  (*)
        if_z and    data,mask       ' if even, take lower 16 bits (*)
        if_nz shr    data,#16         ' if odd, take upper 16 bits  (*)
    look_ret ret
    table word    $0000
          word    $C0C1
          word    $C181
          word    $0140
          word    $C301
          word    $03C0
          word    $0280
    mask  long   $FFFF
    data  res     1
    ptr   res     1
    'Post Edited (Mike Green) : 8/23/2006 3:37:17 PM GMT
    
    

    This code moves #2 to ptr and then jumps to look_ret, which then immediately jumps back to testa.· For further clarification, here is the "x" modified code to make sure I understood you right Mike.
    '' Here's a simple example of table lookup in assembly.
    '' This particular example takes a table index in "ptr"
    '' and sets the "data" to the word value from the table.
    '' There's no range checking.  If you want long values,
    '' just eliminate the shifts and masks (*).  You can use
    '' the same kind of logic for byte values.
    xtesta    mov   ptr,#2        ' for an example, get third value
             call  #xlook            ' note table indices are 0 to n-1
    xstop    jmp   #xstop        ' no checking for out of range
    xlook     mov    data,ptr      ' ptr is a table index (0 to n-1)
             shr   data,#1       ' divide input value by 2 to get (*)
             add   data,#table    '   long word index, add table address
             movs  xinline,data   ' have to use instruction modification
             nop                        ' need pause here for pipelining
    xinline  mov    data,0-0         ' get long value from table
             test   ptr,#1   wz     ' do we want odd or even half  (*)
        if_z and    data,mask       ' if even, take lower 16 bits (*)
        if_nz shr    data,#16         ' if odd, take upper 16 bits  (*)
    xlook_ret ret
    table word    $0000
          word    $C0C1
          word    $C181
          word    $0140
          word    $C301
          word    $03C0
          word    $0280
    mask  long   $FFFF
    data  res     1
    ptr   res     1
    'Post Edited (Mike Green) : 8/23/2006 3:37:17 PM GMT
    
    

    ·Either version will produce the exact same results mentioned in my previous post.· Any thoughts?

    Thanks for your help,
    Shawn

    P.S.· Mike, I am having a bit of a hard time understanding what exactally these lines are doing in your example.· Could you please clairify them for me?
             movs  :inline,data   ' have to use instruction modification
             nop                        ' need pause here for pipelining
    :inline  mov    data,0-0         ' get long value from tabl
    
     
    


    Up to this point I follow what is going on.· You have added the offset or index to the base address of the look-up table.· You retrieved the base address of the look-up table by adding the "#" modifier to the symbol, which returned the address pointer and not the contents of table.· However, I am stumped by what the movs :inline, data does.· The way I understand it, you are·moving bits 0..8 of the 32-bit variable "data" to the first entry of :inline, which is another mov instruction.· This does what exactally?· Next, there is a NOP which the comments state is for pipelining?· My first thoughts was that it was to synchronize the COG with the HUB access window but there are no HUB statements in this code so that doesn't make sense.· Could you please explain what this "Pipelining" is that you speak of?· Also, do you think you could explain what the 0-0 is doing in this·code and why it couldn't have simply been :inline mov data,0.· Since the NR, WZ, WC effects are not specified it's not to toggle the Z or C flags.· Therefore, I am confused by this as well.

    I appreciate any help you can provide.

    Thanks,
    Shawn
  • AribaAriba Posts: 2,690
    edited 2008-08-31 08:51
    Here is your Testcode modified to run with PASD:
    {{ PASD Test }}
    
    CON
      _clkmode        = xtal1  + pll16x
      _xinfreq        = 5_000_000
    
    VAR
      long  Cog
    
    OBJ
      dbg   :       "PASDebug"                '<---- Add for Debugger 
    
    PUB main
    
      Cog := cognew(@entry, 0) + 1
      dbg.start(31,30,@entry)                 '<---- Add for Debugger
    
    DAT
    
                            org     0
    entry
    
    '  --------- Debugger Kernel add this at Entry (Addr 0) ---------
       long $34FC1202,$6CE81201,$83C120B,$8BC0E0A,$E87C0E03,$8BC0E0A
       long $EC7C0E05,$A0BC1207,$5C7C0003,$5C7C0003,$7FFC,$7FF8
    '  -------------------------------------------------------------- 
    
    '' Here's a simple example of table lookup in assembly.
    '' This particular example takes a table index in "ptr"
    '' and sets the "data" to the word value from the table.
    '' There's no range checking.  If you want long values,
    '' just eliminate the shifts and masks (*).  You can use
    '' the same kind of logic for byte values.
    
    testa    mov   ptr,#2        ' for an example, get third value
             call  #look            ' note table indices are 0 to n-1
    :stop    jmp   #:stop        ' no checking for out of range
    
    look     mov    data,ptr      ' ptr is a table index (0 to n-1)
             shr   data,#1       ' divide input value by 2 to get (*)
             add   data,#table    '   long word index, add table address
             movs  :inline,data   ' have to use instruction modification
             nop                        ' need pause here for pipelining
    :inline  mov    data,0-0         ' get long value from table
             test   ptr,#1   wz     ' do we want odd or even half  (*)
        if_z and    data,mask       ' if even, take lower 16 bits (*)
        if_nz shr    data,#16         ' if odd, take upper 16 bits  (*)
    look_ret ret
    
    table    word    $0000,$C0C1
             word    $C181,$0140
             word    $C301,$03C0
             word    $0280,0
    mask     long   $FFFF
    data     res     1
    ptr      res     1
             fit
    
    


    Just copy that in the PropTool press F10, then start PASD, set the right COM port, and press F2. Now you can single step thru the code, and watch the variables in the CogRAM viewer.

    About ' movs :inline,data ':
    this sets only the source field of the instruction at :inline to the value in data (bits 8..0). This field is set to 0-0 in the souce code, to indicate it will be modified. You can clearly see all the modifications with PASD.

    Andy
Sign In or Register to comment.