Operation – Altera Nios II Embedded Evaluation Kit Cyclone III Edition User Manual

Page 47

Advertising
background image

5–11

Development Board Version 1.0.

Altera Corporation

Nios II Embedded Evaluation Kit, Cyclone III Edition

July 2010

Mandelbrot Application

When hardware rendering is selected the benchmark data is
updated every 5 frames.

When software rendering is selected the benchmark data is
updated every frame.

The benchmark data is displayed in the bottom right of the screen and it
represents the instantaneous frames per second being rendered and
displayed.

Consider the implications of what you have observed: What one would
traditionally do with an expensive, power hungry GHz processor was
just accomplished using an inexpensive Cyclone III FPGA, running at 100
MHz. Such is the power of hardware acceleration using FPGAs.

Operation

The design performs panning and zooming on the complex plane which
gives a video like effect. Every time a new frame is rendered, a new set of
coordinates must be calculated. These coordinates contain a center point,
zoom factor, and maximum number of iterations. Knowing the center
point and zoom factor the top left point of the screen is then determine
and passed to the Mandelbrot algorithm. The maximum number of
iterations is used to determine how much effort is spent per pixel before
it is determined that the point is included in the Mandelbrot set (these
points appear as black pixels). The pixel calculation is based on the
following software segment:

inline int int_mandelbrot(long long cr, long long ci,
int max_iter)
{
long long xsqr=0, ysqr=0, x=0, y=0;
int iter=0;
// go ahead and shift these up to the new decimal
offset
ci = ci<<28;
cr = cr<<28;
while( ((xsqr + ysqr) < 0x0400000000000000LL) &&
(iter < max_iter) )
{
xsqr = x * x;
ysqr = y * y;
y = ((2 * x * y) + ci) >> 28;
x = (xsqr - ysqr + cr) >> 28;
iter++;
return(iter);
}

Advertising