From 4afcebf22a4f2fdbe90884120eeeb69708deb60c Mon Sep 17 00:00:00 2001 From: Alan Steremberg Date: Mon, 28 Sep 2026 12:40:10 -0400 Subject: [PATCH] Video fetch: register the end-of-line test before the SDRAM ack coco_mem_fetch.sv compared read_count against WORD_END_COUNT on the same 114 MHz edge that took SDRAM_VID_ACK and updated VID_READ_OFFSET, the fetch address; that path missed timing (-0.7 ns). read_count only changes on the ack, so the compare is now registered in state_start with identical results. Co-Authored-By: Claude Opus 5.5 (1M context) --- rtl/coco_mem_fetch.sv | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rtl/coco_mem_fetch.sv b/rtl/coco_mem_fetch.sv index c53929d..0fbf9d8 100644 --- a/rtl/coco_mem_fetch.sv +++ b/rtl/coco_mem_fetch.sv @@ -84,6 +84,11 @@ reg [8:0] read_count; reg [4:0] state; reg second_write; reg init_offset_a0; +// End-of-line test for the fetch being requested, registered in state_start. +// read_count only changes on SDRAM_VID_ACK, so this equals the old in-line +// compare; it takes the 9-bit compare off the ACK -> VID_READ_OFFSET path, +// which missed timing at 114 MHz. +reg last_fetch; reg [4:0] a0_delay; localparam state_pre_start = 4'd0; @@ -161,6 +166,7 @@ begin SDRAM_VID_REQ <= 1'b1; state <= state_wait_accept; init_offset_a0 <= PHY_VID_ADD[1]; + last_fetch <= (read_count >= WORD_END_COUNT); end end @@ -170,7 +176,7 @@ begin begin SDRAM_VID_REQ <= 1'b0; - if (read_count >= WORD_END_COUNT) + if (last_fetch) begin read_count <= 9'h000; state <= state_done;