// Verilog // (C) 2001 by M. Thole module apfel; parameter itmax = 10, // max iterations rad = 4.0, // test radius resolution = 500, // number of points per line xmin = -2.25, // min x value xmax = 0.75, // max x value ymin = -1.5, // min y value ymax = 1.5; // max y value integer result; real x, y; // This function calculates the mandelbrot iteration for a given // complex point of the z plane (re, im) function integer iterate; input re, im, itmax, rad; integer i, itmax; real re, im, xnew, ynew, x, y, xq, rad; begin i = 0; x = 0.0; y = 0.0; while ((i < itmax) && (x*x + y*y < rad)) begin xnew = x*x - y * y + re; ynew = 2.0 * x * y + im; x = xnew; y = ynew; i = i+1; end iterate = i; end endfunction // iterate initial begin for (y = ymin; y <= ymax; y = y + (ymax-ymin)/resolution) begin for (x = xmin; x <= xmax; x = x + (xmax-xmin)/resolution) begin result = iterate(x, y, itmax, rad); $write("%c", (result % 2) ? " " : "#"); end $write("\n"); end end endmodule // apfel