aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarrick Lo <wlo@warricklo.net>2026-03-02 21:49:30 -0800
committerWarrick Lo <wlo@warricklo.net>2026-03-02 21:49:30 -0800
commit1a8ed2442f5c7509b82fa5f5971e5344bccfa917 (patch)
tree0c2281567451cf13e63822700fbda629610f7571
parentFix arc 1 not drawing when centre of circle 1 is off screen (diff)
Fix gaps and incorrect geometry at large sizes
Signed-off-by: Warrick Lo <wlo@warricklo.net>
-rw-r--r--task4/reuleaux.sv18
1 files changed, 11 insertions, 7 deletions
diff --git a/task4/reuleaux.sv b/task4/reuleaux.sv
index dbf57f8..cc89f4f 100644
--- a/task4/reuleaux.sv
+++ b/task4/reuleaux.sv
@@ -20,10 +20,10 @@ module reuleaux(clk, rst_n, colour, centre_x, centre_y, diameter, start, done,
* 8-bit and 13-bit numbers together. */
logic [20:0] diameter_scaled;
- /* One bit larger since these are signed. */
- logic signed [7:0] vga_y_next, offset_y, offset_y_next,
+ /* Extra bits to fix incorrect geometry when drawing at large radii. */
+ logic signed [8:0] vga_y_next, offset_y, offset_y_next,
centre_y1, centre_y2, centre_y3;
- logic signed [8:0] vga_x_next, offset_x, offset_x_next,
+ logic signed [9:0] vga_x_next, offset_x, offset_x_next,
centre_x1, centre_x2, centre_x3, crit, crit_next, radius;
assign vga_colour = clear ? 3'b000 : colour;
@@ -79,9 +79,13 @@ module reuleaux(clk, rst_n, colour, centre_x, centre_y, diameter, start, done,
/* 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'd0) || (octant == 3'd1))
- if (vga_y_next > centre_y2)
+ /* Pixels of circle 1 that are between the centres
+ * of circle 2 and 3. */
+ if (octant == 3'd0)
+ if (vga_x_next <= centre_x2)
+ vga_plot_next = 1'b1;
+ if (octant == 3'd1)
+ if (vga_x_next >= centre_x3)
vga_plot_next = 1'b1;
/* Pixels of circle 2 that are to the left of the centre. */
if ((octant == 3'd2) || (octant == 3'd3))
@@ -141,7 +145,7 @@ module reuleaux(clk, rst_n, colour, centre_x, centre_y, diameter, start, done,
end else if (ready && start && ~done) begin
ready <= 1'b0;
octant <= 3'b0;
- offset_y <= 8'b0;
+ offset_y <= 9'b0;
offset_x <= radius;
crit <= 1 - radius;
/* Draw the circle using the Bresenham circle algorithm. */