Shop OBEX P1 Docs P2 Docs Learn Events
P1 Mandelbrot Fractal Program ported to P2 PASM — Parallax Forums

P1 Mandelbrot Fractal Program ported to P2 PASM

potatoheadpotatohead Posts: 10,261
edited 2014-03-23 00:39 in Propeller 2
I saw Chip's fun full-color brain wash capable spiral and it make me want to render some fractals with the new math instructions. It wasn't hard, and they are really fast without any real thought at optimizing things. Hanno put one here, and that's what I used.

Honestly, I got stuck on stupid mistakes I miss when I don't have the syntax highlighting I'm so used to more than I did the math part of things. What a sweet turn of events! On P1, complex math is a project in and of itself. On P2, one can more or less parse the expression and type it right in.

The attached program runs on a DE2, composite NTSC display. You don't need the SDRAM capable image to run it. HUB RAM only on this version.

It fires off a monitor on pins 3 & 5, so you can capture the pictures if you want to. Change this, if you want the default pins. There are some basic parameters at the bottom. I was wondering, do the buttons and switches still work on the DE2 with the addition of the SDRAM, SD CARD and DACS?

Load it with Pnut. The driver is 256x192 NTSC 16 bit color.
720 x 540 - 169K
720 x 540 - 267K
720 x 540 - 297K
720 x 540 - 244K

