aboutsummaryrefslogtreecommitdiff
path: root/task4/reuleaux.sv
diff options
context:
space:
mode:
authorWarrick Lo <wlo@warricklo.net>2026-03-04 14:53:56 -0800
committerWarrick Lo <wlo@warricklo.net>2026-03-04 14:53:56 -0800
commite16feba0f56963d22c6f7820815f0b651c78bbe5 (patch)
tree9fe65e5f89d7f60ca3ac7d9f13f9991ca6d05937 /task4/reuleaux.sv
parentFix gaps and incorrect geometry at large sizes (diff)
Move fillscreen to a separate moduleHEADmaster
Signed-off-by: Warrick Lo <wlo@warricklo.net>
Diffstat (limited to 'task4/reuleaux.sv')
-rw-r--r--task4/reuleaux.sv36
1 files changed, 6 insertions, 30 deletions
diff --git a/task4/reuleaux.sv b/task4/reuleaux.sv
index cc89f4f..e518b63 100644
--- a/task4/reuleaux.sv
+++ b/task4/reuleaux.sv
@@ -14,7 +14,7 @@ module reuleaux(clk, rst_n, colour, centre_x, centre_y, diameter, start, done,
output logic [6:0] vga_y;
output logic [7:0] vga_x;
- logic clear, ready, vga_plot_next;
+ logic clear, vga_plot_next;
logic [2:0] octant;
/* Auxiliary value for calculations. 21-bit number since we multiply
* 8-bit and 13-bit numbers together. */
@@ -114,42 +114,19 @@ module reuleaux(clk, rst_n, colour, centre_x, centre_y, diameter, start, done,
always_ff @(posedge clk) begin
if (~rst_n) begin
done <= 1'b0;
- ready <= 1'b0;
- /* Start clearing the screen. */
- clear <= 1'b1;
+ /* Initialise the registers for the circle algorithm. */
vga_x <= 8'b0;
vga_y <= 7'b0;
- vga_plot <= 1'b1;
- end
-
- /* Clear the screen. */
- if (clear) begin
- if (vga_y < 120) begin
- /* Check for one column less since it takes
- * one clock cycle to reset and increment. */
- if (vga_x < 159)
- vga_x <= vga_x + 1;
- else begin
- vga_x <= 8'b0;
- vga_y <= vga_y + 1;
- end
- end else begin
- clear <= 1'b0;
- ready <= 1'b1;
- vga_x <= 8'b0;
- vga_y <= 7'b0;
- vga_plot <= 1'b0;
- end
- /* Initialise the registers for the circle algorithm. */
- end else if (ready && start && ~done) begin
- ready <= 1'b0;
+ vga_plot <= 1'b0;
octant <= 3'b0;
offset_y <= 9'b0;
offset_x <= radius;
crit <= 1 - radius;
+ end
+
/* Draw the circle using the Bresenham circle algorithm. */
- end else if (start && ~done) begin
+ if (start && ~done) begin
if (offset_y <= offset_x) begin
if ((vga_x_next >= 0) && (vga_x_next <= `VGA_W))
vga_x <= vga_x_next;
@@ -174,7 +151,6 @@ module reuleaux(clk, rst_n, colour, centre_x, centre_y, diameter, start, done,
/* Finished. */
end else begin
done <= 1'b1;
- ready <= 1'b1;
vga_plot <= 1'b0;
end
/* Wait for start to be deasserted. */