- // The modulation signal of the tag. The delay line is only relevant for TAGSIM_MOD, but used in other modes as well.
- // Note: this means that even in READER_MOD, there will be an arbitrary delay depending on the time of a previous reset of fdt_counter and the time and
- // content of the next bit to be transmitted.
- mod_sig_buf[47:0] <= {mod_sig_buf[46:1], ssp_dout, 1'b0}; // shift in new data starting at mod_sig_buf[1]. mod_sig_buf[0] = 0 always.
- if((ssp_dout || (| mod_sig_ptr[5: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
- 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.
- begin
- // wait for the next 1 after fdt_elapsed before fixing the delay and starting modulation. This ensures that the response can only happen
- // at intervals of 8 * 16 = 128 adc_clk ticks intervals (as defined in ISO14443-3)
- if(ssp_dout) temp_buffer_reset = 1'b1;
- if(mod_sig_ptr == 6'b000010) mod_sig_ptr <= 6'b001001; // still nothing received, need to go for the next interval
- else mod_sig_ptr <= mod_sig_ptr - 1; // decrease buffer.
- end
- else
- // mod_sig_ptr and therefore the delay is now fixed until fdt_counter is reset (this can happen in SNIFFER and TAGSIM_LISTEN mode only. Note that SNIFFER
- // mode (3'b000) is the default and is active in FPGA_MAJOR_MODE_OFF if no other minor mode is explicitly requested.
- begin
- // 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(~mod_sig_buf[mod_sig_ptr-1] && ~mod_sig_buf[mod_sig_ptr+1]) mod_sig = 1'b0;
- // finally, do the modulation:
- else mod_sig = mod_sig_buf[mod_sig_ptr] & fdt_elapsed;
- end
+ // wait for the next 1 after fdt_elapsed before fixing the delay and starting modulation. This ensures that the response can only happen
+ // at intervals of 8 * 16 = 128 adc_clk ticks intervals (as defined in ISO14443-3)
+ if(ssp_dout) temp_buffer_reset = 1'b1;
+ if(mod_sig_ptr == 5'd2) mod_sig_ptr <= 5'd9; // still nothing received, need to go for the next interval
+ else mod_sig_ptr <= mod_sig_ptr - 1; // decrease buffer.
+ end
+ else
+ begin
+ if(~mod_sig_buf[mod_sig_ptr-1] && ~mod_sig_buf[mod_sig_ptr+1]) mod_sig = 1'b0;
+ // finally, assign the delayed signal:
+ else mod_sig = mod_sig_buf[mod_sig_ptr];