P2 Simulator

Dave HeinDave Hein Posts: 5,088
edited July 2015 in Propeller 2 Vote Up2Vote Down
I've updated spinsim with the information contained in the July 14 P2 document that Chip posted.  This version of spinsim supports most of the P2 instructions that match instructions in the P1.  Most of the new non-P1 P2 instructions are not supported yet, but I will implement them as more information becomes available about them.
In addition to spinsim, the attached zipfile contains a utility called qasm that converts PASM instructions to DAT LONG values.  The resulting file can then be compiled by an existing P1 compiler, such as the Prop Tool or BST.  The zipfile also contains a P2 version of the pfth Forth interpreter.  Windows executables of spinsim and qasm are included.  Executables for other platforms need to be built from the source files.  Read the readme.txt files for more information.

Comments

  • 14 Comments sorted by Date Added Votes
  • Wow! Quite a package to release!

    I'll need to grab it and build it.

    Thanks!
    MOV OUTA, PEACE <div>Rick </div><div>"I've stopped using programming languages with Garbage Collection, they keep deleting my source code!!"</div>
  • Dave HeinDave Hein Posts: 5,088
    edited November 2015 Vote Up0Vote Down
    I've updated spinsim to the latest P2 spec that Chip posted on November 9th. This version supports most of the P2 instructions except for the following:
    setbyts movbyts msgin   msgout  xzero   xinit   xcont   qfrac
    qvector qrotate clkset  setdacs setxfrq getxcos getxsin sethlk
    setbrk  setcy   setci   setcq   setcfrq setcmod
    

    This version will run binary files produced by the PNut assembler, which is included with Chip's FPGA updates. You can generate a binary file under PNut without being attached to an FPGA board by typing Ctrl-M to switch to the list view, and then typing Ctrl-M again to return back to the editor mode.

    As in previous releases, a Windows executable for spinsim is included. Executables for other platforms need to be built using the makefile. Read the readme.txt file for more information.
  • Dave,

    This is cool!

    One question (so far), in the example below, I assume the first group of numbers is the CNT value, should that reset with a REBOOT command? I'm not sure how the hardware actually operates...it may only zero out when power is applied but I thought a reset would go back to 0.
    Cog 0: 00000021 0003 f467f603                setb     1fb, #003, cram[1fb] = f
    
    Cog 0: 00000022 0004 fd60381a F              getct    01c,  01a
    
    Cog 0: 00000023 0004 fd60381a                getct    01c,  01a, cram[1c] = 23
    
    Cog 0: 00000024 0005 fa803819 F              addct1   01c,  019
    
    DEBUG> reboot
    Cog 0: 00000025 0000 00000000 F              nop      000,  000
    
    Cog 0: 00000026 0000 00000000 I              nop      000,  000
    
    Cog 0: 00000027 0000 f467f600 F              setb     1fb, #000
    
    Cog 0: 00000028 0000 f467f600                setb     1fb, #000, cram[1fb] = 1
    
    DEBUG>
    

    Now all we need is some simulated LEDs! :)

    Thanks for sharing this...it should provide much distraction and aid!
    MOV OUTA, PEACE <div>Rick </div><div>"I've stopped using programming languages with Garbage Collection, they keep deleting my source code!!"</div>
  • Nice work Dave! :)
    BTW not sure if MOVBYTS and SETBYTS are missing because of lack of docs but here's a quick outline.

    SETBYTS simply copues the lower 8 bits of the S reg into all the byte positions of the Dreg.
    MOVBYTS copies the bytes in D reg in the order specified in the S reg.
    for example
        movbyts reg1,#%%0123
    
    does a endian swap of the bytes in reg1.
    Hope this helps.
    Cheers
    Brian
    Melbourne, Australia
  • Hi Dave,

    Did you follow any particular reference for understanding the instructions?

    The opcode list is really overwhelming. I'm sure there is a "fun subset" hiding there somewhere.

    Not having a simple reference is a great barrier to me. I like Rick's google doc - maybe that can be expanded.

    Forgive me, but I abandoned the intravenous information forum feeding habit long ago (withdrawl was worse than quitting cigarettes and coffee), and haven't even tried to keep up. Hopefully I can remain distant enough so that this thing doesn't consume me again. I did go back to coffee, but I'll never smoke again.

    Your work always piques my interest, and I have applications in mind for the new chip, so I need to be in touch with it a little. I just wish Chip's infinite tinkering would stop.
  • Dave HeinDave Hein Posts: 5,088
    edited November 2015 Vote Up0Vote Down
    @mindrobots, I believe the system counter does not reset on a reboot, but I'll have to check it against the FPGA to see what it does.

    @ozpropdev, thanks for the information on MOVBYTS and SETBYTS. I'll implement them when I have a chance.

    @jazzed, I used the instructions_xx.txt document that Chip includes with his FPGA updates, and also the Google docs document that he maintains. I also used Rick's google doc. However, for some of the instructions I had to resort to searching the P2 forum and study example code.

    EDIT: There are also several instructions where I just used my best guess at how they work. Some of the cordic instructions are implemented using C functions, such as log and exp. I currently don't simulate the cordic pipeline.
  • jazzed wrote: »
    Hi Dave,

    Did you follow any particular reference for understanding the instructions?

    The opcode list is really overwhelming. I'm sure there is a "fun subset" hiding there somewhere.

    Not having a simple reference is a great barrier to me. I like Rick's google doc - maybe that can be expanded.

    Forgive me, but I abandoned the intravenous information forum feeding habit long ago (withdrawl was worse than quitting cigarettes and coffee), and haven't even tried to keep up. Hopefully I can remain distant enough so that this thing doesn't consume me again. I did go back to coffee, but I'll never smoke again.

    Your work always piques my interest, and I have applications in mind for the new chip, so I need to be in touch with it a little. I just wish Chip's infinite tinkering would stop.

    Steve!

    We are almost there. The only plans I have left are to see about putting the pixel mixer instructions from P2-Hot in, and then getting the smartpin designed. Neither is too complex.

    A lot of the tinkering comes from using what we've already got and discovering hitch-ups in the git-along that need releasing.

    We're very close, anyway.
  • Yes ... come tinker a little .. you might like it. :crazy:
    "Since 1978, the cost of textbooks has risen 812%, outpacing even the cost of medical services and new housing."
  • This update makes spinsim compatible with Chip's November 20th update to PNut. It also fixes some problems and adds support for a few more instructions. The following changes were made.

    - Fixed a problem with the "-l" option in the P1 mode
    - Added support for the SETBYTS and MOVBYTS instructions
    - Added support for the QROTATE, QFRACT and QVECTOR instructions
    - Added wait logic for the GETQX and GETQY instructions
    - Implemented the SETHLK instruction and the associated code for handling LOCK interrupts
    - Fixed a problem with the "JMP S" instruction
    - Fixed several problems with the PTRA/PTRB logic.
  • This update is compatible with the November 25th version of PNut. It also fixes the following problems:

    Fixed the REP instruction
    Fixed multi-long RDLONG and WRLONG preceded by a SETQ in the hubexec mode
    Fixed the ALTS, ALTD, ALTR and ALTI instructions
    Fixed the "PAR" value passed by COGINIT when preceded with a SETQ
    Fixed the CALLD instruction when calling from cog memory to cog memory

  • Here's an update that fixes a problem I found with P2 binaries that were larger than 32K.
  • AleAle Posts: 2,272
    edited May 2016 Vote Up0Vote Down
    Hei Dave,

    How up-to-date is spinsim ? I'm not really interesting (at this point) in smart pins and such, but more on the normal opcodes for arithmetic and memory access...
  • It supports the instruction set of the November 25th FPGA image. I haven't closely followed the P2 work since then, but I don't think the core instruction set has changed since then.
  • AleAle Posts: 2,272
    That looks very good ! Thanks, I'll see what I can do :)
Sign In or Register to comment.