Fractal project with Papilio Duo

Larry McGovern

Recommended Posts

Thanks Jack!  It would be an honor to see this on the Gadget Factory blog.  This project was quite suitable for the Duo, since it makes use of the AVR chip for some of the basic math and input controls processing, and leaves the hard stuff to the FPGA.

Also, hats off to Hamster, whose own Mandelbrot project were the inspiration for this.  My project was not a copy of his (after all, my objective here was to learn), but I did learn quite a bit from his implementation on how to pipeline a project like this. 

I posted a few other details on the project on the YouTube post, but I suspect some of the readers here would be more interested.  Here is the bullet point description:

• The Atmega32U4 is used to process the analog joystick, buttons, and rotary encoder to set the cursor position, zoom, and color map.  This information is sent over to the FPGA via an SPI interface.
• The FPGA runs the 800x600 pixel fractal calculations at 200 MHz using the onboard DSP48s.
• The fractals are saved to SRAM, with each pixel stored as a 1 byte word.
• A set of selectable 12-bit color maps are stored using the FPGA BRAM.  I currently have over a dozen, and am planning on adding more color maps.
• An 800x600 pixel SVGA controller on the FPGA is used to send a 12-bit color image to the LCD.  I used the snap-off VGA wing from the LogicStart Shield.  The LCD was an inexpensive 7” screen purchased off eBay, typically used for Raspberry Pi projects.
• The case for this design was 3D printed, and custom designed just for this project.

Finally, the 3D case could be easily modified for a more general purpose Papilio Arcade.  The Papilio Duo drops right into it.  Perhaps I'll post the SketchUp file on Thingiverse if there is interest.

  • Like 1
Link to comment
Share on other sites

Man, this really makes me happy to see such an amazing use of the Papilio DUO! It seems like this is the perfect project to demonstrate what can be done. :)

I'd love to get a sketchup file of the case - I'd like to make myself one of these puppies for the office. I'm sure other people would love to have one of these too. If you have any interest in producing these I would give you the best discount we offer on the DUO so you can have some profit to work with when you make some of these. Just drop an email to and we can have an offline discussion.



Link to comment
Share on other sites

Hi Jack, thanks for your enthusiasm!  At my household, the reactions ranged from bafflement on why I had wasted so many hours doing this to "you need to get a real hobby"!  LOL!  Actually, my 11 year old enjoyed finding all sorts of crazy fractal patterns.  She keeps coming back to this little gadget for more.  It is strangely addictive, and one can get lost for long stretches of time exploring the Mandelbrot set.

I just posted the SketchUp and STL files on Thingiverse with a few instructions, in case anyone is interested:

Although my application was very specific, it is pretty easy to modify if someone wanted to have a different placement for the joystick and buttons.  I could see rotating the screen 90 deg, moving the joystick, and setting this up as an arcade. It is a very simple design, and I'm sure someone who designed consumer products for a living would find plenty wrong with it.  I'm not really interested in mass producing these, but might be persuaded to print off one or two for a few interested folks for the price of the filament (a few dollars) and shipping.  (Or if you're interested, maybe in exchange for a discount on one of your new Nanos when it is ready.  I'll definitely need to pick up one of those!)  And I notice that Thingiverse has a new "Order this printed" button, convenient for those without access to their own 3D printer.

Link to comment
Share on other sites

  • 3 months later...

Hi Jack,

I noticed that you put this project on your blog back in mid-July.  Thanks for creating it on my behalf! If possible, could you replace the picture with an image and link to my YouTube video? Link:  The current picture there is not from my project, and I would hate for the author of that picture to think that I had taken credit for their work!

Also, I am certainly happy to share my VHDL code, though I’m not sure it’s best to learn VHDL from me, clearly a novice. I approached this project as a learning opportunity, and my best recommendation is for others to do the same and create as much from scratch as they can.  I can certainly provide a link to the source code if you think it would enhance the blog entry.

Again, thanks for putting that up there.  Also (on a different topic altogether), looking forward to the Papillio Nano.  I'll definitely be ordering one of those when they are ready.

Link to comment
Share on other sites

  • 9 months later...


Thanks for this excellent project.

I'm trying to rebuild from the soures you have posted on github:

This is so I can use the Classic Computing shield.

To do this I need to re-create the FIFO and DCM cores in Core Generator (as you haven't checked in any implementation of these).

What depth is the FIFO?

What are the two clocks (clk_200 and clk_m)? From the comments I'm guessing 200MHz for both.

I'm sure I'll have more questions if that is OK.


Link to comment
Share on other sites

Hi Dave,

I'm glad you found the source code on github!  It's been more than a year since I put this together, so I had to dust off the old files.  You are correct, you will need to use the Core Generator to create the FIFO and clock manager.  I used a standard FIFO with 28b x 1024 depth.  I also used the clocking wizard to create 200 MHz and 100 MHz clocks from the 32 MHz input.  But if you look inside MandlebrotTop.vhd, you'll see that the 100 MHz output from clk_mgr does not get used.  Instead, I set both clk_200 and clk_m to the 200 MHz clock.  The 100 MHz is a holdover from a previous iteration of my code, and certainly could have been cleaned up. 

Let me know if you get this working, and if you spot any improvements.  This was one of my first VHDL projects, so I'm sure the code is less than perfect.

Link to comment
Share on other sites

Thanks Larry,

I've got it mostly working now, with some minor tweaks for using the buttons on the classic computing shield:

The only issue I'm seeing is that at the most zoomed out view there are some corruptions to the image in the cornest, which look like come pixels not being updated (i.e. if you zoom in and then zoom out you see some ghosting of the image from the previous zoom level). Hitting the redraw button multiple times causes these to be eventually corrected. I haven't investigated the cause of this yet. I did notice the design didn't seem to meet timing @ 200MHz, so it's possible this is a factor.

Is this something you have ever seen?



Link to comment
Share on other sites

You got it together, that's terrific!!  Photos?

Yes, I had exactly the same problem.  There are some corrupt pixels at the maximum zoom level, which disappear after pressing the refresh button a few times.  I didn't see that issue at any other zoom level.  And yes, the timing report did show there was a path that didn't meet 200 MHz timing, which I bet is the cause of the issue.  I did spend a little time trying to hunt that one down, but eventually moved on because i was already pretty happy with the result.  If you happen to find a fix for the issue, please let me know. 

Link to comment
Share on other sites

Another update.

I've now returned to Mike Field's original design, and done some work to port this to the Papilio Duo + Classic Computing shield. The main difference from the Papilio Plus is the memory is 512KBx8 rather than 256KBx16. This entailed a re-write of the memory controller to deal with half the memory bandwidth, but nothing else. I also added in the colour maps from Larry's Mandelbrot-Explorer.

This is working very nicely indeed, panning is super smooth, and multiple colour maps is really funky. The picture below doesn't really do it justice!

If anyone want to try this out, the source is it github, and I'm happy to post a .bit file on request:



  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.