Ok, let's take a look at what needs to be done with your code.
The line generator outline is ok. maybe we should rename a few things for ease of understanding.
/*
* ELLIPSE GENERATOR MODULE
*
* v 0.1.001
*
*/
module ellipse_generator (
// inputs
input logic clk, // 125 MHz pixel clock
input logic reset, // asynchronous reset
input logic enable, // logic enable
input logic run, // HIGH to draw / run the unit
input logic [1:0] quadrant, // specifies which quadrant of the ellipse to draw
input logic signed [11:0] Xc, // 12-bit X-coordinate for center of ellipse
input logic signed [11:0] Yc, // 12-bit Y-coordinate for center of ellipse
input logic signed [11:0] A, // 12-bit X-radius, the width
input logic signed [11:0] B, // 12-bit Y-radius, the height
input logic ena_pause, // set HIGH to pause line generator while it is drawing
// outputs
output logic busy, // HIGH when ellipse_generator is running
output logic signed [11:0] X_coord, // 12-bit X-coordinate for current pixel
output logic signed [11:0] Y_coord, // 12-bit Y-coordinate for current pixel
output logic pixel_data_rdy, // HIGH when coordinate outputs are valid
output logic ellipse_complete // HIGH when ellipse is completed
);
Next, some of the internal logic:
logic draw_line = 1'b0 ;
logic [1:0] quadrant_latch = 2'b0 ; // This logic latches which quadrant to draw when run is issued
logic [2:0] geo_sub_func1 = 3'b0 ; // This logic defines which step is running, IE first setup for first 45 degrees,
// draw the first 45 degrees if the radius is not 0, finish the ellipse if the remaining radius is <=1,
// setup for the second 45 degrees (inv), draw the second 45 degrees if the radius is not 0,
// finish the ellipse if the remaining radius is <=1, end the busy and await the next command.
logic signed [11:0] x ; internal drawing x coordinate
logic signed [11:0] y ; internal drawing x coordinate
logic signed [11:0] af ;
logic signed [11:0] ab ;
logic signed [23:0] a2 ; // Note that the 4* fa2 & fb2 arent needed as they will just be a logic shift inside the code
logic signed [23:0] b2 ;
logic signed [23:0] sigma ;
logic pixel_data_rdy_int ; // HIGH when coordinate outputs are valid
logic busy_int ; // HIGH when coordinate outputs are valid
Now for the combinational logic:
always_comb begin
pixel_data_rdy = pixel_data_rdy_int && !ena_pause ; // immediately clear the pixel_data_ready output when the pause is high.
busy = busy_int || run ; // immediately make busy flag high when run is asserted
end
This stays the same as these outputs are crucial to match & be compliant with the line-generator's output.
Now, for the next part:
always_ff @( posedge clk or posedge reset) begin
if ( reset ) begin
// reset geometry counters and flags
// ********* Fill this in ********* //
end
else if ( enable ) begin // draw_busy_int must be LOW or the line generator won't run
if ( run ) begin // load values and begin drawing the line
// Initialise starting coordinates and direction for immediate plotting
quadrant_latch <= quadrant ; // latch which of the 4 quadrants will be drawn
if ((A==0) && (B==0)) begin // 0 X&Y radius, drawing only a single center point
X_coord <= Xc ; // initialize starting X pixel location
Y_coord <= Yc ; // initialize starting Y pixel location
pixel_data_rdy_int <= 1'b1 ; // set pixel_data_rdy_int flag
line_complete <= 1'b1 ; // make sure line_complete is set.
geo_sub_func1 <= 1'b0 ; // reset the phase counter
draw_line <= 1'b0 ; // no line to draw
busy_int <= 1'b0 ; // the line generator is busy_int from the next cycle
end
else begin // Drawing a full ellipse
// ********* Work on this ********* //
Use the other code to begin. First start initialize the variables and begin only the first 45 degrees.
Just output the X&Y, do not bother with any quadrants yet.
Setup a simulation test bench in Quartus driving the input and a clock. No other modules.
Drive some test inputs and I'll prepare the Freebasic code to print out the rendered coordinates of the arc.
(Arrrrgggg, the page count is over 9000 ......)