Browse Source

cores/hub75: Introduce zig-zag scanning mode to minimize painting artefacts

When drawing the screen with multiple banks, if you scan the rows
sequentially, you end up drawing row 0 and row 31 "far appart" in time
but they are spatially close on the panel and this can lead to some
tearing effect (because you end up drawing row 0 of frame n+1 right after
drawing row 31 of frame n and they are right next to each other).

This new scanning mode tries to paint rows in an order that makes adjacent
rows being painted at roughly the same time.

Fixes #7

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Sylvain Munaut 5 years ago
parent
commit
48a784e6e2
2 changed files with 13 additions and 3 deletions
  1. 9 2
      cores/hub75/rtl/hub75_scan.v
  2. 4 1
      cores/hub75/rtl/hub75_top.v

+ 9 - 2
cores/hub75/rtl/hub75_scan.v

@@ -28,6 +28,8 @@
 module hub75_scan #(
 	parameter integer N_ROWS   = 32,
 
+	parameter SCAN_MODE = "ZIGZAG",		// 'LINEAR' or 'ZIGZAG'
+
 	// Auto-set
 	parameter integer LOG_N_ROWS  = $clog2(N_ROWS)
 )(
@@ -112,8 +114,13 @@ module hub75_scan #(
 			row <= 0;
 			row_last <= 1'b0;
 		end else if (fsm_state == ST_PAINT) begin
-			row <= row + 1;
-			row_last <= (row == {{(LOG_N_ROWS-1){1'b1}}, 1'b0});
+			if (SCAN_MODE == "ZIGZAG") begin
+				row <= ~(row + {LOG_N_ROWS{row[LOG_N_ROWS-1]}});
+				row_last <= (row == {1'b0, {(LOG_N_ROWS-1){1'b1}}});
+			end else begin
+				row <= row + 1;
+				row_last <= (row == {{(LOG_N_ROWS-1){1'b1}}, 1'b0});
+			end
 		end
 
 

+ 4 - 1
cores/hub75/rtl/hub75_top.v

@@ -33,6 +33,8 @@ module hub75_top #(
 	parameter integer N_PLANES = 8,		// # bitplanes
 	parameter integer BITDEPTH = 24,	// # bits per color
 
+	parameter SCAN_MODE = "ZIGZAG",		// 'LINEAR' or 'ZIGZAG'
+
 	// Auto-set
 	parameter integer LOG_N_BANKS = $clog2(N_BANKS),
 	parameter integer LOG_N_ROWS  = $clog2(N_ROWS),
@@ -174,7 +176,8 @@ module hub75_top #(
 
 	// Scan
 	hub75_scan #(
-		.N_ROWS(N_ROWS)
+		.N_ROWS(N_ROWS),
+		.SCAN_MODE(SCAN_MODE)
 	) scan_I (
 		.bcm_row(bcm_row),				// -> hub75_bcm
 		.bcm_go(bcm_go),				// -> hub75_bcm