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 //-----------------------------------------------------------------------------
21 input [2:0] major_mode
,
30 always @(negedge ck_1356megb
)
32 clock_cnt
<= clock_cnt
+ 1;
35 // sample at 13,56MHz / 8. The highest signal frequency (subcarrier) is 848,5kHz, i.e. in this case we oversample by a factor of 2
36 reg [2:0] sample_clock
;
37 always @(negedge ck_1356megb
)
39 if (sample_clock
== 3'd7)
42 sample_clock
<= sample_clock
+ 1;
47 reg [11:0] start_addr
;
48 reg [2:0] previous_major_mode
;
51 always @(negedge ck_1356megb
)
53 previous_major_mode
<= major_mode
;
54 if (major_mode
== `FPGA_MAJOR_MODE_HF_GET_TRACE)
56 write_enable1
<= 1'b0;
57 write_enable2
<= 1'b0;
58 if (previous_major_mode
!= `FPGA_MAJOR_MODE_HF_GET_TRACE) // just switched into GET_TRACE mode
60 if (clock_cnt
== 7'd0)
68 else if (major_mode
!= `FPGA_MAJOR_MODE_OFF)
74 write_enable1
<= 1'b1;
75 write_enable2
<= 1'b0;
79 write_enable1
<= 1'b0;
80 write_enable2
<= 1'b1;
82 if (sample_clock
== 3'b000)
87 write_enable1
<= 1'b1;
88 write_enable2
<= 1'b0;
98 write_enable1
<= 1'b0;
99 write_enable2
<= 1'b0;
103 else // major_mode == `FPGA_MAJOR_MODE_OFF
105 write_enable1
<= 1'b0;
106 write_enable2
<= 1'b0;
107 if (previous_major_mode
!= `FPGA_MAJOR_MODE_OFF && previous_major_mode != `FPGA_MAJOR_MODE_HF_GET_TRACE) // just switched off
115 reg [7:0] D_out1
, D_out2
;
116 reg [7:0] ram1
[2047:0]; // 2048 u8
117 reg [7:0] ram2
[1023:0]; // 1024 u8
119 always @(negedge ck_1356megb
)
123 ram1
[addr
[10:0]] <= adc_d
;
127 D_out1
<= ram1
[addr
[10:0]];
130 ram2
[addr
[9:0]] <= adc_d
;
134 D_out2
<= ram2
[addr
[9:0]];
139 always @(negedge ck_1356megb
)
141 if (clock_cnt
[3:0] == 4'd0) // update shift register every 16 clock cycles
143 if (clock_cnt
[6:4] == 3'd0) // either load new value
145 if (addr
[11] == 1'b0)
153 shift_out
[7:1] <= shift_out
[6:0];
157 ssp_clk
<= ~clock_cnt
[3]; // ssp_clk frequency = 13,56MHz / 16 = 847,5 kHz
159 if (clock_cnt
[6:4] == 3'b000) // set ssp_frame for 0...31
166 assign ssp_din
= shift_out
[7];