Comments

  • nutsonnutson Posts: 242
    edited 2013-04-14 05:12
    Fantastic, I am really enyoing this P2 discovery tour. Terasic must be growing like hell with all thes P2 followers. How about a big discount??
  • cgraceycgracey Posts: 14,206
    edited 2013-04-14 09:09
    Really neat, Doug!
  • BaggersBaggers Posts: 3,019
    edited 2013-04-14 09:17
    That's ace Doug :)

    Chip, the new features on the Prop2 are awesome!
  • cgraceycgracey Posts: 14,206
    edited 2013-04-14 09:21
    Baggers wrote: »
    That's ace Doug :)

    Chip, the new features on the Prop2 are awesome!

    What I'm really looking forward to is live sensor/feedback visualization, but we kind of need the real chip for that. I think it will be fun to compose custom instruments for all kinds of real-world phenomena. It should bridge the gap between the PC's graphics capabilities and a DSP's real-time response.
  • BaggersBaggers Posts: 3,019
    edited 2013-04-14 09:34
    That's great Chip, can't wait to see all the amazing things that will get done with this! Exciting times ahead :)
  • potatoheadpotatohead Posts: 10,261
    edited 2013-04-14 12:33
    Me too. That is a really fun area of electronics to explore. I see some leftover nops and stuff in that fractal code. I'll post up a cleaner one later today.

    Edit: We can make a Propller Tricorder. :)
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2013-04-15 18:21
    How fast is it? Could you add a mouse driver and port (at least the function of) XaoS?

    Simple would be left-click to zoom, right-click to toggle Julia mode, using the current mouse position as the seed value.
  • potatoheadpotatohead Posts: 10,261
    edited 2013-04-15 18:33
    At 20 iterations, one compute COG, it fills the full Mandlebrot view in about a second, maybe two. That's a tough case, because there are a lot of max iterations on that one.

    I may multi-cog this tonight. One COG running 200 or so iterations can do the screen in a few seconds, maybe 5, depending on the region being rendered.
  • Heater.Heater. Posts: 21,230
    edited 2013-04-16 00:00
    Sounds like you are approaching the speeds of my old x86 asm Mandlebrot set which used 32 bit arithmetic on a Compaq 386 running the otherwise 16 bit DOS. Ah, those were the days. Oh, looks like they still are the days for Potatohead:)

    Can't wait to get hold a PII....
  • potatoheadpotatohead Posts: 10,261
    edited 2013-04-16 07:47
    Yeah, seeing the real chip will be great. We can then learn all about how the pins really work. Yeah, these things are a nice lark once in a while. Kind of trivial on a P2 now. Until I get some means of interaction hooked up, there is no point in doing multi-cog. Maybe revisit this then.
  • Bill HenningBill Henning Posts: 6,445
    edited 2013-04-16 11:29
    potatohead,

    Nice work! I finally got around to hooking up an NTSC monitor again, and the first thing I tried was your Mandelbrot demo - looks great.
  • Bill HenningBill Henning Posts: 6,445
    edited 2013-04-16 12:21
    Here is a 720p driver version...
  • potatoheadpotatohead Posts: 10,261
    edited 2013-04-16 12:50
    Nice Bill! I can't wait to run it. I was on a capture card when I did the first one. Thanks for this. HDTV was to be the next one. :)
  • cgraceycgracey Posts: 14,206
    edited 2013-04-16 13:00
    Neat, Bill!

    Something like this could be shown using the STR8_RGBI8 video mode to get your byte rate down to 74.25MHz, which would work with the SDRAM driver, no problem. Then, you'd have full 720p resolution and 32 shades of each 8 basic colors. Do you want to try it?
  • Bill HenningBill Henning Posts: 6,445
    edited 2013-04-16 13:34
    Thanks - and you are most welcome.

    XGA version is coming up shortly...
    potatohead wrote: »
    Nice Bill! I can't wait to run it. I was on a capture card when I did the first one. Thanks for this. HDTV was to be the next one. :)
  • Bill HenningBill Henning Posts: 6,445
    edited 2013-04-16 13:41
    Thanks Chip!

    I've been meaning to try out the STR8_RGBI8 mode...

    First, I'll make a 1024x768 VGA version (with 256x192 bitmap) (done, see below)

    Then I plan to start experimenting with the SDRAM

    Following that... high-resolution here we come!

    The nice thing about the fractal code is that I can construct a scan line in the hub, then burst transfer it - I have not yet written "read/write long/word/byte" routines... I need to experiment with your driver before I can make those.
    cgracey wrote: »
    Neat, Bill!

    Something like this could be shown using the STR8_RGBI8 video mode to get your byte rate down to 74.25MHz, which would work with the SDRAM driver, no problem. Then, you'd have full 720p resolution and 32 shades of each 8 basic colors. Do you want to try it?
  • Bill HenningBill Henning Posts: 6,445
    edited 2013-04-16 13:49
    Here is the XGA vesion (1024x768 60Hz signalling, 256x192 pixels)
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-16 14:05
    Hi Bill.

    Can You made 800x600 one ?

    Here is the XGA vesion (1024x768 60Hz signalling, 256x192 pixels)
  • Bill HenningBill Henning Posts: 6,445
    edited 2013-04-16 14:38
    No problem - 800x600 is a good target for an SDRAM frame buffer.

    800 * 600 * 2 * 60 = 57.6MB/sec, well under the 107MB/sec bandwidth limit on the DE2
    Sapieha wrote: »
    Hi Bill.

    Can You made 800x600 one ?
  • potatoheadpotatohead Posts: 10,261
    edited 2013-04-16 14:38
    Dang it! I have SDRAM driver time envy right now Bill! Can't play until the weekend because I don't want to fly with the DE2... Have a good time for me.

    Well if you don't end up multi-cogging it, I will later. :). On that note, are the buttons and switches still functional with the latest DE2 image?

    800x600 is a good compute speed target too. With 2 cogs, it should be able to do a screen in a few seconds, maybe 10 at a couple hundred iterations...
  • Bill HenningBill Henning Posts: 6,445
    edited 2013-04-16 17:26
    Done!

    Please find the 800x600 driver, with fractal demo, attached.

    Update: Added 800x480 driver with fractal demo - note, I could not find any official VESA numbers for this, only a screenshot of a PowerStrip mode line.
    Sapieha wrote: »
    Hi Bill.

    Can You made 800x600 one ?
  • Bill HenningBill Henning Posts: 6,445
    edited 2013-04-16 17:28
    :)

    I think I'll have some SDRAM drivers running before the weekend - depends on how much "play" time I can free up.

    I don't think I'll have time to multi-cog the fractal engine though... so that will probably have to wait for you.
    potatohead wrote: »
    Dang it! I have SDRAM driver time envy right now Bill! Can't play until the weekend because I don't want to fly with the DE2... Have a good time for me.

    Well if you don't end up multi-cogging it, I will later. :). On that note, are the buttons and switches still functional with the latest DE2 image?

    800x600 is a good compute speed target too. With 2 cogs, it should be able to do a screen in a few seconds, maybe 10 at a couple hundred iterations...
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-17 03:19
    Can someone please post a video. I am dying to see the demos but don't dare to get them running on my DE0 because I am busy with other P2 code.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-17 03:51
    Hi Cluso.

    PIC in attachment.

    Cluso99 wrote: »
    Can someone please post a video. I am dying to see the demos but don't dare to get them running on my DE0 because I am busy with other P2 code.
    100_0242.jpg
    1024 x 768 - 116K
  • potatoheadpotatohead Posts: 10,261
    edited 2014-03-09 12:54
    I spent a little time with this yesterday to make it interactive.

    Key1 = mode, which is displayed as little dashes right at the top of the screen. From left to right: scale, vpan, hpan, iterations
    key2, 3 = + and - by mode

    sw0 up = redraw on button action
    sw0 down = no redraw

    TV version attached. My VGA is on loan right now. I may tinker with this on the next FPGA image to add modes, tasks, resolution, Component video, etc...

    Use F10. It's a small program, simple.
  • ozpropdevozpropdev Posts: 2,793
    edited 2014-03-09 23:29
    Hi Potatohead
    Looks great!

    You can get some more performance by changing your MUL32 instructions to MUL.
    Saves ~14 clocks per multiply. :)
    Brian
  • potatoheadpotatohead Posts: 10,261
    edited 2014-03-09 23:33
    Nice! I saw that discussion, but did not take the time to change things out. IMHO, the fun thing to get done is more resolution in a byte / color mode + more COGS & precision.

    This also shows off how cool tasks are going to be. Refactoring this to employ tasks would result in a cleaner, more efficient program.
  • Ym2413aYm2413a Posts: 630
    edited 2014-03-12 17:46
    Great work Doug!
    Can't wait to try it out. : ]

    --Andrew.
  • potatoheadpotatohead Posts: 10,261
    edited 2014-03-23 00:39
Sign In or Register to comment.