From 31b0ece9219b666f9cb11701e69d742e17e6b0e3 Mon Sep 17 00:00:00 2001 From: dxl <64101226@qq.com> Date: Sat, 10 Oct 2026 09:41:25 +0800 Subject: [PATCH] FPGA: hi_simulate.v merged. --- fpga/hi_simulate.v | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/fpga/hi_simulate.v b/fpga/hi_simulate.v index 8e485d56c..320fe31c6 100644 --- a/fpga/hi_simulate.v +++ b/fpga/hi_simulate.v @@ -108,22 +108,33 @@ begin ssp_clk <= ~ssp_clk_divider[4]; end +// Since the 212k clock is generated by ssp_clk_divider[5], a full cycle here involves 16 bits—effectively 8 clock periods. +// This means an 8-bit transfer; in SSP mode, the frame signal is driven high at bit 1 (clock rising edge) and low at bit 5 (clock falling edge). +// To switch to TI mode, this must be changed to the rising edge of the final cycle: driving high at bit 14 (rising edge) and low at bit 0 (falling edge). +`ifdef WITH_TIMODE +`define FRAME_SET_212K 4'd14 +`define FRAME_CLR_212K 4'd0 +`else +`define FRAME_SET_212K 4'd1 +`define FRAME_CLR_212K 4'd5 +`endif + // Produce the byte framing signal; the phase of this signal // is arbitrary, because it's just a bit stream in this module. always @(negedge adc_clk) begin if (mod_type == `FPGA_HF_SIMULATOR_MODULATE_212K) begin - if (ssp_clk_divider[8:5] == 4'd1) + if (ssp_clk_divider[8:5] == `FRAME_SET_212K) ssp_frame <= 1'b1; - if (ssp_clk_divider[8:5] == 4'd5) + if (ssp_clk_divider[8:5] == `FRAME_CLR_212K) ssp_frame <= 1'b0; end else begin - if (ssp_clk_divider[7:4] == 4'd1) + if (ssp_clk_divider[7:4] == `FRAME_SET_212K) ssp_frame <= 1'b1; - if (ssp_clk_divider[7:4] == 4'd5) + if (ssp_clk_divider[7:4] == `FRAME_CLR_212K) ssp_frame <= 1'b0; end end