FPGA Mandelbrot With Code!

A place where you can keep others updated about your NES-related projects through screenshots, videos or information in general.

Moderator: Moderators

Post Reply
User avatar
kevtris
Posts: 504
Joined: Sat Oct 29, 2005 2:09 am
Location: Indianapolis
Contact:

FPGA Mandelbrot With Code!

Post by kevtris » Tue Feb 15, 2011 10:45 am

Well, it's not entirely NES related, but I thought I'd post a bit about this anyways since there might be some interested in it.

A few weeks ago, I created an FPGA mandelbrot set / julia set rendering engine on the FPGA. It produces real time sets which you can zoom and pan via an NES or SNES controller. I have a video of it in action here:

http://www.youtube.com/watch?v=KWmxb-9vjyA

The thing uses two verilog files; a "rendering core" which is mandelbrot.v, and the main controller which coordinates the cores and ouputs pixels which is video.v.

And to keep it somewhat NES related, it uses 6502 code to calculate the coordinates and step size. My arbitrary bit size math functions might be useful for NES games. I dunno. (source for these is below)

Anyways, have fun with it, and if you get it going on an FPGA board I would like to see the output. If a larger FPGA is used, more rendering cores can be easily dropped in to speed it up even more, though with 7 it is pretty fast and can typically pull 10-25fps or so without a problem.
If more cores are used, it could theoretically output a higher resolution with the same framerate but more mods would have to be done. Right now, it's NES resolution naturally. (256*240)

If you wish to play around with it, here is how to use it:

The video.v file instantiates mandelbrot.v, and it outputs pixels to a frame buffer. The video.v outputs addresses and RGB pixel data, 4 pixels at a time. So to use it, you need to make a small frame buffer object using a synchronous SRAM (which are included on almost all of the FPGA dev boards).

anyways, here is the source code:

http://blog.kevtris.org/blogfiles/mandelbrot.v
http://blog.kevtris.org/blogfiles/video.v
http://blog.kevtris.org/blogfiles/MANDEL.ASM

have fun. If there's some interest I might be persuaded to release other code sometime.
/* this is a comment */

User avatar
jwdonal
Posts: 719
Joined: Sat Jun 27, 2009 11:05 pm
Location: New Mexico, USA
Contact:

Post by jwdonal » Thu Mar 10, 2011 10:36 pm

This is freakin sick! So my question is...how did you figure out how to do this? Haha. Did you use some existing verilog code that you found online or did you just do everything from scratch?? O.o Or did you study the algorithms from a book or...?

This is really impressive. I'm surprised you have no replies...I guess maybe because there aren't many FPGA'ers on these forums...? Still kind of odd. I was thinking about puttin this baby on a giant Virtex-5 that I have and upping the number of cores. What clock rate were you running at?

Pz!

Jonathon

User avatar
kevtris
Posts: 504
Joined: Sat Oct 29, 2005 2:09 am
Location: Indianapolis
Contact:

Post by kevtris » Fri Mar 11, 2011 1:08 pm

jwdonal wrote:This is freakin sick! So my question is...how did you figure out how to do this? Haha. Did you use some existing verilog code that you found online or did you just do everything from scratch?? O.o Or did you study the algorithms from a book or...?

This is really impressive. I'm surprised you have no replies...I guess maybe because there aren't many FPGA'ers on these forums...? Still kind of odd. I was thinking about puttin this baby on a giant Virtex-5 that I have and upping the number of cores. What clock rate were you running at?

Pz!

Jonathon
I came up with it all on my own. I wrote it all from scratch in about 2-3 days.

The Mandelbrot algo is quite simple- you just iterate a function until the bailout condition is met, and when it is you use the number of iterations to set the colour for that pixel.

I spent some time working out the fixed point representation for it that would give me the most bang for the buck.

I ran the cores at around 70MHz from what I recall. When I ran faster, I got errors in the multiplies due to propagation delays. The interesting thing to me is that the errors were fractal in nature! It ended up making complex loops and curves in the black part of the mandelbrot/julia sets.

If you wish to increase core depth I can help with that. But the basics are you just add more mandelbrot instances and adjust the selector in the case statement to add the results from the cores, and up the core counter.

I have NOT tried increasing bit depth of the cores- that functionality is untested but should work. <cough>. the cores are 36 bit inputs because this is a multiple of the width of the hardware multipliers (18*18 bits on this chip).
/* this is a comment */

yesyesyall
Posts: 28
Joined: Sat Mar 05, 2011 3:17 pm
Location: Houston, Texas

Post by yesyesyall » Wed Mar 30, 2011 11:01 am

had to google what fpga was. this is amazing. i try to collect as many of those old art matix mandlebrot/julia set videos as i can. mandlebrot set on nes possibility?

edit: want to restate that this is truly fucking awesome

User avatar
Memblers
Site Admin
Posts: 3858
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Post by Memblers » Wed Mar 30, 2011 5:58 pm


User avatar
kevtris
Posts: 504
Joined: Sat Oct 29, 2005 2:09 am
Location: Indianapolis
Contact:

Post by kevtris » Thu Mar 31, 2011 8:35 am

yesyesyall wrote:had to google what fpga was. this is amazing. i try to collect as many of those old art matix mandlebrot/julia set videos as i can. mandlebrot set on nes possibility?

edit: want to restate that this is truly fucking awesome
Thanks for the good words. I remember art matrix too. I had two t-shirts by them (long gone now unfortunately) and at least 1 videotape. Not sure if I still have the tape or not. I got them back around 1993 or thereabouts from a friend here in town that used to sell their stuff.
/* this is a comment */

gamax92
Posts: 27
Joined: Sun Apr 10, 2011 12:05 pm
Location: Earth
Contact:

Post by gamax92 » Sun Apr 10, 2011 8:02 pm

That video was really cool. i like how it looks and the sound in the background. five out of five stars.

Post Reply