Skip to content

Commit 94fc37d

Browse files
committed
Fix clock domain crossing for zoom signal
interact_zoom is written in the clk_74a domain but consumed by ASTEROIDS_DW logic clocked on clk_25. Add a synch_2 synchronizer (same pattern used for controller inputs) to safely cross the clock domain boundary and prevent metastable values from reaching the zoom address computation. The zoom math precision issue (ceiling vs floor scaling, ~1px offset) is left as-is since the difference is visually imperceptible. https://claude.ai/code/session_01NYKHEx1oSSxcWrEi23wb4L
1 parent d657769 commit 94fc37d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/fpga/core/core_top.sv

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,16 @@ synch_2 #(
681681

682682
reg [7:0] dpad_thrust = 0;
683683

684+
wire [1:0] interact_zoom_s;
685+
686+
synch_2 #(
687+
.WIDTH(2)
688+
) zoom_s (
689+
interact_zoom,
690+
interact_zoom_s,
691+
clk_25
692+
);
693+
684694
synch_2 #(
685695
.WIDTH(8)
686696
) thrust_s (
@@ -781,7 +791,7 @@ LLANDER_TOP LLANDER_TOP
781791
.VID_HBLANK(hblank),
782792
.VID_VBLANK(vblank_lunarlander),
783793
.DIP(m_dip),
784-
.ZOOM(interact_zoom),
794+
.ZOOM(interact_zoom_s),
785795
.RESET_L (reset_n),
786796
.clk_6(clk_6),
787797
.clk_25(clk_25)

0 commit comments

Comments
 (0)