29-bit Photon Computer (LightPC)

  • mark2222
    26th Jun 2014 Member 12 Permalink

     

    LightPC is a 15-register WiFi-less 0.6 Hz 29-bit processor featuring a two-frame-per-bit adder, 1.8 KB of RAM and a pre-packaged screen, display, pseudorandom number generator and clock. It is probably the first processor in Powder Toy to use photon-filter technology, and probably holds the title of most colourful Powder Toy processor as of now. Any amount of copying is allowed, even copying wholesale, as long as the credit is given to my original save in a clear fashion.

     

    The LightPC save may be laggy, but only due to the large number of particles used for the touchscreen and hexadecimal display. Using LightPC for other applications should allow a full 60 fps frame rate.

     

    You can program LightPC on any platform that supports Python 3, but syntax highlighting is only available for Windows. Details on how to set up the programming environment can be found in the manual.

     

    This thread holds the cross-compiler, manual, example programs (including the demo program and TPT - yes, TPT in TPT!) and all the resources required to create programs for or to modify LightPC. The attached zip file also contains a bonus timelapse GIF of LightPC's creation, because timelapses are awesome.

     

    Access the zip file here: LightPC Resources

     

    The manual is useful not only if you wish to program for LightPC, but also if you would like to know how it works, are having technical issues using it or would like to modify, fix or copy components from LightPC.

     

    If you are afraid of coding in assembly, here is an example of LightPC "assembly code" to consider (prints "Hello World!"):

     

    //The Hello World program in high-level LightASM.
    //Should display "Hello World" on the screen.
    define RETREG r14
    define screen 0

    func dev(devid,arg1,arg2){
        DEV devid arg1 arg2
        return RETREG
    }

    func readram(dataid){
        var res
        LOAD res dataid
        return res
    }

    data helloworld={
    001010111010001000010000b,
    001010100010001000101000b,
    001110111010001000101000b,
    001010100010001000101000b,
    001010111011101110010000b,
    000000000000000000000000b,
    100010010011001000110010b,
    100010101010101000101010b,
    101010101011001000101010b,
    101010101010101000101000b,
    010100010010101110110010b
    }

    var cline=1
    var scrcont=helloworld
    do{
        @dev(screen,cline,@readram(scrcont))
        cline++
        scrcont++
    } while(cline~=12)

     

    Of course, if you read the manual, you'd find that the code is much more low-level than it first appears :)

     

    Bugs:

    • LightPC very rarely suffers from a Heisenbug (possibly with incrementation), but as Heisenbugs are, I can't seem to find the problem. Fixed, I think. There was a timing issue with the incrementor, which means that the processor speed measurements may contain mistakes.
    Edited once by mark2222. Last: 26th Jun 2014
  • boxmein
    26th Jun 2014 Former Staff 0 Permalink
    I've got to say. This is amazing. Whoa.
    I've pasted your assembler online here for all to see without the zipfile:
    http://bpaste.net/show/JadpX1HWJDpnTXTZGya6/
  • mark2222
    26th Jun 2014 Member 0 Permalink

    @boxmein (View Post)

    Haha hope that doesn't spark off the easiest bug-hunt in history ><

     

    I suppose the timelapse is more suited for public viewing, so here it is outside the zipfile:

    http://i.imgur.com/TioWqVA.gif

  • PTuniverse
    26th Jun 2014 Member 0 Permalink

    Now someone create a Rule 110 program.

  • mark2222
    26th Jun 2014 Member 0 Permalink

    @PTuniverse (View Post)

     For your pleasure.

     

    var cline=0,cnum=1
    do{
        DEV 0 cline cnum
        {
            var lbit=cnum>>1,rbit=cnum<<1
            cnum=(lbit~&(cnum|rbit))|(lbit&(cnum^rbit))
        }
        cline++
        if(cline==24) cline=0
    } while(1)

    Edited once by mark2222. Last: 26th Jun 2014
  • mecha-man
    26th Jun 2014 Member 2 Permalink

    I noticed that in the Excel spreadsheets you were missing a couple of TPT "computers".

  • mark2222
    27th Jun 2014 Member 0 Permalink

    @mecha-man (View Post)

     

    The list of processors was not meant to be exhaustive. There are a lot of processors on Powder Toy and I don't have time to review all of them. In the list, I included some old processors to illustrate time and technological progress (for the fun of it) and some of the most modern processors for the sake of comparison.

     

    If you would like to add to the list, feel free to do so. The methodology is described in the manual.

  • massey101
    1st Jul 2014 Member 0 Permalink

    Great I only just finished writing an OS for A_Real_Genius's cpu. (It was easy because of the lack of direct register use). Seems like the hardware advancements are moving faster and faster. Moore's law anyone?

  • mark2222
    2nd Jul 2014 Member 0 Permalink

    @massey101 (View Post)

     

    o_O An OS with so little memory? What does it do?

  • mniip
    2nd Jul 2014 Developer 0 Permalink
    @mark2222 (View Post)
    Wow. I am impressed.
    Someone record this, mniip is impressed

    You obviously had experience in HDLs before?
    Also that is some compiler-grade code right here... (Your MSVC-biased C++ though)
    Edited once by mniip. Last: 2nd Jul 2014