Presentation is loading. Please wait.

Presentation is loading. Please wait.

ECE 448: Spring 2019 Lab 5 Julia Set Fractal.

Similar presentations


Presentation on theme: "ECE 448: Spring 2019 Lab 5 Julia Set Fractal."— Presentation transcript:

1 ECE 448: Spring 2019 Lab 5 Julia Set Fractal

2 Hands-on Session on FPro SoC Video Subsystem Example
2

3 Platform Hardware Organization
The main functionality of the subsystem is to generate, process, and display pixel data. An FPro video core inputs a pixel stream, performs computation or adds new contents to the stream, and then outputs the processed pixel stream. The video cores are arranged as a cascading chain and the pixel data travels through the chain stage by stage. The cores in the left are video sources that generate fullscreen pixel data and stream it to the cores in the following stages. The cores in the middle perform certain transformations on the pixels or augment the frame with additional graphics. The stream is eventually routed to the video synchronization circuit, which is the rightmost core in the chain, and displayed on a monitor.

4 Video Display using VGA Interface

5 Frame Buffer Driver (vga_core.h)
/* methods */ FrameCore(uint32_t frame_base_addr); ~FrameCore(); // not used void wr_pix(int x, int y, int color); /** * clear frame buffer (fill the frame with a specific color) color color to fill the frame * */ void clr_screen(int color); * enable/disable core bypass by 1: bypass current core; 0: not bypass void bypass(int by);

6 Video Subsystem Application
FrameCore frame(FRAME_BASE); GpvCore bar(get_sprite_addr(BRIDGE_BASE, V7_BAR)); GpvCore gray(get_sprite_addr(BRIDGE_BASE, V6_GRAY)); SpriteCore ghost(get_sprite_addr(BRIDGE_BASE, V3_GHOST), 1024); SpriteCore mouse(get_sprite_addr(BRIDGE_BASE, V1_MOUSE), 1024); int main(){ bar.bypass(1); gray.bypass(1); ghost.bypass(1); mouse.bypass(1); frame.bypass(0); frame.clr_screen(0); frame.wr_pix(0, 0, 1); frame.wr_pix(639, 479, 1); }

7 Introduction to Lab 5 7

8 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.

9 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

10 The Julia Set Julia Set was named for the early twentieth century French mathematician Gaston Julia The Julia set is a set of points in the complex plane, the boundary of which forms a fractal. Mathematically, the Julia set can be generated using a very simple iterative formula, called the quadratic recurrence equation, applied to points in complex plane  zn+1 = zn2 + zn + c  we start with z0=0 and apply the iteration repeatedly, The absolute number depends on c, however large n gets.

11 The Julia Set

12 Pseudocode In the pseudocode below, Z0=z0x+i·z0y, corresponds to one pixel of the display region. The plotted region should have the following limits -2 ≤ z0x=Re[Z0] < 2 -1.5 < z0y=Im[Z0] ≤ 1.5 for z0y = -1.5+step to 1.5, step 3/480 do for z0x = -2 to 2-step, step 4/640 do { iteration = 0 zx = z0x zy = z0y z and c are complex numbers. One begins by assigning a fixed value to c, letting z = 0 and calculating the output. One then repeatedly recalculates, or iterates, the equation, substituting each new output for z. Some values of c, when plugged into this iterative function, produce outputs that swiftly soar toward infinity. Other values of c produce outputs that eternally skitter about within a certain boundary. This latter group of c‘s, or complex numbers, constitutes the Mandelbrot set.

13 Pseudocode Cont… // z = z2 + z + c = (zx2 – zy2 +zx + cx) // + i·(2 · zx · zy + zy + cy) while (zx2 + zy2 < 4 && iteration < MAX_ITER ){ zxtemp = zx2 – zy2 + zx + cx zytemp = 2 · zx · zy + zy + cy zx = zxtemp zy = zytemp iteration++ }

14 Pseudocode Cont… x = x_conv(z0x) // conversion to the x-coordinate of a pixel y = y_conv(z0y) // conversion to the y-coordinate of a pixel if zx2 + zy2 < 4 color(x,y) = fractal_color else color(x,y) = background_color }

15 VGA Display Area Use a rectangular area of the size 640 x 480 to display the Julia set fractal. Use BTNS to start/pause the computations.

16 x_conv() and y_conv() The functions x_conv() and y_conv() are used to convert the coordinates of the complex number Z0 into x and y coordinates of the pixel. x = x_conv(z0x) = (z0x-(-2))*(640/4) = 160*(z0x+2) y = y_conv(z0y) = (z0y-(-1.5))*(480/3)= 480 – 160*(z0y+1.5)

17 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

18

19

20

21

22

23

24

25

26 Julia Set Fractal Core

27 Julia Set Fractal Core The fractal is calculated over a 640x480 pixel area and this area can be divided into tiles, each containing 32x16 pixels. Each tile is then processed by the core to determine which of its pixels are the part of the Julia set. The tiles are represented using the following data sent to the core: • Initial value of the z0x • Initial value of the z0y The algorithm mentioned above is performed for all pixels in each tile mentioned above, and the result should contain 16 32-bit words, with each bit of each word denoting whether a corresponding pixel of the tile belongs to the Julia set. Finally, there should be a flag denoting that the computations are complete for the entire tile.

28 Bonus Task 1 At the top of the screen display “THE JULIA SET” in the center. At the bottom of the screen display Percentage of the display area, increasing after the Julia set fractal core completes calculations for each subsequent 32x16 pixels tile. Progress bar Total execution time with the step 0.1 s.

29 VGA Display Outlook THE JULIA SET 33.1 s 95.5%

30 Bonus Tasks 2 Increase the speed of calculations, by evaluating 4 values of Z0 in parallel. Determine the maximum speed-up possible by evaluating N values of Z0 in parallel, where N is limited only by the available FPGA resources. 

31 Bonus Task 3 Provide support for changing the color of the fractal and background depending on the settings of switches, as described in the table below:

32 Lab Exercise 1 32

33 Text Generation Basics
Each character is treated as a tile The patterns of the tiles constitute the font of the character set We use an 8 x 16 font, similar to the one used in early IBM PCs In this font each character is represented as an 8 x 16 pixel pattern The character patterns are stored in the pattern memory, known as font memory For a 7-bit ASCII we need 128 x 16 x 8 = 2kbytes ECE 448 – FPGA and ASIC Design with VHDL

34 Font Pattern of A 128 ×16=2048 byte array Pixel Pattern Array Content
ECE 448 – FPGA and ASIC Design with VHDL

35 Character coordinates
640 pixels  640/8 = 80 characters 1 2 3 4 5 6 7 8 9 10 75 76 77 78 79 1 2 3 480 pixels 480/16 = 30 characters 26 27 28 29 ECE 448 – FPGA and ASIC Design with VHDL

36 Repeated display of all 128 characters
32 chars 31 32 63 64 79 95 4 chars 128 characters 128 characters 128 characters 3 4 128 characters 128 characters 128 characters 7 24 128 characters 128 characters 128 characters 27 28 128 characters 128 characters 128 characters 31 ECE 448 – FPGA and ASIC Design with VHDL


Download ppt "ECE 448: Spring 2019 Lab 5 Julia Set Fractal."

Similar presentations


Ads by Google