From 933e5ec714e97dad0951d560b90c301d233dc1b6 Mon Sep 17 00:00:00 2001 From: Warrick Lo Date: Mon, 2 Mar 2026 16:46:07 -0800 Subject: Remove plotting unused octants Signed-off-by: Warrick Lo --- task4/reuleaux.sv | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) (limited to 'task4/reuleaux.sv') diff --git a/task4/reuleaux.sv b/task4/reuleaux.sv index b6c35a2..68a3540 100644 --- a/task4/reuleaux.sv +++ b/task4/reuleaux.sv @@ -40,59 +40,55 @@ module reuleaux(clk, rst_n, colour, centre_x, centre_y, diameter, start, done, assign centre_x3 = centre_x - (diameter >> 1); assign centre_y3 = centre_y + ((y_offset + (1 << 12)) >> 13); - /* Draw only the octants that are needed for each circle: - * - circle 1: octants 2 & 3; - * - circle 2: octants 5 & 6; - * - circle 3: octants 7 & 8. + /* Draw only the octants that are needed for each circle. * Extra pixels will be taken care further below. */ always_comb case (octant) + /* Circle 1: octants 2 and 3. */ 3'd0: begin - vga_x_next = centre_x + offset_x; - vga_y_next = centre_y + offset_y; - end - 3'd1: begin vga_x_next = centre_x1 + offset_y; vga_y_next = centre_y1 + offset_x; end - 3'd2: begin + 3'd1: begin vga_x_next = centre_x1 - offset_y; vga_y_next = centre_y1 + offset_x; end - 3'd3: begin - vga_x_next = centre_x - offset_x; - vga_y_next = centre_y + offset_y; - end - 3'd4: begin + /* Circle 2: octants 5 and 6. */ + 3'd2: begin vga_x_next = centre_x2 - offset_x; vga_y_next = centre_y2 - offset_y; end - 3'd5: begin + 3'd3: begin vga_x_next = centre_x2 - offset_y; vga_y_next = centre_y2 - offset_x; end - 3'd6: begin + /* Circle 3: octants 7 and 8. */ + 3'd4: begin vga_x_next = centre_x3 + offset_y; vga_y_next = centre_y3 - offset_x; end - 3'd7: begin + 3'd5: begin vga_x_next = centre_x3 + offset_x; vga_y_next = centre_y3 - offset_y; end + default: begin + vga_x_next = 9'bx; + vga_y_next = 8'bx; + end endcase /* Only plot the pixels of the triangle. */ always_comb begin vga_plot_next = 1'b0; /* Pixels of circle 1 that are below the centre of 2 or 3. */ - if ((octant == 3'd1) || (octant == 3'd2)) + if ((octant == 3'd0) || (octant == 3'd1)) if (vga_y_next > centre_y2) vga_plot_next = 1'b1; /* Pixels of circle 2 that are to the left of the centre. */ - if ((octant == 3'd4) || (octant == 3'd5)) + if ((octant == 3'd2) || (octant == 3'd3)) if (vga_x_next <= centre_x) vga_plot_next = 1'b1; /* Pixels of circle 3 that are to the right of the centre. */ - if ((octant == 3'd6) || (octant == 3'd7)) + if ((octant == 3'd4) || (octant == 3'd5)) if (vga_x_next >= centre_x) vga_plot_next = 1'b1; end @@ -163,14 +159,14 @@ module reuleaux(clk, rst_n, colour, centre_x, centre_y, diameter, start, done, && (vga_y_next >= 0) && (vga_y_next <= `VGA_H)); - octant <= octant + 1; - /* The last octant. */ - if (octant == 7) begin + if (octant == 5) begin offset_x <= offset_x_next; offset_y <= offset_y_next; crit <= crit_next; - end + octant <= 3'b0; + end else + octant <= octant + 1; /* Finished. */ end else begin done <= 1'b1; -- cgit v1.2.3