+
+
+ // check timing of a falling edge in reader signal
+ if (pre_after_hysteresis && ~after_hysteresis)
+ reader_falling_edge_time[3:0] <= negedge_cnt[3:0];
+
+
+
+ // sync clock to external reader's clock:
+ if (negedge_cnt[3:0] == 4'd13 && (mod_type == `SNIFFER || mod_type == `TAGSIM_MOD || mod_type == `TAGSIM_LISTEN))
+ begin
+ // adjust clock if necessary:
+ if (reader_falling_edge_time < 4'd8 && reader_falling_edge_time > 4'd1)
+ begin
+ negedge_cnt <= negedge_cnt; // freeze time
+ end
+ else if (reader_falling_edge_time == 4'd8)
+ begin
+ negedge_cnt <= negedge_cnt + 1; // the desired state. Advance as usual;
+ end
+ else
+ begin
+ negedge_cnt[3:0] <= 4'd15; // time warp
+ end
+ reader_falling_edge_time <= 4'd8; // only once per detected rising edge
+ end
+
+
+