1 //-----------------------------------------------------------------------------
4 //-----------------------------------------------------------------------------
8 adc_d, trace_enable, major_mode,
9 ssp_frame, ssp_din, ssp_clk
14 input [2:0] major_mode;
15 output ssp_frame, ssp_din, ssp_clk;
17 // constants for some major_modes:
19 `define GET_TRACE 3'b101
24 always @(negedge ck_1356megb)
26 clock_cnt <= clock_cnt + 1;
29 // 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
30 reg [2:0] sample_clock;
31 always @(negedge ck_1356megb)
33 if (sample_clock == 3'd3)
36 sample_clock <= sample_clock + 1;
41 reg [11:0] start_addr;
42 reg [2:0] previous_major_mode;
45 always @(negedge ck_1356megb)
47 previous_major_mode <= major_mode;
48 if (major_mode == `GET_TRACE)
50 write_enable1 <= 1'b0;
51 write_enable2 <= 1'b0;
52 if (previous_major_mode != `GET_TRACE) // just switched into GET_TRACE mode
54 if (clock_cnt == 7'd0)
62 else if (major_mode != `OFF)
68 write_enable1 <= 1'b1;
69 write_enable2 <= 1'b0;
73 write_enable1 <= 1'b0;
74 write_enable2 <= 1'b1;
76 if (sample_clock == 3'b000)
81 write_enable1 <= 1'b1;
82 write_enable2 <= 1'b0;
90 write_enable1 <= 1'b0;
91 write_enable2 <= 1'b0;
95 else // major_mode == `OFF
97 write_enable1 <= 1'b0;
98 write_enable2 <= 1'b0;
99 if (previous_major_mode != `OFF && previous_major_mode != `GET_TRACE) // just switched off
106 reg [7:0] D_out1, D_out2;
107 reg [7:0] ram1 [2047:0];
108 reg [7:0] ram2 [1023:0];
110 always @(negedge ck_1356megb)
114 ram1[addr[10:0]] <= adc_d;
118 D_out1 <= ram1[addr[10:0]];
121 ram2[addr[9:0]] <= adc_d;
125 D_out2 <= ram2[addr[9:0]];
129 // SSC communication to ARM
134 always @(negedge ck_1356megb)
136 if(clock_cnt[3:0] == 4'd0) // update shift register every 16 clock cycles
138 if(clock_cnt[6:4] == 3'd0) // either load new value
140 if (addr[11] == 1'b0)
145 else // or shift left
146 shift_out[7:1] <= shift_out[6:0];
149 ssp_clk <= ~clock_cnt[3]; // ssp_clk frequency = 13,56MHz / 16 = 847,5 kHz
151 if(clock_cnt[6:4] == 3'b000) // set ssp_frame for 0...31
158 assign ssp_din = shift_out[7];