- after_hysteresis_prev2 <= after_hysteresis;
- bit2 <= curbit;
- end
- if(negedge_cnt == 7'd33)
- begin
- after_hysteresis_prev3 <= after_hysteresis;
- bit3 <= curbit;
- end
- if(negedge_cnt == 7'd47)
- begin
- after_hysteresis_prev4 <= after_hysteresis;
- bit4 <= curbit;
- end
-
- //--------------------------------------------------------------------------------------------------------------------------------------------------------------
- // Relevant in TAGSIM_MOD only. Delay-Line to buffer data and send it at the correct time
- if(negedge_cnt[3:0] == 4'd0) // at rising edge of ssp_clk - ssp_dout changes at the falling edge.
- begin
- mod_sig_buf[31:0] <= {mod_sig_buf[30:1], ssp_dout, 1'b0}; // shift in new data starting at mod_sig_buf[1]. mod_sig_buf[0] = 0 always.
- // asign the delayed signal to mod_sig, but don't modulate with the correction bit (which is sent as 00010000, all other bits will come with at least 2 consecutive 1s)
- // side effect: when ptr = 1 it will cancel the first 1 of every block of ones. Note: this would only be the case if we received a 1 just before fdt_elapsed.
- if((ssp_dout || (| mod_sig_ptr[4:0])) && ~fdt_elapsed) // buffer a 1 (and all subsequent data) until fdt_counter = 1148 adc_clk ticks.
- //if(mod_sig_ptr == 6'b101110) // buffer overflow at 46 - this would mean data loss
- //begin
- // mod_sig_ptr <= 6'b000000;
- //end
- if (mod_sig_ptr == 5'd30) mod_sig_ptr <= 5'd0;
- else mod_sig_ptr <= mod_sig_ptr + 1; // increase buffer (= increase delay by 16 adc_clk ticks). ptr always points to first 1.
- else if(fdt_elapsed && ~temp_buffer_reset)
- // fdt_elapsed. If we didn't receive a 1 yet, ptr will be at 9 and not yet fixed. Otherwise temp_buffer_reset will be 1 already.