1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
17 // The way that we connect things in low-frequency simulation mode. In this
18 // case just pass everything through to the ARM, which can bit-bang this
19 // (because it is so slow).
21 // Jonathan Westhues, April 2006
22 //-----------------------------------------------------------------------------
44 reg [7:0] to_arm_shiftreg
;
45 reg [7:0] pck_divider
;
48 // Antenna logic, depending on "lf_field" (in arm defined as FPGA_LF_READER_FIELD)
49 wire tag_modulation
= ssp_dout
& !lf_field
;
50 wire reader_modulation
= !ssp_dout
& lf_field
& clk_state
;
52 // always on (High Frequency outputs, unused)
53 assign pwr_oe1
= 1'b0;
56 // low frequency outputs
57 assign pwr_lo
= reader_modulation
;
58 assign pwr_oe2
= 1'b0; // 33 Ohms
59 assign pwr_oe3
= tag_modulation
; // base antenna load = 33 Ohms
60 assign pwr_oe4
= 1'b0; // 10k Ohms
62 // Debug Output ADC clock
63 assign debug
= adc_clk
;
65 // ADC clock out of phase with antenna driver
66 assign adc_clk
= ~clk_state
;
68 // serialized SSP data is gated by clk_state to suppress unwanted signal
69 assign ssp_din
= to_arm_shiftreg
[7] && !clk_state
;
71 // SSP clock always runs at 24MHz
72 assign ssp_clk
= pck0
;
74 // SSP frame is gated by clk_state and goes high when pck_divider=8..15
75 assign ssp_frame
= (pck_divider
[7:3] == 5'd1) && !clk_state
;
77 // divide 24mhz down to 3mhz
78 always @(posedge pck0
)
80 if (pck_divider
== divisor
[7:0])
83 clk_state
= !clk_state
;
87 pck_divider
<= pck_divider
+ 1;
91 // this task also runs at pck0 frequency (24Mhz) and is used to serialize
92 // the ADC output which is then clocked into the ARM SSP.
93 always @(posedge pck0
)
95 if ((pck_divider
== 8'd7) && !clk_state
)
96 to_arm_shiftreg
<= adc_d
;
99 to_arm_shiftreg
[7:1] <= to_arm_shiftreg
[6:0];
100 to_arm_shiftreg
[0] <= 1'b0;