-- VHDL-AMS -- (C) 2000 by M. Thole LIBRARY ieee; USE ieee.math_real.ALL; LIBRARY DISCIPLINES; USE DISCIPLINES.ELECTROMAGNETIC_SYSTEM.ALL; -- This entity is the interface to architectures caalculating -- iterations for a given complex point of the z plane (re, im) ENTITY fractal IS GENERIC ( itmax : INTEGER := 10; -- Max iteration rad: REAL := 4.0 -- Radius of convergence ); PORT ( TERMINAL inx, iny, outp : ELECTRICAL ); END ENTITY fractal; -- This architecture calculates the mandelbrot iteration for a given -- complex point of the z plane (re, im) ARCHITECTURE mandel OF fractal is QUANTITY x ACROSS inx ; QUANTITY y ACROSS iny; QUANTITY res ACROSS ires THROUGH outp; FUNCTION iterate( re: REAL; im: REAL; itmax: INTEGER; rad: REAL) RETURN INTEGER IS VARIABLE i: INTEGER; VARIABLE xnew, ynew, x, y, xq: REAL; BEGIN i := 0; x := 0.0; y := 0.0; WHILE (i < itmax) AND (x*x + y*y < rad) LOOP xnew := x*x - y * y + re; ynew := 2.0 * x * y + im; x := xnew; y := ynew; i := i+1; END LOOP; RETURN i; END; BEGIN res == REAL(iterate(x, y, itmax, rad)); END mandel;