// Original Coco 3 Plus contributions: Copyright (c) 2026 Brian K. Holman. // Original component notices/terms retained; see COPYRIGHT.md and LICENSING.md. // Research request boundary for the MiSTer 57 MHz CPU / 114 MHz SDRAM interface. // Captures the complete selected CPU/GART/AMW payload after the core raises req. // The clocks are related PLL outputs; all crossings retain normal timing checks. module cpu_sdram_bridge ( input clk, fast_clk, reset, input [24:0] cpu_addr, input [7:0] cpu_din, input cpu_req, cpu_rnw, memory_ack, output cpu_ack, output reg [24:0] memory_addr, output reg [7:0] memory_din, output reg memory_rnw, output reg memory_req = 1'b0 ); // A falling fast-clock observation avoids the coincident positive-fast / // negative-system edge for ACK. Both half-period transfers remain timed. reg ack_phase = 1'b0; always @(negedge fast_clk) ack_phase <= reset ? 1'b0 : memory_ack; assign cpu_ack = cpu_req && memory_req && ack_phase; always @(negedge clk) begin if (reset || !cpu_req) memory_req <= 1'b0; else if (!memory_req && !ack_phase) begin memory_addr <= cpu_addr; memory_din <= cpu_din; memory_rnw <= cpu_rnw; memory_req <= 1'b1; end end endmodule