ece 448: spring 2015 lab 5 mandelbrot set fractal 1
TRANSCRIPT
![Page 1: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/1.jpg)
ECE 448: Spring 2015Lab 5
Mandelbrot Set Fractal
1
![Page 2: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/2.jpg)
Introduction to Lab5
2
![Page 3: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/3.jpg)
3
Benoit Mandelbrot
• Mandelbrot was born in Poland in 1924.
• Father of fractal geometry.
• He showed how fractals can occur in many different places in both mathematics and elsewhere in nature.
![Page 4: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/4.jpg)
What is a Fractal?Fractals are mathematical structures defined by two
properties– Iterative– Self-similar
• Zooming in or out on the image reveals deep repetition of patterns
4
![Page 5: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/5.jpg)
The Mandelbrot Set
• The Mandelbrot set is a set of points in the complex plane, the boundary of which forms a fractal.
• Mathematically, the Mandelbrot set can be generated using a very simple iterative formula, called the quadratic recurrence equation, applied to points in complex plane
zn+1 = zn2 + c
That is, a complex number c, is in the Mandelbrot set if the absolute value of zn never exceeds a certain number.
5
![Page 6: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/6.jpg)
6
The Mandelbrot Set
![Page 7: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/7.jpg)
Pseudocode
for cy = -1 to 1, step 2/400 do
for cx = -2 to 1, step 3/600 do
{
zx = 0
zy = 0
iteration = 0
7
In the pseudocode below, c=cx+i·cy, corresponds to one pixel of the display region. The plotted region should have the following limits
-2 ≤ cx=Re[c] ≤ 1
-1 ≤ cy=Im[c] ≤ 1
![Page 8: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/8.jpg)
Pseudocode Cont…
// z = z2 + c =
// =(zx2 – zy2 + cx) + i · (2 · zx · zy + cy)
while (zx2 + zy2 < 4 && iteration < MAX_ITER ){
zxtemp = zx2 – zy2 + cx
zytemp = 2 · zx · zy + cy
zx = zxtemp
zy = zytemp
iteration++
}
8
![Page 9: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/9.jpg)
x = x_conv(cx) // conversion to the x-coordinate of a pixel
y = y_conv(cy) // conversion to the y-coordinate of a pixel
if zx2 + zy2 < 4
color(x,y) = fractal_color
else
color(x,y) = background_color
}
9
Pseudocode Cont…
![Page 10: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/10.jpg)
x_conv() and y_convThe functions x_conv() and y_conv() are used to convert the coordinates of the complex number c into x and y coordinates of the pixel.
x = x_conv(cx) = 20 + (cx-(-2))*(600/3) = 20 + 200*(cx+2)
y = y_conv(cy) = 440 – (cy-(-1))*(400/2) = 440 - 200*(cy+1)
10
![Page 11: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/11.jpg)
11
The magnification of the last image relative to the first one is about 10,000,000,000 to 1.
![Page 12: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/12.jpg)
Fixed Point Representation• You can use Q4.28 representation
– 4 integer bits– 28 fractional bits
• Addition/Subtraction performed as usual
• Multiplication of two Q4.28 numbers results in a Q8.56 number, which should be converted back to Q4.28
12
![Page 13: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/13.jpg)
VGA Display Area
• Use a rectangular area of the size (600 x 400) to display the Mandelbrot set fractal.
• Left and Right border = 20 pixels each
• Top and Bottom border = 40 pixels each
13
![Page 14: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/14.jpg)
Cont..
• Top border should display “The Mandelbrot Set” in the center.
• Bottom border should display– Percentage of the display area, increasing
every 0.5%.– Progress bar – Total execution time with the step 0.1 s.
14
![Page 15: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/15.jpg)
Input/Output Scheme
15
• Use BTNS as the Start/Pause button to start/pause the computations.
• The color of the fractal and background should also change, depending on the positions of switches
![Page 16: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/16.jpg)
Final VGA Display Outlook
16
THE MANDELBROT SET
95.5% 33.1 s
![Page 17: ECE 448: Spring 2015 Lab 5 Mandelbrot Set Fractal 1](https://reader035.vdocument.in/reader035/viewer/2022081503/5697bfea1a28abf838cb7895/html5/thumbnails/17.jpg)
Bonus Tasks
17
• Increase the speed of calculations, by evaluating 4 values of c in parallel.
• Determine the maximum speed-up possible by evaluating N values of c in parallel, where N is limited only by the available FPGA resources.
• Add colors by assigning a different color to each value of c, based on the number of iterations required for the decision based on the following formula:
color = iteration mod 8