From ba06a4b694da23045ed75d18ccf77a9befac65c0 Mon Sep 17 00:00:00 2001 From: bushing Date: Mon, 22 Feb 2010 19:29:05 +0000 Subject: [PATCH 02/16] setting svn:eol-style=native on files, part 3 (should be done now, sorry) --- fpga/fpga.ucf | 82 ++-- fpga/fpga.v | 426 +++++++++--------- fpga/hi_read_rx_xcorr.v | 370 +++++++-------- fpga/hi_read_tx.v | 178 ++++---- fpga/hi_simulate.v | 218 ++++----- fpga/lo_passthru.v | 112 ++--- fpga/lo_read.v | 206 ++++----- fpga/lo_simulate.v | 101 +++-- fpga/sim.tcl | 54 +-- fpga/testbed_fpga.v | 100 ++-- fpga/testbed_hi_read_tx.v | 218 ++++----- fpga/testbed_hi_simulate.v | 232 +++++----- fpga/testbed_lo_read.v | 202 ++++----- fpga/testbed_lo_simulate.v | 202 ++++----- fpga/util.v | 54 +-- fpga/xst.scr | 2 +- .../at91sam7s256-armusbocd-flash-program.cfg | 78 ++-- tools/at91sam7s256-jtagkey.cfg | 48 +- tools/at91sam7s256-wiggler.cfg | 78 ++-- 19 files changed, 1481 insertions(+), 1480 deletions(-) diff --git a/fpga/fpga.ucf b/fpga/fpga.ucf index bf0d40bc..35f38e73 100644 --- a/fpga/fpga.ucf +++ b/fpga/fpga.ucf @@ -1,41 +1,41 @@ -# See the schematic for the pin assignment. - -NET "adc_d<0>" LOC = "P62" ; -NET "adc_d<1>" LOC = "P60" ; -NET "adc_d<2>" LOC = "P58" ; -NET "adc_d<3>" LOC = "P57" ; -NET "adc_d<4>" LOC = "P56" ; -NET "adc_d<5>" LOC = "P55" ; -NET "adc_d<6>" LOC = "P54" ; -NET "adc_d<7>" LOC = "P53" ; -#NET "cross_hi" LOC = "P88" ; -#NET "miso" LOC = "P40" ; -#PACE: Start of Constraints generated by PACE - -#PACE: Start of PACE I/O Pin Assignments -NET "adc_clk" LOC = "P46" ; -NET "adc_noe" LOC = "P47" ; -NET "ck_1356meg" LOC = "P91" ; -NET "ck_1356megb" LOC = "P93" ; -NET "cross_lo" LOC = "P87" ; -NET "dbg" LOC = "P22" ; -NET "mosi" LOC = "P43" ; -NET "ncs" LOC = "P44" ; -NET "pck0" LOC = "P36" ; -NET "pwr_hi" LOC = "P80" ; -NET "pwr_lo" LOC = "P81" ; -NET "pwr_oe1" LOC = "P82" ; -NET "pwr_oe2" LOC = "P83" ; -NET "pwr_oe3" LOC = "P84" ; -NET "pwr_oe4" LOC = "P86" ; -NET "spck" LOC = "P39" ; -NET "ssp_clk" LOC = "P71" ; -NET "ssp_din" LOC = "P32" ; -NET "ssp_dout" LOC = "P34" ; -NET "ssp_frame" LOC = "P31" ; - -#PACE: Start of PACE Area Constraints - -#PACE: Start of PACE Prohibit Constraints - -#PACE: End of Constraints generated by PACE +# See the schematic for the pin assignment. + +NET "adc_d<0>" LOC = "P62" ; +NET "adc_d<1>" LOC = "P60" ; +NET "adc_d<2>" LOC = "P58" ; +NET "adc_d<3>" LOC = "P57" ; +NET "adc_d<4>" LOC = "P56" ; +NET "adc_d<5>" LOC = "P55" ; +NET "adc_d<6>" LOC = "P54" ; +NET "adc_d<7>" LOC = "P53" ; +#NET "cross_hi" LOC = "P88" ; +#NET "miso" LOC = "P40" ; +#PACE: Start of Constraints generated by PACE + +#PACE: Start of PACE I/O Pin Assignments +NET "adc_clk" LOC = "P46" ; +NET "adc_noe" LOC = "P47" ; +NET "ck_1356meg" LOC = "P91" ; +NET "ck_1356megb" LOC = "P93" ; +NET "cross_lo" LOC = "P87" ; +NET "dbg" LOC = "P22" ; +NET "mosi" LOC = "P43" ; +NET "ncs" LOC = "P44" ; +NET "pck0" LOC = "P36" ; +NET "pwr_hi" LOC = "P80" ; +NET "pwr_lo" LOC = "P81" ; +NET "pwr_oe1" LOC = "P82" ; +NET "pwr_oe2" LOC = "P83" ; +NET "pwr_oe3" LOC = "P84" ; +NET "pwr_oe4" LOC = "P86" ; +NET "spck" LOC = "P39" ; +NET "ssp_clk" LOC = "P71" ; +NET "ssp_din" LOC = "P32" ; +NET "ssp_dout" LOC = "P34" ; +NET "ssp_frame" LOC = "P31" ; + +#PACE: Start of PACE Area Constraints + +#PACE: Start of PACE Prohibit Constraints + +#PACE: End of Constraints generated by PACE diff --git a/fpga/fpga.v b/fpga/fpga.v index c39109f9..4002945b 100644 --- a/fpga/fpga.v +++ b/fpga/fpga.v @@ -1,213 +1,213 @@ -//----------------------------------------------------------------------------- -// The FPGA is responsible for interfacing between the A/D, the coil drivers, -// and the ARM. In the low-frequency modes it passes the data straight -// through, so that the ARM gets raw A/D samples over the SSP. In the high- -// frequency modes, the FPGA might perform some demodulation first, to -// reduce the amount of data that we must send to the ARM. -// -// I am not really an FPGA/ASIC designer, so I am sure that a lot of this -// could be improved. -// -// Jonathan Westhues, March 2006 -// Added ISO14443-A support by Gerhard de Koning Gans, April 2008 -//----------------------------------------------------------------------------- - -`include "lo_read.v" -`include "lo_passthru.v" -`include "lo_simulate.v" -`include "hi_read_tx.v" -`include "hi_read_rx_xcorr.v" -`include "hi_simulate.v" -`include "hi_iso14443a.v" -`include "util.v" - -module fpga( - spcki, miso, mosi, ncs, - pck0i, ck_1356meg, ck_1356megb, - pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, - adc_d, adc_clk, adc_noe, - ssp_frame, ssp_din, ssp_dout, ssp_clk, - cross_hi, cross_lo, - dbg -); - input spcki, mosi, ncs; - output miso; - input pck0i, ck_1356meg, ck_1356megb; - output pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; - input [7:0] adc_d; - output adc_clk, adc_noe; - input ssp_dout; - output ssp_frame, ssp_din, ssp_clk; - input cross_hi, cross_lo; - output dbg; - -//assign pck0 = pck0i; - IBUFG #(.IOSTANDARD("DEFAULT") ) pck0b( - .O(pck0), - .I(pck0i) - ); -//assign spck = spcki; - IBUFG #(.IOSTANDARD("DEFAULT") ) spckb( - .O(spck), - .I(spcki) - ); -//----------------------------------------------------------------------------- -// The SPI receiver. This sets up the configuration word, which the rest of -// the logic looks at to determine how to connect the A/D and the coil -// drivers (i.e., which section gets it). Also assign some symbolic names -// to the configuration bits, for use below. -//----------------------------------------------------------------------------- - -reg [15:0] shift_reg; -reg [7:0] divisor; -reg [7:0] conf_word; - -// We switch modes between transmitting to the 13.56 MHz tag and receiving -// from it, which means that we must make sure that we can do so without -// glitching, or else we will glitch the transmitted carrier. -always @(posedge ncs) -begin - case(shift_reg[15:12]) - 4'b0001: conf_word <= shift_reg[7:0]; - 4'b0010: divisor <= shift_reg[7:0]; - endcase -end - -always @(posedge spck) -begin - if(~ncs) - begin - shift_reg[15:1] <= shift_reg[14:0]; - shift_reg[0] <= mosi; - end -end - -wire [2:0] major_mode; -assign major_mode = conf_word[7:5]; - -// For the low-frequency configuration: -wire lo_is_125khz; -assign lo_is_125khz = conf_word[3]; - -// For the high-frequency transmit configuration: modulation depth, either -// 100% (just quite driving antenna, steady LOW), or shallower (tri-state -// some fraction of the buffers) -wire hi_read_tx_shallow_modulation; -assign hi_read_tx_shallow_modulation = conf_word[0]; - -// For the high-frequency receive correlator: frequency against which to -// correlate. -wire hi_read_rx_xcorr_848; -assign hi_read_rx_xcorr_848 = conf_word[0]; -// and whether to drive the coil (reader) or just short it (snooper) -wire hi_read_rx_xcorr_snoop; -assign hi_read_rx_xcorr_snoop = conf_word[1]; - -// Divide the expected subcarrier frequency for hi_read_rx_xcorr by 4 -wire hi_read_rx_xcorr_quarter; -assign hi_read_rx_xcorr_quarter = conf_word[2]; - -// For the high-frequency simulated tag: what kind of modulation to use. -wire [2:0] hi_simulate_mod_type; -assign hi_simulate_mod_type = conf_word[2:0]; - -//----------------------------------------------------------------------------- -// And then we instantiate the modules corresponding to each of the FPGA's -// major modes, and use muxes to connect the outputs of the active mode to -// the output pins. -//----------------------------------------------------------------------------- - -lo_read lr( - pck0, ck_1356meg, ck_1356megb, - lr_pwr_lo, lr_pwr_hi, lr_pwr_oe1, lr_pwr_oe2, lr_pwr_oe3, lr_pwr_oe4, - adc_d, lr_adc_clk, - lr_ssp_frame, lr_ssp_din, ssp_dout, lr_ssp_clk, - cross_hi, cross_lo, - lr_dbg, - lo_is_125khz, divisor -); - -lo_passthru lp( - pck0, ck_1356meg, ck_1356megb, - lp_pwr_lo, lp_pwr_hi, lp_pwr_oe1, lp_pwr_oe2, lp_pwr_oe3, lp_pwr_oe4, - adc_d, lp_adc_clk, - lp_ssp_frame, lp_ssp_din, ssp_dout, lp_ssp_clk, - cross_hi, cross_lo, - lp_dbg, divisor -); - -lo_simulate ls( - pck0, ck_1356meg, ck_1356megb, - ls_pwr_lo, ls_pwr_hi, ls_pwr_oe1, ls_pwr_oe2, ls_pwr_oe3, ls_pwr_oe4, - adc_d, ls_adc_clk, - ls_ssp_frame, ls_ssp_din, ssp_dout, ls_ssp_clk, - cross_hi, cross_lo, - ls_dbg, divisor -); - -hi_read_tx ht( - pck0, ck_1356meg, ck_1356megb, - ht_pwr_lo, ht_pwr_hi, ht_pwr_oe1, ht_pwr_oe2, ht_pwr_oe3, ht_pwr_oe4, - adc_d, ht_adc_clk, - ht_ssp_frame, ht_ssp_din, ssp_dout, ht_ssp_clk, - cross_hi, cross_lo, - ht_dbg, - hi_read_tx_shallow_modulation -); - -hi_read_rx_xcorr hrxc( - pck0, ck_1356meg, ck_1356megb, - hrxc_pwr_lo, hrxc_pwr_hi, hrxc_pwr_oe1, hrxc_pwr_oe2, hrxc_pwr_oe3, hrxc_pwr_oe4, - adc_d, hrxc_adc_clk, - hrxc_ssp_frame, hrxc_ssp_din, ssp_dout, hrxc_ssp_clk, - cross_hi, cross_lo, - hrxc_dbg, - hi_read_rx_xcorr_848, hi_read_rx_xcorr_snoop, hi_read_rx_xcorr_quarter -); - -hi_simulate hs( - pck0, ck_1356meg, ck_1356megb, - hs_pwr_lo, hs_pwr_hi, hs_pwr_oe1, hs_pwr_oe2, hs_pwr_oe3, hs_pwr_oe4, - adc_d, hs_adc_clk, - hs_ssp_frame, hs_ssp_din, ssp_dout, hs_ssp_clk, - cross_hi, cross_lo, - hs_dbg, - hi_simulate_mod_type -); - -hi_iso14443a hisn( - pck0, ck_1356meg, ck_1356megb, - hisn_pwr_lo, hisn_pwr_hi, hisn_pwr_oe1, hisn_pwr_oe2, hisn_pwr_oe3, hisn_pwr_oe4, - adc_d, hisn_adc_clk, - hisn_ssp_frame, hisn_ssp_din, ssp_dout, hisn_ssp_clk, - cross_hi, cross_lo, - hisn_dbg, - hi_simulate_mod_type -); - -// Major modes: -// 000 -- LF reader (generic) -// 001 -- LF simulated tag (generic) -// 010 -- HF reader, transmitting to tag; modulation depth selectable -// 011 -- HF reader, receiving from tag, correlating as it goes; frequency selectable -// 100 -- HF simulated tag -// 101 -- HF ISO14443-A -// 110 -- LF passthrough -// 111 -- everything off - -mux8 mux_ssp_clk (major_mode, ssp_clk, lr_ssp_clk, ls_ssp_clk, ht_ssp_clk, hrxc_ssp_clk, hs_ssp_clk, hisn_ssp_clk, lp_ssp_clk, 1'b0); -mux8 mux_ssp_din (major_mode, ssp_din, lr_ssp_din, ls_ssp_din, ht_ssp_din, hrxc_ssp_din, hs_ssp_din, hisn_ssp_din, lp_ssp_din, 1'b0); -mux8 mux_ssp_frame (major_mode, ssp_frame, lr_ssp_frame, ls_ssp_frame, ht_ssp_frame, hrxc_ssp_frame, hs_ssp_frame, hisn_ssp_frame, lp_ssp_frame, 1'b0); -mux8 mux_pwr_oe1 (major_mode, pwr_oe1, lr_pwr_oe1, ls_pwr_oe1, ht_pwr_oe1, hrxc_pwr_oe1, hs_pwr_oe1, hisn_pwr_oe1, lp_pwr_oe1, 1'b0); -mux8 mux_pwr_oe2 (major_mode, pwr_oe2, lr_pwr_oe2, ls_pwr_oe2, ht_pwr_oe2, hrxc_pwr_oe2, hs_pwr_oe2, hisn_pwr_oe2, lp_pwr_oe2, 1'b0); -mux8 mux_pwr_oe3 (major_mode, pwr_oe3, lr_pwr_oe3, ls_pwr_oe3, ht_pwr_oe3, hrxc_pwr_oe3, hs_pwr_oe3, hisn_pwr_oe3, lp_pwr_oe3, 1'b0); -mux8 mux_pwr_oe4 (major_mode, pwr_oe4, lr_pwr_oe4, ls_pwr_oe4, ht_pwr_oe4, hrxc_pwr_oe4, hs_pwr_oe4, hisn_pwr_oe4, lp_pwr_oe4, 1'b0); -mux8 mux_pwr_lo (major_mode, pwr_lo, lr_pwr_lo, ls_pwr_lo, ht_pwr_lo, hrxc_pwr_lo, hs_pwr_lo, hisn_pwr_lo, lp_pwr_lo, 1'b0); -mux8 mux_pwr_hi (major_mode, pwr_hi, lr_pwr_hi, ls_pwr_hi, ht_pwr_hi, hrxc_pwr_hi, hs_pwr_hi, hisn_pwr_hi, lp_pwr_hi, 1'b0); -mux8 mux_adc_clk (major_mode, adc_clk, lr_adc_clk, ls_adc_clk, ht_adc_clk, hrxc_adc_clk, hs_adc_clk, hisn_adc_clk, lp_adc_clk, 1'b0); -mux8 mux_dbg (major_mode, dbg, lr_dbg, ls_dbg, ht_dbg, hrxc_dbg, hs_dbg, hisn_dbg, lp_dbg, 1'b0); - -// In all modes, let the ADC's outputs be enabled. -assign adc_noe = 1'b0; - -endmodule +//----------------------------------------------------------------------------- +// The FPGA is responsible for interfacing between the A/D, the coil drivers, +// and the ARM. In the low-frequency modes it passes the data straight +// through, so that the ARM gets raw A/D samples over the SSP. In the high- +// frequency modes, the FPGA might perform some demodulation first, to +// reduce the amount of data that we must send to the ARM. +// +// I am not really an FPGA/ASIC designer, so I am sure that a lot of this +// could be improved. +// +// Jonathan Westhues, March 2006 +// Added ISO14443-A support by Gerhard de Koning Gans, April 2008 +//----------------------------------------------------------------------------- + +`include "lo_read.v" +`include "lo_passthru.v" +`include "lo_simulate.v" +`include "hi_read_tx.v" +`include "hi_read_rx_xcorr.v" +`include "hi_simulate.v" +`include "hi_iso14443a.v" +`include "util.v" + +module fpga( + spcki, miso, mosi, ncs, + pck0i, ck_1356meg, ck_1356megb, + pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, + adc_d, adc_clk, adc_noe, + ssp_frame, ssp_din, ssp_dout, ssp_clk, + cross_hi, cross_lo, + dbg +); + input spcki, mosi, ncs; + output miso; + input pck0i, ck_1356meg, ck_1356megb; + output pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; + input [7:0] adc_d; + output adc_clk, adc_noe; + input ssp_dout; + output ssp_frame, ssp_din, ssp_clk; + input cross_hi, cross_lo; + output dbg; + +//assign pck0 = pck0i; + IBUFG #(.IOSTANDARD("DEFAULT") ) pck0b( + .O(pck0), + .I(pck0i) + ); +//assign spck = spcki; + IBUFG #(.IOSTANDARD("DEFAULT") ) spckb( + .O(spck), + .I(spcki) + ); +//----------------------------------------------------------------------------- +// The SPI receiver. This sets up the configuration word, which the rest of +// the logic looks at to determine how to connect the A/D and the coil +// drivers (i.e., which section gets it). Also assign some symbolic names +// to the configuration bits, for use below. +//----------------------------------------------------------------------------- + +reg [15:0] shift_reg; +reg [7:0] divisor; +reg [7:0] conf_word; + +// We switch modes between transmitting to the 13.56 MHz tag and receiving +// from it, which means that we must make sure that we can do so without +// glitching, or else we will glitch the transmitted carrier. +always @(posedge ncs) +begin + case(shift_reg[15:12]) + 4'b0001: conf_word <= shift_reg[7:0]; + 4'b0010: divisor <= shift_reg[7:0]; + endcase +end + +always @(posedge spck) +begin + if(~ncs) + begin + shift_reg[15:1] <= shift_reg[14:0]; + shift_reg[0] <= mosi; + end +end + +wire [2:0] major_mode; +assign major_mode = conf_word[7:5]; + +// For the low-frequency configuration: +wire lo_is_125khz; +assign lo_is_125khz = conf_word[3]; + +// For the high-frequency transmit configuration: modulation depth, either +// 100% (just quite driving antenna, steady LOW), or shallower (tri-state +// some fraction of the buffers) +wire hi_read_tx_shallow_modulation; +assign hi_read_tx_shallow_modulation = conf_word[0]; + +// For the high-frequency receive correlator: frequency against which to +// correlate. +wire hi_read_rx_xcorr_848; +assign hi_read_rx_xcorr_848 = conf_word[0]; +// and whether to drive the coil (reader) or just short it (snooper) +wire hi_read_rx_xcorr_snoop; +assign hi_read_rx_xcorr_snoop = conf_word[1]; + +// Divide the expected subcarrier frequency for hi_read_rx_xcorr by 4 +wire hi_read_rx_xcorr_quarter; +assign hi_read_rx_xcorr_quarter = conf_word[2]; + +// For the high-frequency simulated tag: what kind of modulation to use. +wire [2:0] hi_simulate_mod_type; +assign hi_simulate_mod_type = conf_word[2:0]; + +//----------------------------------------------------------------------------- +// And then we instantiate the modules corresponding to each of the FPGA's +// major modes, and use muxes to connect the outputs of the active mode to +// the output pins. +//----------------------------------------------------------------------------- + +lo_read lr( + pck0, ck_1356meg, ck_1356megb, + lr_pwr_lo, lr_pwr_hi, lr_pwr_oe1, lr_pwr_oe2, lr_pwr_oe3, lr_pwr_oe4, + adc_d, lr_adc_clk, + lr_ssp_frame, lr_ssp_din, ssp_dout, lr_ssp_clk, + cross_hi, cross_lo, + lr_dbg, + lo_is_125khz, divisor +); + +lo_passthru lp( + pck0, ck_1356meg, ck_1356megb, + lp_pwr_lo, lp_pwr_hi, lp_pwr_oe1, lp_pwr_oe2, lp_pwr_oe3, lp_pwr_oe4, + adc_d, lp_adc_clk, + lp_ssp_frame, lp_ssp_din, ssp_dout, lp_ssp_clk, + cross_hi, cross_lo, + lp_dbg, divisor +); + +lo_simulate ls( + pck0, ck_1356meg, ck_1356megb, + ls_pwr_lo, ls_pwr_hi, ls_pwr_oe1, ls_pwr_oe2, ls_pwr_oe3, ls_pwr_oe4, + adc_d, ls_adc_clk, + ls_ssp_frame, ls_ssp_din, ssp_dout, ls_ssp_clk, + cross_hi, cross_lo, + ls_dbg, divisor +); + +hi_read_tx ht( + pck0, ck_1356meg, ck_1356megb, + ht_pwr_lo, ht_pwr_hi, ht_pwr_oe1, ht_pwr_oe2, ht_pwr_oe3, ht_pwr_oe4, + adc_d, ht_adc_clk, + ht_ssp_frame, ht_ssp_din, ssp_dout, ht_ssp_clk, + cross_hi, cross_lo, + ht_dbg, + hi_read_tx_shallow_modulation +); + +hi_read_rx_xcorr hrxc( + pck0, ck_1356meg, ck_1356megb, + hrxc_pwr_lo, hrxc_pwr_hi, hrxc_pwr_oe1, hrxc_pwr_oe2, hrxc_pwr_oe3, hrxc_pwr_oe4, + adc_d, hrxc_adc_clk, + hrxc_ssp_frame, hrxc_ssp_din, ssp_dout, hrxc_ssp_clk, + cross_hi, cross_lo, + hrxc_dbg, + hi_read_rx_xcorr_848, hi_read_rx_xcorr_snoop, hi_read_rx_xcorr_quarter +); + +hi_simulate hs( + pck0, ck_1356meg, ck_1356megb, + hs_pwr_lo, hs_pwr_hi, hs_pwr_oe1, hs_pwr_oe2, hs_pwr_oe3, hs_pwr_oe4, + adc_d, hs_adc_clk, + hs_ssp_frame, hs_ssp_din, ssp_dout, hs_ssp_clk, + cross_hi, cross_lo, + hs_dbg, + hi_simulate_mod_type +); + +hi_iso14443a hisn( + pck0, ck_1356meg, ck_1356megb, + hisn_pwr_lo, hisn_pwr_hi, hisn_pwr_oe1, hisn_pwr_oe2, hisn_pwr_oe3, hisn_pwr_oe4, + adc_d, hisn_adc_clk, + hisn_ssp_frame, hisn_ssp_din, ssp_dout, hisn_ssp_clk, + cross_hi, cross_lo, + hisn_dbg, + hi_simulate_mod_type +); + +// Major modes: +// 000 -- LF reader (generic) +// 001 -- LF simulated tag (generic) +// 010 -- HF reader, transmitting to tag; modulation depth selectable +// 011 -- HF reader, receiving from tag, correlating as it goes; frequency selectable +// 100 -- HF simulated tag +// 101 -- HF ISO14443-A +// 110 -- LF passthrough +// 111 -- everything off + +mux8 mux_ssp_clk (major_mode, ssp_clk, lr_ssp_clk, ls_ssp_clk, ht_ssp_clk, hrxc_ssp_clk, hs_ssp_clk, hisn_ssp_clk, lp_ssp_clk, 1'b0); +mux8 mux_ssp_din (major_mode, ssp_din, lr_ssp_din, ls_ssp_din, ht_ssp_din, hrxc_ssp_din, hs_ssp_din, hisn_ssp_din, lp_ssp_din, 1'b0); +mux8 mux_ssp_frame (major_mode, ssp_frame, lr_ssp_frame, ls_ssp_frame, ht_ssp_frame, hrxc_ssp_frame, hs_ssp_frame, hisn_ssp_frame, lp_ssp_frame, 1'b0); +mux8 mux_pwr_oe1 (major_mode, pwr_oe1, lr_pwr_oe1, ls_pwr_oe1, ht_pwr_oe1, hrxc_pwr_oe1, hs_pwr_oe1, hisn_pwr_oe1, lp_pwr_oe1, 1'b0); +mux8 mux_pwr_oe2 (major_mode, pwr_oe2, lr_pwr_oe2, ls_pwr_oe2, ht_pwr_oe2, hrxc_pwr_oe2, hs_pwr_oe2, hisn_pwr_oe2, lp_pwr_oe2, 1'b0); +mux8 mux_pwr_oe3 (major_mode, pwr_oe3, lr_pwr_oe3, ls_pwr_oe3, ht_pwr_oe3, hrxc_pwr_oe3, hs_pwr_oe3, hisn_pwr_oe3, lp_pwr_oe3, 1'b0); +mux8 mux_pwr_oe4 (major_mode, pwr_oe4, lr_pwr_oe4, ls_pwr_oe4, ht_pwr_oe4, hrxc_pwr_oe4, hs_pwr_oe4, hisn_pwr_oe4, lp_pwr_oe4, 1'b0); +mux8 mux_pwr_lo (major_mode, pwr_lo, lr_pwr_lo, ls_pwr_lo, ht_pwr_lo, hrxc_pwr_lo, hs_pwr_lo, hisn_pwr_lo, lp_pwr_lo, 1'b0); +mux8 mux_pwr_hi (major_mode, pwr_hi, lr_pwr_hi, ls_pwr_hi, ht_pwr_hi, hrxc_pwr_hi, hs_pwr_hi, hisn_pwr_hi, lp_pwr_hi, 1'b0); +mux8 mux_adc_clk (major_mode, adc_clk, lr_adc_clk, ls_adc_clk, ht_adc_clk, hrxc_adc_clk, hs_adc_clk, hisn_adc_clk, lp_adc_clk, 1'b0); +mux8 mux_dbg (major_mode, dbg, lr_dbg, ls_dbg, ht_dbg, hrxc_dbg, hs_dbg, hisn_dbg, lp_dbg, 1'b0); + +// In all modes, let the ADC's outputs be enabled. +assign adc_noe = 1'b0; + +endmodule diff --git a/fpga/hi_read_rx_xcorr.v b/fpga/hi_read_rx_xcorr.v index 9d012f42..dece2db3 100644 --- a/fpga/hi_read_rx_xcorr.v +++ b/fpga/hi_read_rx_xcorr.v @@ -1,185 +1,185 @@ -//----------------------------------------------------------------------------- -// -// Jonathan Westhues, April 2006 -//----------------------------------------------------------------------------- - -module hi_read_rx_xcorr( - pck0, ck_1356meg, ck_1356megb, - pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, - adc_d, adc_clk, - ssp_frame, ssp_din, ssp_dout, ssp_clk, - cross_hi, cross_lo, - dbg, - xcorr_is_848, snoop, xcorr_quarter_freq -); - input pck0, ck_1356meg, ck_1356megb; - output pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; - input [7:0] adc_d; - output adc_clk; - input ssp_dout; - output ssp_frame, ssp_din, ssp_clk; - input cross_hi, cross_lo; - output dbg; - input xcorr_is_848, snoop, xcorr_quarter_freq; - -// Carrier is steady on through this, unless we're snooping. -assign pwr_hi = ck_1356megb & (~snoop); -assign pwr_oe1 = 1'b0; -assign pwr_oe2 = 1'b0; -assign pwr_oe3 = 1'b0; -assign pwr_oe4 = 1'b0; - -reg ssp_clk; -reg ssp_frame; - -reg fc_div_2; -always @(posedge ck_1356meg) - fc_div_2 = ~fc_div_2; - -reg fc_div_4; -always @(posedge fc_div_2) - fc_div_4 = ~fc_div_4; - -reg fc_div_8; -always @(posedge fc_div_4) - fc_div_8 = ~fc_div_8; - -reg adc_clk; - -always @(xcorr_is_848 or xcorr_quarter_freq or ck_1356meg) - if(~xcorr_quarter_freq) - begin - if(xcorr_is_848) - // The subcarrier frequency is fc/16; we will sample at fc, so that - // means the subcarrier is 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 ... - adc_clk <= ck_1356meg; - else - // The subcarrier frequency is fc/32; we will sample at fc/2, and - // the subcarrier will look identical. - adc_clk <= fc_div_2; - end - else - begin - if(xcorr_is_848) - // The subcarrier frequency is fc/64 - adc_clk <= fc_div_4; - else - // The subcarrier frequency is fc/128 - adc_clk <= fc_div_8; - end - -// When we're a reader, we just need to do the BPSK demod; but when we're an -// eavesdropper, we also need to pick out the commands sent by the reader, -// using AM. Do this the same way that we do it for the simulated tag. -reg after_hysteresis, after_hysteresis_prev; -reg [11:0] has_been_low_for; -always @(negedge adc_clk) -begin - if(& adc_d[7:0]) after_hysteresis <= 1'b1; - else if(~(| adc_d[7:0])) after_hysteresis <= 1'b0; - - if(after_hysteresis) - begin - has_been_low_for <= 7'b0; - end - else - begin - if(has_been_low_for == 12'd4095) - begin - has_been_low_for <= 12'd0; - after_hysteresis <= 1'b1; - end - else - has_been_low_for <= has_been_low_for + 1; - end -end - -// Let us report a correlation every 4 subcarrier cycles, or 4*16 samples, -// so we need a 6-bit counter. -reg [5:0] corr_i_cnt; -reg [5:0] corr_q_cnt; -// And a couple of registers in which to accumulate the correlations. -reg signed [15:0] corr_i_accum; -reg signed [15:0] corr_q_accum; -reg signed [7:0] corr_i_out; -reg signed [7:0] corr_q_out; - -// ADC data appears on the rising edge, so sample it on the falling edge -always @(negedge adc_clk) -begin - // These are the correlators: we correlate against in-phase and quadrature - // versions of our reference signal, and keep the (signed) result to - // send out later over the SSP. - if(corr_i_cnt == 7'd63) - begin - if(snoop) - begin - corr_i_out <= {corr_i_accum[12:6], after_hysteresis_prev}; - corr_q_out <= {corr_q_accum[12:6], after_hysteresis}; - end - else - begin - // Only correlations need to be delivered. - corr_i_out <= corr_i_accum[13:6]; - corr_q_out <= corr_q_accum[13:6]; - end - - corr_i_accum <= adc_d; - corr_q_accum <= adc_d; - corr_q_cnt <= 4; - corr_i_cnt <= 0; - end - else - begin - if(corr_i_cnt[3]) - corr_i_accum <= corr_i_accum - adc_d; - else - corr_i_accum <= corr_i_accum + adc_d; - - if(corr_q_cnt[3]) - corr_q_accum <= corr_q_accum - adc_d; - else - corr_q_accum <= corr_q_accum + adc_d; - - corr_i_cnt <= corr_i_cnt + 1; - corr_q_cnt <= corr_q_cnt + 1; - end - - // The logic in hi_simulate.v reports 4 samples per bit. We report two - // (I, Q) pairs per bit, so we should do 2 samples per pair. - if(corr_i_cnt == 6'd31) - after_hysteresis_prev <= after_hysteresis; - - // Then the result from last time is serialized and send out to the ARM. - // We get one report each cycle, and each report is 16 bits, so the - // ssp_clk should be the adc_clk divided by 64/16 = 4. - - if(corr_i_cnt[1:0] == 2'b10) - ssp_clk <= 1'b0; - - if(corr_i_cnt[1:0] == 2'b00) - begin - ssp_clk <= 1'b1; - // Don't shift if we just loaded new data, obviously. - if(corr_i_cnt != 7'd0) - begin - corr_i_out[7:0] <= {corr_i_out[6:0], corr_q_out[7]}; - corr_q_out[7:1] <= corr_q_out[6:0]; - end - end - - if(corr_i_cnt[5:2] == 4'b000 || corr_i_cnt[5:2] == 4'b1000) - ssp_frame = 1'b1; - else - ssp_frame = 1'b0; - -end - -assign ssp_din = corr_i_out[7]; - -assign dbg = corr_i_cnt[3]; - -// Unused. -assign pwr_lo = 1'b0; - -endmodule +//----------------------------------------------------------------------------- +// +// Jonathan Westhues, April 2006 +//----------------------------------------------------------------------------- + +module hi_read_rx_xcorr( + pck0, ck_1356meg, ck_1356megb, + pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, + adc_d, adc_clk, + ssp_frame, ssp_din, ssp_dout, ssp_clk, + cross_hi, cross_lo, + dbg, + xcorr_is_848, snoop, xcorr_quarter_freq +); + input pck0, ck_1356meg, ck_1356megb; + output pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; + input [7:0] adc_d; + output adc_clk; + input ssp_dout; + output ssp_frame, ssp_din, ssp_clk; + input cross_hi, cross_lo; + output dbg; + input xcorr_is_848, snoop, xcorr_quarter_freq; + +// Carrier is steady on through this, unless we're snooping. +assign pwr_hi = ck_1356megb & (~snoop); +assign pwr_oe1 = 1'b0; +assign pwr_oe2 = 1'b0; +assign pwr_oe3 = 1'b0; +assign pwr_oe4 = 1'b0; + +reg ssp_clk; +reg ssp_frame; + +reg fc_div_2; +always @(posedge ck_1356meg) + fc_div_2 = ~fc_div_2; + +reg fc_div_4; +always @(posedge fc_div_2) + fc_div_4 = ~fc_div_4; + +reg fc_div_8; +always @(posedge fc_div_4) + fc_div_8 = ~fc_div_8; + +reg adc_clk; + +always @(xcorr_is_848 or xcorr_quarter_freq or ck_1356meg) + if(~xcorr_quarter_freq) + begin + if(xcorr_is_848) + // The subcarrier frequency is fc/16; we will sample at fc, so that + // means the subcarrier is 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 ... + adc_clk <= ck_1356meg; + else + // The subcarrier frequency is fc/32; we will sample at fc/2, and + // the subcarrier will look identical. + adc_clk <= fc_div_2; + end + else + begin + if(xcorr_is_848) + // The subcarrier frequency is fc/64 + adc_clk <= fc_div_4; + else + // The subcarrier frequency is fc/128 + adc_clk <= fc_div_8; + end + +// When we're a reader, we just need to do the BPSK demod; but when we're an +// eavesdropper, we also need to pick out the commands sent by the reader, +// using AM. Do this the same way that we do it for the simulated tag. +reg after_hysteresis, after_hysteresis_prev; +reg [11:0] has_been_low_for; +always @(negedge adc_clk) +begin + if(& adc_d[7:0]) after_hysteresis <= 1'b1; + else if(~(| adc_d[7:0])) after_hysteresis <= 1'b0; + + if(after_hysteresis) + begin + has_been_low_for <= 7'b0; + end + else + begin + if(has_been_low_for == 12'd4095) + begin + has_been_low_for <= 12'd0; + after_hysteresis <= 1'b1; + end + else + has_been_low_for <= has_been_low_for + 1; + end +end + +// Let us report a correlation every 4 subcarrier cycles, or 4*16 samples, +// so we need a 6-bit counter. +reg [5:0] corr_i_cnt; +reg [5:0] corr_q_cnt; +// And a couple of registers in which to accumulate the correlations. +reg signed [15:0] corr_i_accum; +reg signed [15:0] corr_q_accum; +reg signed [7:0] corr_i_out; +reg signed [7:0] corr_q_out; + +// ADC data appears on the rising edge, so sample it on the falling edge +always @(negedge adc_clk) +begin + // These are the correlators: we correlate against in-phase and quadrature + // versions of our reference signal, and keep the (signed) result to + // send out later over the SSP. + if(corr_i_cnt == 7'd63) + begin + if(snoop) + begin + corr_i_out <= {corr_i_accum[12:6], after_hysteresis_prev}; + corr_q_out <= {corr_q_accum[12:6], after_hysteresis}; + end + else + begin + // Only correlations need to be delivered. + corr_i_out <= corr_i_accum[13:6]; + corr_q_out <= corr_q_accum[13:6]; + end + + corr_i_accum <= adc_d; + corr_q_accum <= adc_d; + corr_q_cnt <= 4; + corr_i_cnt <= 0; + end + else + begin + if(corr_i_cnt[3]) + corr_i_accum <= corr_i_accum - adc_d; + else + corr_i_accum <= corr_i_accum + adc_d; + + if(corr_q_cnt[3]) + corr_q_accum <= corr_q_accum - adc_d; + else + corr_q_accum <= corr_q_accum + adc_d; + + corr_i_cnt <= corr_i_cnt + 1; + corr_q_cnt <= corr_q_cnt + 1; + end + + // The logic in hi_simulate.v reports 4 samples per bit. We report two + // (I, Q) pairs per bit, so we should do 2 samples per pair. + if(corr_i_cnt == 6'd31) + after_hysteresis_prev <= after_hysteresis; + + // Then the result from last time is serialized and send out to the ARM. + // We get one report each cycle, and each report is 16 bits, so the + // ssp_clk should be the adc_clk divided by 64/16 = 4. + + if(corr_i_cnt[1:0] == 2'b10) + ssp_clk <= 1'b0; + + if(corr_i_cnt[1:0] == 2'b00) + begin + ssp_clk <= 1'b1; + // Don't shift if we just loaded new data, obviously. + if(corr_i_cnt != 7'd0) + begin + corr_i_out[7:0] <= {corr_i_out[6:0], corr_q_out[7]}; + corr_q_out[7:1] <= corr_q_out[6:0]; + end + end + + if(corr_i_cnt[5:2] == 4'b000 || corr_i_cnt[5:2] == 4'b1000) + ssp_frame = 1'b1; + else + ssp_frame = 1'b0; + +end + +assign ssp_din = corr_i_out[7]; + +assign dbg = corr_i_cnt[3]; + +// Unused. +assign pwr_lo = 1'b0; + +endmodule diff --git a/fpga/hi_read_tx.v b/fpga/hi_read_tx.v index 5ddc974d..f12e64eb 100644 --- a/fpga/hi_read_tx.v +++ b/fpga/hi_read_tx.v @@ -1,89 +1,89 @@ -//----------------------------------------------------------------------------- -// The way that we connect things when transmitting a command to an ISO -// 15693 tag, using 100% modulation only for now. -// -// Jonathan Westhues, April 2006 -//----------------------------------------------------------------------------- - -module hi_read_tx( - pck0, ck_1356meg, ck_1356megb, - pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, - adc_d, adc_clk, - ssp_frame, ssp_din, ssp_dout, ssp_clk, - cross_hi, cross_lo, - dbg, - shallow_modulation -); - input pck0, ck_1356meg, ck_1356megb; - output pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; - input [7:0] adc_d; - output adc_clk; - input ssp_dout; - output ssp_frame, ssp_din, ssp_clk; - input cross_hi, cross_lo; - output dbg; - input shallow_modulation; - -// The high-frequency stuff. For now, for testing, just bring out the carrier, -// and allow the ARM to modulate it over the SSP. -reg pwr_hi; -reg pwr_oe1; -reg pwr_oe2; -reg pwr_oe3; -reg pwr_oe4; -always @(ck_1356megb or ssp_dout or shallow_modulation) -begin - if(shallow_modulation) - begin - pwr_hi <= ck_1356megb; - pwr_oe1 <= ~ssp_dout; - pwr_oe2 <= ~ssp_dout; - pwr_oe3 <= ~ssp_dout; - pwr_oe4 <= 1'b0; - end - else - begin - pwr_hi <= ck_1356megb & ssp_dout; - pwr_oe1 <= 1'b0; - pwr_oe2 <= 1'b0; - pwr_oe3 <= 1'b0; - pwr_oe4 <= 1'b0; - end -end - -// Then just divide the 13.56 MHz clock down to produce appropriate clocks -// for the synchronous serial port. - -reg [6:0] hi_div_by_128; - -always @(posedge ck_1356meg) - hi_div_by_128 <= hi_div_by_128 + 1; - -assign ssp_clk = hi_div_by_128[6]; - -reg [2:0] hi_byte_div; - -always @(negedge ssp_clk) - hi_byte_div <= hi_byte_div + 1; - -assign ssp_frame = (hi_byte_div == 3'b000); - -// Implement a hysteresis to give out the received signal on -// ssp_din. Sample at fc. -assign adc_clk = ck_1356meg; - -// ADC data appears on the rising edge, so sample it on the falling edge -reg after_hysteresis; -always @(negedge adc_clk) -begin - if(& adc_d[7:0]) after_hysteresis <= 1'b1; - else if(~(| adc_d[7:0])) after_hysteresis <= 1'b0; -end - - -assign ssp_din = after_hysteresis; - -assign pwr_lo = 1'b0; -assign dbg = ssp_din; - -endmodule +//----------------------------------------------------------------------------- +// The way that we connect things when transmitting a command to an ISO +// 15693 tag, using 100% modulation only for now. +// +// Jonathan Westhues, April 2006 +//----------------------------------------------------------------------------- + +module hi_read_tx( + pck0, ck_1356meg, ck_1356megb, + pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, + adc_d, adc_clk, + ssp_frame, ssp_din, ssp_dout, ssp_clk, + cross_hi, cross_lo, + dbg, + shallow_modulation +); + input pck0, ck_1356meg, ck_1356megb; + output pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; + input [7:0] adc_d; + output adc_clk; + input ssp_dout; + output ssp_frame, ssp_din, ssp_clk; + input cross_hi, cross_lo; + output dbg; + input shallow_modulation; + +// The high-frequency stuff. For now, for testing, just bring out the carrier, +// and allow the ARM to modulate it over the SSP. +reg pwr_hi; +reg pwr_oe1; +reg pwr_oe2; +reg pwr_oe3; +reg pwr_oe4; +always @(ck_1356megb or ssp_dout or shallow_modulation) +begin + if(shallow_modulation) + begin + pwr_hi <= ck_1356megb; + pwr_oe1 <= ~ssp_dout; + pwr_oe2 <= ~ssp_dout; + pwr_oe3 <= ~ssp_dout; + pwr_oe4 <= 1'b0; + end + else + begin + pwr_hi <= ck_1356megb & ssp_dout; + pwr_oe1 <= 1'b0; + pwr_oe2 <= 1'b0; + pwr_oe3 <= 1'b0; + pwr_oe4 <= 1'b0; + end +end + +// Then just divide the 13.56 MHz clock down to produce appropriate clocks +// for the synchronous serial port. + +reg [6:0] hi_div_by_128; + +always @(posedge ck_1356meg) + hi_div_by_128 <= hi_div_by_128 + 1; + +assign ssp_clk = hi_div_by_128[6]; + +reg [2:0] hi_byte_div; + +always @(negedge ssp_clk) + hi_byte_div <= hi_byte_div + 1; + +assign ssp_frame = (hi_byte_div == 3'b000); + +// Implement a hysteresis to give out the received signal on +// ssp_din. Sample at fc. +assign adc_clk = ck_1356meg; + +// ADC data appears on the rising edge, so sample it on the falling edge +reg after_hysteresis; +always @(negedge adc_clk) +begin + if(& adc_d[7:0]) after_hysteresis <= 1'b1; + else if(~(| adc_d[7:0])) after_hysteresis <= 1'b0; +end + + +assign ssp_din = after_hysteresis; + +assign pwr_lo = 1'b0; +assign dbg = ssp_din; + +endmodule diff --git a/fpga/hi_simulate.v b/fpga/hi_simulate.v index 05662e53..efaf452f 100644 --- a/fpga/hi_simulate.v +++ b/fpga/hi_simulate.v @@ -1,109 +1,109 @@ -//----------------------------------------------------------------------------- -// Pretend to be an ISO 14443 tag. We will do this by alternately short- -// circuiting and open-circuiting the antenna coil, with the tri-state -// pins. -// -// We communicate over the SSP, as a bitstream (i.e., might as well be -// unframed, though we still generate the word sync signal). The output -// (ARM -> FPGA) tells us whether to modulate or not. The input (FPGA -// -> ARM) is us using the A/D as a fancy comparator; this is with -// (software-added) hysteresis, to undo the high-pass filter. -// -// At this point only Type A is implemented. This means that we are using a -// bit rate of 106 kbit/s, or fc/128. Oversample by 4, which ought to make -// things practical for the ARM (fc/32, 423.8 kbits/s, ~50 kbytes/s) -// -// Jonathan Westhues, October 2006 -//----------------------------------------------------------------------------- - -module hi_simulate( - pck0, ck_1356meg, ck_1356megb, - pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, - adc_d, adc_clk, - ssp_frame, ssp_din, ssp_dout, ssp_clk, - cross_hi, cross_lo, - dbg, - mod_type -); - input pck0, ck_1356meg, ck_1356megb; - output pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; - input [7:0] adc_d; - output adc_clk; - input ssp_dout; - output ssp_frame, ssp_din, ssp_clk; - input cross_hi, cross_lo; - output dbg; - input [2:0] mod_type; - -// Power amp goes between LOW and tri-state, so pwr_hi (and pwr_lo) can -// always be low. -assign pwr_hi = 1'b0; -assign pwr_lo = 1'b0; - -// The comparator with hysteresis on the output from the peak detector. -reg after_hysteresis; -assign adc_clk = ck_1356meg; - -always @(negedge adc_clk) -begin - if(& adc_d[7:5]) after_hysteresis = 1'b1; - else if(~(| adc_d[7:5])) after_hysteresis = 1'b0; -end - -// Divide 13.56 MHz by 32 to produce the SSP_CLK -// The register is bigger to allow higher division factors of up to /128 -reg [6:0] ssp_clk_divider; -always @(posedge adc_clk) - ssp_clk_divider <= (ssp_clk_divider + 1); -assign ssp_clk = ssp_clk_divider[4]; - -// Divide SSP_CLK by 8 to produce the byte framing signal; the phase of -// this is arbitrary, because it's just a bitstream. -// One nasty issue, though: I can't make it work with both rx and tx at -// once. The phase wrt ssp_clk must be changed. TODO to find out why -// that is and make a better fix. -reg [2:0] ssp_frame_divider_to_arm; -always @(posedge ssp_clk) - ssp_frame_divider_to_arm <= (ssp_frame_divider_to_arm + 1); -reg [2:0] ssp_frame_divider_from_arm; -always @(negedge ssp_clk) - ssp_frame_divider_from_arm <= (ssp_frame_divider_from_arm + 1); - -reg ssp_frame; -always @(ssp_frame_divider_to_arm or ssp_frame_divider_from_arm or mod_type) - if(mod_type == 3'b000) // not modulating, so listening, to ARM - ssp_frame = (ssp_frame_divider_to_arm == 3'b000); - else - ssp_frame = (ssp_frame_divider_from_arm == 3'b000); - -// Synchronize up the after-hysteresis signal, to produce DIN. -reg ssp_din; -always @(posedge ssp_clk) - ssp_din = after_hysteresis; - -// Modulating carrier frequency is fc/16, reuse ssp_clk divider for that -reg modulating_carrier; -always @(mod_type or ssp_clk or ssp_dout) - if(mod_type == 3'b000) - modulating_carrier <= 1'b0; // no modulation - else if(mod_type == 3'b001) - modulating_carrier <= ssp_dout ^ ssp_clk_divider[3]; // XOR means BPSK - else if(mod_type == 3'b010) - modulating_carrier <= ssp_dout & ssp_clk_divider[5]; // switch 212kHz subcarrier on/off - else - modulating_carrier <= 1'b0; // yet unused - -// This one is all LF, so doesn't matter -assign pwr_oe2 = modulating_carrier; - -// Toggle only one of these, since we are already producing much deeper -// modulation than a real tag would. -assign pwr_oe1 = modulating_carrier; -assign pwr_oe4 = modulating_carrier; - -// This one is always on, so that we can watch the carrier. -assign pwr_oe3 = 1'b0; - -assign dbg = after_hysteresis; - -endmodule +//----------------------------------------------------------------------------- +// Pretend to be an ISO 14443 tag. We will do this by alternately short- +// circuiting and open-circuiting the antenna coil, with the tri-state +// pins. +// +// We communicate over the SSP, as a bitstream (i.e., might as well be +// unframed, though we still generate the word sync signal). The output +// (ARM -> FPGA) tells us whether to modulate or not. The input (FPGA +// -> ARM) is us using the A/D as a fancy comparator; this is with +// (software-added) hysteresis, to undo the high-pass filter. +// +// At this point only Type A is implemented. This means that we are using a +// bit rate of 106 kbit/s, or fc/128. Oversample by 4, which ought to make +// things practical for the ARM (fc/32, 423.8 kbits/s, ~50 kbytes/s) +// +// Jonathan Westhues, October 2006 +//----------------------------------------------------------------------------- + +module hi_simulate( + pck0, ck_1356meg, ck_1356megb, + pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, + adc_d, adc_clk, + ssp_frame, ssp_din, ssp_dout, ssp_clk, + cross_hi, cross_lo, + dbg, + mod_type +); + input pck0, ck_1356meg, ck_1356megb; + output pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; + input [7:0] adc_d; + output adc_clk; + input ssp_dout; + output ssp_frame, ssp_din, ssp_clk; + input cross_hi, cross_lo; + output dbg; + input [2:0] mod_type; + +// Power amp goes between LOW and tri-state, so pwr_hi (and pwr_lo) can +// always be low. +assign pwr_hi = 1'b0; +assign pwr_lo = 1'b0; + +// The comparator with hysteresis on the output from the peak detector. +reg after_hysteresis; +assign adc_clk = ck_1356meg; + +always @(negedge adc_clk) +begin + if(& adc_d[7:5]) after_hysteresis = 1'b1; + else if(~(| adc_d[7:5])) after_hysteresis = 1'b0; +end + +// Divide 13.56 MHz by 32 to produce the SSP_CLK +// The register is bigger to allow higher division factors of up to /128 +reg [6:0] ssp_clk_divider; +always @(posedge adc_clk) + ssp_clk_divider <= (ssp_clk_divider + 1); +assign ssp_clk = ssp_clk_divider[4]; + +// Divide SSP_CLK by 8 to produce the byte framing signal; the phase of +// this is arbitrary, because it's just a bitstream. +// One nasty issue, though: I can't make it work with both rx and tx at +// once. The phase wrt ssp_clk must be changed. TODO to find out why +// that is and make a better fix. +reg [2:0] ssp_frame_divider_to_arm; +always @(posedge ssp_clk) + ssp_frame_divider_to_arm <= (ssp_frame_divider_to_arm + 1); +reg [2:0] ssp_frame_divider_from_arm; +always @(negedge ssp_clk) + ssp_frame_divider_from_arm <= (ssp_frame_divider_from_arm + 1); + +reg ssp_frame; +always @(ssp_frame_divider_to_arm or ssp_frame_divider_from_arm or mod_type) + if(mod_type == 3'b000) // not modulating, so listening, to ARM + ssp_frame = (ssp_frame_divider_to_arm == 3'b000); + else + ssp_frame = (ssp_frame_divider_from_arm == 3'b000); + +// Synchronize up the after-hysteresis signal, to produce DIN. +reg ssp_din; +always @(posedge ssp_clk) + ssp_din = after_hysteresis; + +// Modulating carrier frequency is fc/16, reuse ssp_clk divider for that +reg modulating_carrier; +always @(mod_type or ssp_clk or ssp_dout) + if(mod_type == 3'b000) + modulating_carrier <= 1'b0; // no modulation + else if(mod_type == 3'b001) + modulating_carrier <= ssp_dout ^ ssp_clk_divider[3]; // XOR means BPSK + else if(mod_type == 3'b010) + modulating_carrier <= ssp_dout & ssp_clk_divider[5]; // switch 212kHz subcarrier on/off + else + modulating_carrier <= 1'b0; // yet unused + +// This one is all LF, so doesn't matter +assign pwr_oe2 = modulating_carrier; + +// Toggle only one of these, since we are already producing much deeper +// modulation than a real tag would. +assign pwr_oe1 = modulating_carrier; +assign pwr_oe4 = modulating_carrier; + +// This one is always on, so that we can watch the carrier. +assign pwr_oe3 = 1'b0; + +assign dbg = after_hysteresis; + +endmodule diff --git a/fpga/lo_passthru.v b/fpga/lo_passthru.v index e1cb2ef2..5c59d11c 100644 --- a/fpga/lo_passthru.v +++ b/fpga/lo_passthru.v @@ -1,56 +1,56 @@ -//----------------------------------------------------------------------------- -// For reading TI tags, we need to place the FPGA in pass through mode -// and pass everything through to the ARM -//----------------------------------------------------------------------------- - -module lo_passthru( - pck0, ck_1356meg, ck_1356megb, - pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, - adc_d, adc_clk, - ssp_frame, ssp_din, ssp_dout, ssp_clk, - cross_hi, cross_lo, - dbg, divisor -); - input pck0, ck_1356meg, ck_1356megb; - output pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; - input [7:0] adc_d; - output adc_clk; - input ssp_dout; - output ssp_frame, ssp_din, ssp_clk; - input cross_hi, cross_lo; - output dbg; - input [7:0] divisor; - -reg [7:0] pck_divider; -reg ant_lo; - -// this task runs on the rising egde of pck0 clock (24Mhz) and creates ant_lo -// which is high for (divisor+1) pck0 cycles and low for the same duration -// ant_lo is therefore a 50% duty cycle clock signal with a frequency of -// 12Mhz/(divisor+1) which drives the antenna as well as the ADC clock adc_clk -always @(posedge pck0) -begin - if(pck_divider == divisor[7:0]) - begin - pck_divider <= 8'd0; - ant_lo = !ant_lo; - end - else - begin - pck_divider <= pck_divider + 1; - end -end - -// the antenna is modulated when ssp_dout = 1, when 0 the -// antenna drivers stop modulating and go into listen mode -assign pwr_oe3 = 1'b0; -assign pwr_oe1 = ssp_dout; -assign pwr_oe2 = ssp_dout; -assign pwr_oe4 = ssp_dout; -assign pwr_lo = ant_lo && ssp_dout; -assign pwr_hi = 1'b0; -assign adc_clk = 1'b0; -assign ssp_din = cross_lo; -assign dbg = cross_lo; - -endmodule +//----------------------------------------------------------------------------- +// For reading TI tags, we need to place the FPGA in pass through mode +// and pass everything through to the ARM +//----------------------------------------------------------------------------- + +module lo_passthru( + pck0, ck_1356meg, ck_1356megb, + pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, + adc_d, adc_clk, + ssp_frame, ssp_din, ssp_dout, ssp_clk, + cross_hi, cross_lo, + dbg, divisor +); + input pck0, ck_1356meg, ck_1356megb; + output pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; + input [7:0] adc_d; + output adc_clk; + input ssp_dout; + output ssp_frame, ssp_din, ssp_clk; + input cross_hi, cross_lo; + output dbg; + input [7:0] divisor; + +reg [7:0] pck_divider; +reg ant_lo; + +// this task runs on the rising egde of pck0 clock (24Mhz) and creates ant_lo +// which is high for (divisor+1) pck0 cycles and low for the same duration +// ant_lo is therefore a 50% duty cycle clock signal with a frequency of +// 12Mhz/(divisor+1) which drives the antenna as well as the ADC clock adc_clk +always @(posedge pck0) +begin + if(pck_divider == divisor[7:0]) + begin + pck_divider <= 8'd0; + ant_lo = !ant_lo; + end + else + begin + pck_divider <= pck_divider + 1; + end +end + +// the antenna is modulated when ssp_dout = 1, when 0 the +// antenna drivers stop modulating and go into listen mode +assign pwr_oe3 = 1'b0; +assign pwr_oe1 = ssp_dout; +assign pwr_oe2 = ssp_dout; +assign pwr_oe4 = ssp_dout; +assign pwr_lo = ant_lo && ssp_dout; +assign pwr_hi = 1'b0; +assign adc_clk = 1'b0; +assign ssp_din = cross_lo; +assign dbg = cross_lo; + +endmodule diff --git a/fpga/lo_read.v b/fpga/lo_read.v index 8dce4dda..e6f245ca 100644 --- a/fpga/lo_read.v +++ b/fpga/lo_read.v @@ -1,103 +1,103 @@ -//----------------------------------------------------------------------------- -// The way that we connect things in low-frequency read mode. In this case -// we are generating the unmodulated low frequency carrier. -// The A/D samples at that same rate and the result is serialized. -// -// Jonathan Westhues, April 2006 -//----------------------------------------------------------------------------- - -module lo_read( - pck0, ck_1356meg, ck_1356megb, - pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, - adc_d, adc_clk, - ssp_frame, ssp_din, ssp_dout, ssp_clk, - cross_hi, cross_lo, - dbg, - lo_is_125khz, divisor -); - input pck0, ck_1356meg, ck_1356megb; - output pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; - input [7:0] adc_d; - output adc_clk; - input ssp_dout; - output ssp_frame, ssp_din, ssp_clk; - input cross_hi, cross_lo; - output dbg; - input lo_is_125khz; // redundant signal, no longer used anywhere - input [7:0] divisor; - -reg [7:0] to_arm_shiftreg; -reg [7:0] pck_divider; -reg ant_lo; - -// this task runs on the rising egde of pck0 clock (24Mhz) and creates ant_lo -// which is high for (divisor+1) pck0 cycles and low for the same duration -// ant_lo is therefore a 50% duty cycle clock signal with a frequency of -// 12Mhz/(divisor+1) which drives the antenna as well as the ADC clock adc_clk -always @(posedge pck0) -begin - if(pck_divider == divisor[7:0]) - begin - pck_divider <= 8'd0; - ant_lo = !ant_lo; - end - else - begin - pck_divider <= pck_divider + 1; - end -end - -// this task also runs at pck0 frequency (24Mhz) and is used to serialize -// the ADC output which is then clocked into the ARM SSP. - -// because ant_lo always transitions when pck_divider = 0 we use the -// pck_divider counter to sync our other signals off it -// we read the ADC value when pck_divider=7 and shift it out on counts 8..15 -always @(posedge pck0) -begin - if((pck_divider == 8'd7) && !ant_lo) - to_arm_shiftreg <= adc_d; - else - begin - to_arm_shiftreg[7:1] <= to_arm_shiftreg[6:0]; - // simulation showed a glitch occuring due to the LSB of the shifter - // not being set as we shift bits out - // this ensures the ssp_din remains low after a transfer and suppresses - // the glitch that would occur when the last data shifted out ended in - // a 1 bit and the next data shifted out started with a 0 bit - to_arm_shiftreg[0] <= 1'b0; - end -end - -// ADC samples on falling edge of adc_clk, data available on the rising edge - -// example of ssp transfer of binary value 1100101 -// start of transfer is indicated by the rise of the ssp_frame signal -// ssp_din changes on the rising edge of the ssp_clk clock and is clocked into -// the ARM by the falling edge of ssp_clk -// _______________________________ -// ssp_frame__| |__ -// _______ ___ ___ -// ssp_din __| |_______| |___| |______ -// _ _ _ _ _ _ _ _ _ _ -// ssp_clk |_| |_| |_| |_| |_| |_| |_| |_| |_| |_ - -// serialized SSP data is gated by ant_lo to suppress unwanted signal -assign ssp_din = to_arm_shiftreg[7] && !ant_lo; -// SSP clock always runs at 24Mhz -assign ssp_clk = pck0; -// SSP frame is gated by ant_lo and goes high when pck_divider=8..15 -assign ssp_frame = (pck_divider[7:3] == 5'd1) && !ant_lo; -// unused signals tied low -assign pwr_hi = 1'b0; -assign pwr_oe1 = 1'b0; -assign pwr_oe2 = 1'b0; -assign pwr_oe3 = 1'b0; -assign pwr_oe4 = 1'b0; -// this is the antenna driver signal -assign pwr_lo = ant_lo; -// ADC clock out of phase with antenna driver -assign adc_clk = ~ant_lo; -// ADC clock also routed to debug pin -assign dbg = adc_clk; -endmodule +//----------------------------------------------------------------------------- +// The way that we connect things in low-frequency read mode. In this case +// we are generating the unmodulated low frequency carrier. +// The A/D samples at that same rate and the result is serialized. +// +// Jonathan Westhues, April 2006 +//----------------------------------------------------------------------------- + +module lo_read( + pck0, ck_1356meg, ck_1356megb, + pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, + adc_d, adc_clk, + ssp_frame, ssp_din, ssp_dout, ssp_clk, + cross_hi, cross_lo, + dbg, + lo_is_125khz, divisor +); + input pck0, ck_1356meg, ck_1356megb; + output pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; + input [7:0] adc_d; + output adc_clk; + input ssp_dout; + output ssp_frame, ssp_din, ssp_clk; + input cross_hi, cross_lo; + output dbg; + input lo_is_125khz; // redundant signal, no longer used anywhere + input [7:0] divisor; + +reg [7:0] to_arm_shiftreg; +reg [7:0] pck_divider; +reg ant_lo; + +// this task runs on the rising egde of pck0 clock (24Mhz) and creates ant_lo +// which is high for (divisor+1) pck0 cycles and low for the same duration +// ant_lo is therefore a 50% duty cycle clock signal with a frequency of +// 12Mhz/(divisor+1) which drives the antenna as well as the ADC clock adc_clk +always @(posedge pck0) +begin + if(pck_divider == divisor[7:0]) + begin + pck_divider <= 8'd0; + ant_lo = !ant_lo; + end + else + begin + pck_divider <= pck_divider + 1; + end +end + +// this task also runs at pck0 frequency (24Mhz) and is used to serialize +// the ADC output which is then clocked into the ARM SSP. + +// because ant_lo always transitions when pck_divider = 0 we use the +// pck_divider counter to sync our other signals off it +// we read the ADC value when pck_divider=7 and shift it out on counts 8..15 +always @(posedge pck0) +begin + if((pck_divider == 8'd7) && !ant_lo) + to_arm_shiftreg <= adc_d; + else + begin + to_arm_shiftreg[7:1] <= to_arm_shiftreg[6:0]; + // simulation showed a glitch occuring due to the LSB of the shifter + // not being set as we shift bits out + // this ensures the ssp_din remains low after a transfer and suppresses + // the glitch that would occur when the last data shifted out ended in + // a 1 bit and the next data shifted out started with a 0 bit + to_arm_shiftreg[0] <= 1'b0; + end +end + +// ADC samples on falling edge of adc_clk, data available on the rising edge + +// example of ssp transfer of binary value 1100101 +// start of transfer is indicated by the rise of the ssp_frame signal +// ssp_din changes on the rising edge of the ssp_clk clock and is clocked into +// the ARM by the falling edge of ssp_clk +// _______________________________ +// ssp_frame__| |__ +// _______ ___ ___ +// ssp_din __| |_______| |___| |______ +// _ _ _ _ _ _ _ _ _ _ +// ssp_clk |_| |_| |_| |_| |_| |_| |_| |_| |_| |_ + +// serialized SSP data is gated by ant_lo to suppress unwanted signal +assign ssp_din = to_arm_shiftreg[7] && !ant_lo; +// SSP clock always runs at 24Mhz +assign ssp_clk = pck0; +// SSP frame is gated by ant_lo and goes high when pck_divider=8..15 +assign ssp_frame = (pck_divider[7:3] == 5'd1) && !ant_lo; +// unused signals tied low +assign pwr_hi = 1'b0; +assign pwr_oe1 = 1'b0; +assign pwr_oe2 = 1'b0; +assign pwr_oe3 = 1'b0; +assign pwr_oe4 = 1'b0; +// this is the antenna driver signal +assign pwr_lo = ant_lo; +// ADC clock out of phase with antenna driver +assign adc_clk = ~ant_lo; +// ADC clock also routed to debug pin +assign dbg = adc_clk; +endmodule diff --git a/fpga/lo_simulate.v b/fpga/lo_simulate.v index 9e3cd50a..57e602a2 100644 --- a/fpga/lo_simulate.v +++ b/fpga/lo_simulate.v @@ -1,56 +1,56 @@ -//----------------------------------------------------------------------------- -// The way that we connect things in low-frequency simulation mode. In this -// case just pass everything through to the ARM, which can bit-bang this -// (because it is so slow). -// -// Jonathan Westhues, April 2006 -//----------------------------------------------------------------------------- - -module lo_simulate( - pck0, ck_1356meg, ck_1356megb, - pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, - adc_d, adc_clk, - ssp_frame, ssp_din, ssp_dout, ssp_clk, - cross_hi, cross_lo, +//----------------------------------------------------------------------------- +// The way that we connect things in low-frequency simulation mode. In this +// case just pass everything through to the ARM, which can bit-bang this +// (because it is so slow). +// +// Jonathan Westhues, April 2006 +//----------------------------------------------------------------------------- + +module lo_simulate( + pck0, ck_1356meg, ck_1356megb, + pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, + adc_d, adc_clk, + ssp_frame, ssp_din, ssp_dout, ssp_clk, + cross_hi, cross_lo, dbg, - divisor -); - input pck0, ck_1356meg, ck_1356megb; - output pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; - input [7:0] adc_d; - output adc_clk; - input ssp_dout; - output ssp_frame, ssp_din, ssp_clk; - input cross_hi, cross_lo; + divisor +); + input pck0, ck_1356meg, ck_1356megb; + output pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; + input [7:0] adc_d; + output adc_clk; + input ssp_dout; + output ssp_frame, ssp_din, ssp_clk; + input cross_hi, cross_lo; output dbg; - input [7:0] divisor; - -// No logic, straight through. -assign pwr_oe3 = 1'b0; -assign pwr_oe1 = ssp_dout; -assign pwr_oe2 = ssp_dout; -assign pwr_oe4 = ssp_dout; -assign ssp_clk = cross_lo; -assign pwr_lo = 1'b0; -assign pwr_hi = 1'b0; -assign dbg = ssp_frame; + input [7:0] divisor; + +// No logic, straight through. +assign pwr_oe3 = 1'b0; +assign pwr_oe1 = ssp_dout; +assign pwr_oe2 = ssp_dout; +assign pwr_oe4 = ssp_dout; +assign ssp_clk = cross_lo; +assign pwr_lo = 1'b0; +assign pwr_hi = 1'b0; +assign dbg = ssp_frame; // Divide the clock to be used for the ADC reg [7:0] pck_divider; reg clk_state; - -always @(posedge pck0) -begin - if(pck_divider == divisor[7:0]) - begin + +always @(posedge pck0) +begin + if(pck_divider == divisor[7:0]) + begin pck_divider <= 8'd0; - clk_state = !clk_state; - end - else - begin - pck_divider <= pck_divider + 1; - end -end + clk_state = !clk_state; + end + else + begin + pck_divider <= pck_divider + 1; + end +end assign adc_clk = ~clk_state; @@ -61,8 +61,8 @@ reg is_high; reg is_low; reg output_state; -always @(posedge pck0) -begin +always @(posedge pck0) +begin if((pck_divider == 8'd7) && !clk_state) begin is_high = (adc_d >= 8'd200); is_low = (adc_d <= 8'd64); @@ -78,5 +78,6 @@ begin end assign ssp_frame = output_state; - -endmodule + +endmodule + diff --git a/fpga/sim.tcl b/fpga/sim.tcl index 477acd1d..0ee8c0c3 100644 --- a/fpga/sim.tcl +++ b/fpga/sim.tcl @@ -1,27 +1,27 @@ -#------------------------------------------------------------------------------ -# Run the simulation testbench in ModelSim: recompile both Verilog source -# files, then start the simulation, add a lot of signals to the waveform -# viewer, and run. I should (TODO) fix the absolute paths at some point. -# -# Jonathan Westhues, Mar 2006 -#------------------------------------------------------------------------------ - -vlog -work work -O0 C:/depot/proximity/mark3/fpga/fpga.v -vlog -work work -O0 C:/depot/proximity/mark3/fpga/fpga_tb.v - -vsim work.fpga_tb - -add wave sim:/fpga_tb/adc_clk -add wave sim:/fpga_tb/adc_d -add wave sim:/fpga_tb/pwr_lo -add wave sim:/fpga_tb/ssp_clk -add wave sim:/fpga_tb/ssp_frame -add wave sim:/fpga_tb/ssp_din -add wave sim:/fpga_tb/ssp_dout - -add wave sim:/fpga_tb/dut/clk_lo -add wave sim:/fpga_tb/dut/pck_divider -add wave sim:/fpga_tb/dut/carrier_divider_lo -add wave sim:/fpga_tb/dut/conf_word - -run 30000 +#------------------------------------------------------------------------------ +# Run the simulation testbench in ModelSim: recompile both Verilog source +# files, then start the simulation, add a lot of signals to the waveform +# viewer, and run. I should (TODO) fix the absolute paths at some point. +# +# Jonathan Westhues, Mar 2006 +#------------------------------------------------------------------------------ + +vlog -work work -O0 C:/depot/proximity/mark3/fpga/fpga.v +vlog -work work -O0 C:/depot/proximity/mark3/fpga/fpga_tb.v + +vsim work.fpga_tb + +add wave sim:/fpga_tb/adc_clk +add wave sim:/fpga_tb/adc_d +add wave sim:/fpga_tb/pwr_lo +add wave sim:/fpga_tb/ssp_clk +add wave sim:/fpga_tb/ssp_frame +add wave sim:/fpga_tb/ssp_din +add wave sim:/fpga_tb/ssp_dout + +add wave sim:/fpga_tb/dut/clk_lo +add wave sim:/fpga_tb/dut/pck_divider +add wave sim:/fpga_tb/dut/carrier_divider_lo +add wave sim:/fpga_tb/dut/conf_word + +run 30000 diff --git a/fpga/testbed_fpga.v b/fpga/testbed_fpga.v index 3ef2766a..f62255db 100644 --- a/fpga/testbed_fpga.v +++ b/fpga/testbed_fpga.v @@ -1,50 +1,50 @@ -`include "fpga.v" - -module testbed_fpga; - reg spck, mosi, ncs; - wire miso; - reg pck0i, ck_1356meg, ck_1356megb; - wire pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; - reg [7:0] adc_d; - wire adc_clk, adc_noe; - reg ssp_dout; - wire ssp_frame, ssp_din, ssp_clk; - - fpga dut( - spck, miso, mosi, ncs, - pck0i, ck_1356meg, ck_1356megb, - pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, - adc_d, adc_clk, adc_noe, - ssp_frame, ssp_din, ssp_dout, ssp_clk - ); - - integer i; - - initial begin - - // init inputs - #5 ncs=1; - #5 spck = 1; - #5 mosi = 1; - - #50 ncs=0; - for (i = 0 ; i < 8 ; i = i + 1) begin - #5 mosi = $random; - #5 spck = 0; - #5 spck = 1; - end - #5 ncs=1; - - #50 ncs=0; - for (i = 0 ; i < 8 ; i = i + 1) begin - #5 mosi = $random; - #5 spck = 0; - #5 spck = 1; - end - #5 ncs=1; - - #50 mosi=1; - $finish; - end - -endmodule // main +`include "fpga.v" + +module testbed_fpga; + reg spck, mosi, ncs; + wire miso; + reg pck0i, ck_1356meg, ck_1356megb; + wire pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4; + reg [7:0] adc_d; + wire adc_clk, adc_noe; + reg ssp_dout; + wire ssp_frame, ssp_din, ssp_clk; + + fpga dut( + spck, miso, mosi, ncs, + pck0i, ck_1356meg, ck_1356megb, + pwr_lo, pwr_hi, pwr_oe1, pwr_oe2, pwr_oe3, pwr_oe4, + adc_d, adc_clk, adc_noe, + ssp_frame, ssp_din, ssp_dout, ssp_clk + ); + + integer i; + + initial begin + + // init inputs + #5 ncs=1; + #5 spck = 1; + #5 mosi = 1; + + #50 ncs=0; + for (i = 0 ; i < 8 ; i = i + 1) begin + #5 mosi = $random; + #5 spck = 0; + #5 spck = 1; + end + #5 ncs=1; + + #50 ncs=0; + for (i = 0 ; i < 8 ; i = i + 1) begin + #5 mosi = $random; + #5 spck = 0; + #5 spck = 1; + end + #5 ncs=1; + + #50 mosi=1; + $finish; + end + +endmodule // main diff --git a/fpga/testbed_hi_read_tx.v b/fpga/testbed_hi_read_tx.v index 0d600a1f..bd4f5b40 100644 --- a/fpga/testbed_hi_read_tx.v +++ b/fpga/testbed_hi_read_tx.v @@ -1,109 +1,109 @@ -`include "hi_read_tx.v" - -/* - pck0 - input main 24Mhz clock (PLL / 4) - [7:0] adc_d - input data from A/D converter - shallow_modulation - modulation type - - pwr_lo - output to coil drivers (ssp_clk / 8) - adc_clk - output A/D clock signal - ssp_frame - output SSS frame indicator (goes high while the 8 bits are shifted) - ssp_din - output SSP data to ARM (shifts 8 bit A/D value serially to ARM MSB first) - ssp_clk - output SSP clock signal - - ck_1356meg - input unused - ck_1356megb - input unused - ssp_dout - input unused - cross_hi - input unused - cross_lo - input unused - - pwr_hi - output unused, tied low - pwr_oe1 - output unused, undefined - pwr_oe2 - output unused, undefined - pwr_oe3 - output unused, undefined - pwr_oe4 - output unused, undefined - dbg - output alias for adc_clk -*/ - -module testbed_hi_read_tx; - reg pck0; - reg [7:0] adc_d; - reg shallow_modulation; - - wire pwr_lo; - wire adc_clk; - reg ck_1356meg; - reg ck_1356megb; - wire ssp_frame; - wire ssp_din; - wire ssp_clk; - reg ssp_dout; - wire pwr_hi; - wire pwr_oe1; - wire pwr_oe2; - wire pwr_oe3; - wire pwr_oe4; - wire cross_lo; - wire cross_hi; - wire dbg; - - hi_read_tx #(5,200) dut( - .pck0(pck0), - .ck_1356meg(ck_1356meg), - .ck_1356megb(ck_1356megb), - .pwr_lo(pwr_lo), - .pwr_hi(pwr_hi), - .pwr_oe1(pwr_oe1), - .pwr_oe2(pwr_oe2), - .pwr_oe3(pwr_oe3), - .pwr_oe4(pwr_oe4), - .adc_d(adc_d), - .adc_clk(adc_clk), - .ssp_frame(ssp_frame), - .ssp_din(ssp_din), - .ssp_dout(ssp_dout), - .ssp_clk(ssp_clk), - .cross_hi(cross_hi), - .cross_lo(cross_lo), - .dbg(dbg), - .shallow_modulation(shallow_modulation) - ); - - integer idx, i; - - // main clock - always #5 begin - ck_1356megb = !ck_1356megb; - ck_1356meg = ck_1356megb; - end - - //crank DUT - task crank_dut; - begin - @(posedge ssp_clk) ; - ssp_dout = $random; - end - endtask - - initial begin - - // init inputs - ck_1356megb = 0; - adc_d = 0; - ssp_dout=0; - - // shallow modulation off - shallow_modulation=0; - for (i = 0 ; i < 16 ; i = i + 1) begin - crank_dut; - end - - // shallow modulation on - shallow_modulation=1; - for (i = 0 ; i < 16 ; i = i + 1) begin - crank_dut; - end - $finish; - end - -endmodule // main +`include "hi_read_tx.v" + +/* + pck0 - input main 24Mhz clock (PLL / 4) + [7:0] adc_d - input data from A/D converter + shallow_modulation - modulation type + + pwr_lo - output to coil drivers (ssp_clk / 8) + adc_clk - output A/D clock signal + ssp_frame - output SSS frame indicator (goes high while the 8 bits are shifted) + ssp_din - output SSP data to ARM (shifts 8 bit A/D value serially to ARM MSB first) + ssp_clk - output SSP clock signal + + ck_1356meg - input unused + ck_1356megb - input unused + ssp_dout - input unused + cross_hi - input unused + cross_lo - input unused + + pwr_hi - output unused, tied low + pwr_oe1 - output unused, undefined + pwr_oe2 - output unused, undefined + pwr_oe3 - output unused, undefined + pwr_oe4 - output unused, undefined + dbg - output alias for adc_clk +*/ + +module testbed_hi_read_tx; + reg pck0; + reg [7:0] adc_d; + reg shallow_modulation; + + wire pwr_lo; + wire adc_clk; + reg ck_1356meg; + reg ck_1356megb; + wire ssp_frame; + wire ssp_din; + wire ssp_clk; + reg ssp_dout; + wire pwr_hi; + wire pwr_oe1; + wire pwr_oe2; + wire pwr_oe3; + wire pwr_oe4; + wire cross_lo; + wire cross_hi; + wire dbg; + + hi_read_tx #(5,200) dut( + .pck0(pck0), + .ck_1356meg(ck_1356meg), + .ck_1356megb(ck_1356megb), + .pwr_lo(pwr_lo), + .pwr_hi(pwr_hi), + .pwr_oe1(pwr_oe1), + .pwr_oe2(pwr_oe2), + .pwr_oe3(pwr_oe3), + .pwr_oe4(pwr_oe4), + .adc_d(adc_d), + .adc_clk(adc_clk), + .ssp_frame(ssp_frame), + .ssp_din(ssp_din), + .ssp_dout(ssp_dout), + .ssp_clk(ssp_clk), + .cross_hi(cross_hi), + .cross_lo(cross_lo), + .dbg(dbg), + .shallow_modulation(shallow_modulation) + ); + + integer idx, i; + + // main clock + always #5 begin + ck_1356megb = !ck_1356megb; + ck_1356meg = ck_1356megb; + end + + //crank DUT + task crank_dut; + begin + @(posedge ssp_clk) ; + ssp_dout = $random; + end + endtask + + initial begin + + // init inputs + ck_1356megb = 0; + adc_d = 0; + ssp_dout=0; + + // shallow modulation off + shallow_modulation=0; + for (i = 0 ; i < 16 ; i = i + 1) begin + crank_dut; + end + + // shallow modulation on + shallow_modulation=1; + for (i = 0 ; i < 16 ; i = i + 1) begin + crank_dut; + end + $finish; + end + +endmodule // main diff --git a/fpga/testbed_hi_simulate.v b/fpga/testbed_hi_simulate.v index 6dc30f0b..b0672016 100644 --- a/fpga/testbed_hi_simulate.v +++ b/fpga/testbed_hi_simulate.v @@ -1,116 +1,116 @@ -`include "hi_simulate.v" - -/* - pck0 - input main 24Mhz clock (PLL / 4) - [7:0] adc_d - input data from A/D converter - mod_type - modulation type - - pwr_lo - output to coil drivers (ssp_clk / 8) - adc_clk - output A/D clock signal - ssp_frame - output SSS frame indicator (goes high while the 8 bits are shifted) - ssp_din - output SSP data to ARM (shifts 8 bit A/D value serially to ARM MSB first) - ssp_clk - output SSP clock signal - - ck_1356meg - input unused - ck_1356megb - input unused - ssp_dout - input unused - cross_hi - input unused - cross_lo - input unused - - pwr_hi - output unused, tied low - pwr_oe1 - output unused, undefined - pwr_oe2 - output unused, undefined - pwr_oe3 - output unused, undefined - pwr_oe4 - output unused, undefined - dbg - output alias for adc_clk -*/ - -module testbed_hi_simulate; - reg pck0; - reg [7:0] adc_d; - reg mod_type; - - wire pwr_lo; - wire adc_clk; - reg ck_1356meg; - reg ck_1356megb; - wire ssp_frame; - wire ssp_din; - wire ssp_clk; - reg ssp_dout; - wire pwr_hi; - wire pwr_oe1; - wire pwr_oe2; - wire pwr_oe3; - wire pwr_oe4; - wire cross_lo; - wire cross_hi; - wire dbg; - - hi_simulate #(5,200) dut( - .pck0(pck0), - .ck_1356meg(ck_1356meg), - .ck_1356megb(ck_1356megb), - .pwr_lo(pwr_lo), - .pwr_hi(pwr_hi), - .pwr_oe1(pwr_oe1), - .pwr_oe2(pwr_oe2), - .pwr_oe3(pwr_oe3), - .pwr_oe4(pwr_oe4), - .adc_d(adc_d), - .adc_clk(adc_clk), - .ssp_frame(ssp_frame), - .ssp_din(ssp_din), - .ssp_dout(ssp_dout), - .ssp_clk(ssp_clk), - .cross_hi(cross_hi), - .cross_lo(cross_lo), - .dbg(dbg), - .mod_type(mod_type) - ); - - integer idx, i; - - // main clock - always #5 begin - ck_1356megb = !ck_1356megb; - ck_1356meg = ck_1356megb; - end - - always begin - @(negedge adc_clk) ; - adc_d = $random; - end - - //crank DUT - task crank_dut; - begin - @(negedge ssp_clk) ; - ssp_dout = $random; - end - endtask - - initial begin - - // init inputs - ck_1356megb = 0; - // random values - adc_d = 0; - ssp_dout=1; - - // shallow modulation off - mod_type=0; - for (i = 0 ; i < 16 ; i = i + 1) begin - crank_dut; - end - - // shallow modulation on - mod_type=1; - for (i = 0 ; i < 16 ; i = i + 1) begin - crank_dut; - end - $finish; - end - -endmodule // main - +`include "hi_simulate.v" + +/* + pck0 - input main 24Mhz clock (PLL / 4) + [7:0] adc_d - input data from A/D converter + mod_type - modulation type + + pwr_lo - output to coil drivers (ssp_clk / 8) + adc_clk - output A/D clock signal + ssp_frame - output SSS frame indicator (goes high while the 8 bits are shifted) + ssp_din - output SSP data to ARM (shifts 8 bit A/D value serially to ARM MSB first) + ssp_clk - output SSP clock signal + + ck_1356meg - input unused + ck_1356megb - input unused + ssp_dout - input unused + cross_hi - input unused + cross_lo - input unused + + pwr_hi - output unused, tied low + pwr_oe1 - output unused, undefined + pwr_oe2 - output unused, undefined + pwr_oe3 - output unused, undefined + pwr_oe4 - output unused, undefined + dbg - output alias for adc_clk +*/ + +module testbed_hi_simulate; + reg pck0; + reg [7:0] adc_d; + reg mod_type; + + wire pwr_lo; + wire adc_clk; + reg ck_1356meg; + reg ck_1356megb; + wire ssp_frame; + wire ssp_din; + wire ssp_clk; + reg ssp_dout; + wire pwr_hi; + wire pwr_oe1; + wire pwr_oe2; + wire pwr_oe3; + wire pwr_oe4; + wire cross_lo; + wire cross_hi; + wire dbg; + + hi_simulate #(5,200) dut( + .pck0(pck0), + .ck_1356meg(ck_1356meg), + .ck_1356megb(ck_1356megb), + .pwr_lo(pwr_lo), + .pwr_hi(pwr_hi), + .pwr_oe1(pwr_oe1), + .pwr_oe2(pwr_oe2), + .pwr_oe3(pwr_oe3), + .pwr_oe4(pwr_oe4), + .adc_d(adc_d), + .adc_clk(adc_clk), + .ssp_frame(ssp_frame), + .ssp_din(ssp_din), + .ssp_dout(ssp_dout), + .ssp_clk(ssp_clk), + .cross_hi(cross_hi), + .cross_lo(cross_lo), + .dbg(dbg), + .mod_type(mod_type) + ); + + integer idx, i; + + // main clock + always #5 begin + ck_1356megb = !ck_1356megb; + ck_1356meg = ck_1356megb; + end + + always begin + @(negedge adc_clk) ; + adc_d = $random; + end + + //crank DUT + task crank_dut; + begin + @(negedge ssp_clk) ; + ssp_dout = $random; + end + endtask + + initial begin + + // init inputs + ck_1356megb = 0; + // random values + adc_d = 0; + ssp_dout=1; + + // shallow modulation off + mod_type=0; + for (i = 0 ; i < 16 ; i = i + 1) begin + crank_dut; + end + + // shallow modulation on + mod_type=1; + for (i = 0 ; i < 16 ; i = i + 1) begin + crank_dut; + end + $finish; + end + +endmodule // main + diff --git a/fpga/testbed_lo_read.v b/fpga/testbed_lo_read.v index cb0f119c..370ed389 100644 --- a/fpga/testbed_lo_read.v +++ b/fpga/testbed_lo_read.v @@ -1,101 +1,101 @@ -`include "lo_read.v" -/* - pck0 - input main 24Mhz clock (PLL / 4) - [7:0] adc_d - input data from A/D converter - lo_is_125khz - input freq selector (1=125Khz, 0=136Khz) - - pwr_lo - output to coil drivers (ssp_clk / 8) - adc_clk - output A/D clock signal - ssp_frame - output SSS frame indicator (goes high while the 8 bits are shifted) - ssp_din - output SSP data to ARM (shifts 8 bit A/D value serially to ARM MSB first) - ssp_clk - output SSP clock signal 1Mhz/1.09Mhz (pck0 / 2*(11+lo_is_125khz) ) - - ck_1356meg - input unused - ck_1356megb - input unused - ssp_dout - input unused - cross_hi - input unused - cross_lo - input unused - - pwr_hi - output unused, tied low - pwr_oe1 - output unused, undefined - pwr_oe2 - output unused, undefined - pwr_oe3 - output unused, undefined - pwr_oe4 - output unused, undefined - dbg - output alias for adc_clk -*/ - -module testbed_lo_read; - reg pck0; - reg [7:0] adc_d; - reg lo_is_125khz; - reg [15:0] divisor; - - wire pwr_lo; - wire adc_clk; - wire ck_1356meg; - wire ck_1356megb; - wire ssp_frame; - wire ssp_din; - wire ssp_clk; - reg ssp_dout; - wire pwr_hi; - wire pwr_oe1; - wire pwr_oe2; - wire pwr_oe3; - wire pwr_oe4; - wire cross_lo; - wire cross_hi; - wire dbg; - - lo_read #(5,10) dut( - .pck0(pck0), - .ck_1356meg(ck_1356meg), - .ck_1356megb(ck_1356megb), - .pwr_lo(pwr_lo), - .pwr_hi(pwr_hi), - .pwr_oe1(pwr_oe1), - .pwr_oe2(pwr_oe2), - .pwr_oe3(pwr_oe3), - .pwr_oe4(pwr_oe4), - .adc_d(adc_d), - .adc_clk(adc_clk), - .ssp_frame(ssp_frame), - .ssp_din(ssp_din), - .ssp_dout(ssp_dout), - .ssp_clk(ssp_clk), - .cross_hi(cross_hi), - .cross_lo(cross_lo), - .dbg(dbg), - .lo_is_125khz(lo_is_125khz), - .divisor(divisor) - ); - - integer idx, i, adc_val=8; - - // main clock - always #5 pck0 = !pck0; - - task crank_dut; - begin - @(posedge adc_clk) ; - adc_d = adc_val; - adc_val = (adc_val *2) + 53; - end - endtask - - initial begin - - // init inputs - pck0 = 0; - adc_d = 0; - ssp_dout = 0; - lo_is_125khz = 1; - divisor = 255; //min 16, 95=125Khz, max 255 - - // simulate 4 A/D cycles at 125Khz - for (i = 0 ; i < 8 ; i = i + 1) begin - crank_dut; - end - $finish; - end -endmodule // main +`include "lo_read.v" +/* + pck0 - input main 24Mhz clock (PLL / 4) + [7:0] adc_d - input data from A/D converter + lo_is_125khz - input freq selector (1=125Khz, 0=136Khz) + + pwr_lo - output to coil drivers (ssp_clk / 8) + adc_clk - output A/D clock signal + ssp_frame - output SSS frame indicator (goes high while the 8 bits are shifted) + ssp_din - output SSP data to ARM (shifts 8 bit A/D value serially to ARM MSB first) + ssp_clk - output SSP clock signal 1Mhz/1.09Mhz (pck0 / 2*(11+lo_is_125khz) ) + + ck_1356meg - input unused + ck_1356megb - input unused + ssp_dout - input unused + cross_hi - input unused + cross_lo - input unused + + pwr_hi - output unused, tied low + pwr_oe1 - output unused, undefined + pwr_oe2 - output unused, undefined + pwr_oe3 - output unused, undefined + pwr_oe4 - output unused, undefined + dbg - output alias for adc_clk +*/ + +module testbed_lo_read; + reg pck0; + reg [7:0] adc_d; + reg lo_is_125khz; + reg [15:0] divisor; + + wire pwr_lo; + wire adc_clk; + wire ck_1356meg; + wire ck_1356megb; + wire ssp_frame; + wire ssp_din; + wire ssp_clk; + reg ssp_dout; + wire pwr_hi; + wire pwr_oe1; + wire pwr_oe2; + wire pwr_oe3; + wire pwr_oe4; + wire cross_lo; + wire cross_hi; + wire dbg; + + lo_read #(5,10) dut( + .pck0(pck0), + .ck_1356meg(ck_1356meg), + .ck_1356megb(ck_1356megb), + .pwr_lo(pwr_lo), + .pwr_hi(pwr_hi), + .pwr_oe1(pwr_oe1), + .pwr_oe2(pwr_oe2), + .pwr_oe3(pwr_oe3), + .pwr_oe4(pwr_oe4), + .adc_d(adc_d), + .adc_clk(adc_clk), + .ssp_frame(ssp_frame), + .ssp_din(ssp_din), + .ssp_dout(ssp_dout), + .ssp_clk(ssp_clk), + .cross_hi(cross_hi), + .cross_lo(cross_lo), + .dbg(dbg), + .lo_is_125khz(lo_is_125khz), + .divisor(divisor) + ); + + integer idx, i, adc_val=8; + + // main clock + always #5 pck0 = !pck0; + + task crank_dut; + begin + @(posedge adc_clk) ; + adc_d = adc_val; + adc_val = (adc_val *2) + 53; + end + endtask + + initial begin + + // init inputs + pck0 = 0; + adc_d = 0; + ssp_dout = 0; + lo_is_125khz = 1; + divisor = 255; //min 16, 95=125Khz, max 255 + + // simulate 4 A/D cycles at 125Khz + for (i = 0 ; i < 8 ; i = i + 1) begin + crank_dut; + end + $finish; + end +endmodule // main diff --git a/fpga/testbed_lo_simulate.v b/fpga/testbed_lo_simulate.v index d30f822d..70b6331f 100644 --- a/fpga/testbed_lo_simulate.v +++ b/fpga/testbed_lo_simulate.v @@ -1,101 +1,101 @@ -`include "lo_simulate.v" - -/* - pck0 - input main 24Mhz clock (PLL / 4) - [7:0] adc_d - input data from A/D converter - - - pwr_lo - output to coil drivers (ssp_clk / 8) - adc_clk - output A/D clock signal - ssp_frame - output SSS frame indicator (goes high while the 8 bits are shifted) - ssp_din - output SSP data to ARM (shifts 8 bit A/D value serially to ARM MSB first) - ssp_clk - output SSP clock signal - - ck_1356meg - input unused - ck_1356megb - input unused - ssp_dout - input unused - cross_hi - input unused - cross_lo - input unused - - pwr_hi - output unused, tied low - pwr_oe1 - output unused, undefined - pwr_oe2 - output unused, undefined - pwr_oe3 - output unused, undefined - pwr_oe4 - output unused, undefined - dbg - output alias for adc_clk -*/ - -module testbed_lo_simulate; - reg pck0; - reg [7:0] adc_d; - - - wire pwr_lo; - wire adc_clk; - wire ck_1356meg; - wire ck_1356megb; - wire ssp_frame; - wire ssp_din; - wire ssp_clk; - reg ssp_dout; - wire pwr_hi; - wire pwr_oe1; - wire pwr_oe2; - wire pwr_oe3; - wire pwr_oe4; - reg cross_lo; - wire cross_hi; - wire dbg; - - lo_simulate #(5,200) dut( - .pck0(pck0), - .ck_1356meg(ck_1356meg), - .ck_1356megb(ck_1356megb), - .pwr_lo(pwr_lo), - .pwr_hi(pwr_hi), - .pwr_oe1(pwr_oe1), - .pwr_oe2(pwr_oe2), - .pwr_oe3(pwr_oe3), - .pwr_oe4(pwr_oe4), - .adc_d(adc_d), - .adc_clk(adc_clk), - .ssp_frame(ssp_frame), - .ssp_din(ssp_din), - .ssp_dout(ssp_dout), - .ssp_clk(ssp_clk), - .cross_hi(cross_hi), - .cross_lo(cross_lo), - .dbg(dbg) - ); - - - integer i, counter=0; - - // main clock - always #5 pck0 = !pck0; - - //cross_lo is not really synced to pck0 but it's roughly pck0/192 (24Mhz/192=125Khz) - task crank_dut; - begin - @(posedge pck0) ; - counter = counter + 1; - if (counter == 192) begin - counter = 0; - ssp_dout = $random; - cross_lo = 1; - end else begin - cross_lo = 0; - end - - end - endtask - - initial begin - pck0 = 0; - for (i = 0 ; i < 4096 ; i = i + 1) begin - crank_dut; - end - $finish; - end - -endmodule // main +`include "lo_simulate.v" + +/* + pck0 - input main 24Mhz clock (PLL / 4) + [7:0] adc_d - input data from A/D converter + + + pwr_lo - output to coil drivers (ssp_clk / 8) + adc_clk - output A/D clock signal + ssp_frame - output SSS frame indicator (goes high while the 8 bits are shifted) + ssp_din - output SSP data to ARM (shifts 8 bit A/D value serially to ARM MSB first) + ssp_clk - output SSP clock signal + + ck_1356meg - input unused + ck_1356megb - input unused + ssp_dout - input unused + cross_hi - input unused + cross_lo - input unused + + pwr_hi - output unused, tied low + pwr_oe1 - output unused, undefined + pwr_oe2 - output unused, undefined + pwr_oe3 - output unused, undefined + pwr_oe4 - output unused, undefined + dbg - output alias for adc_clk +*/ + +module testbed_lo_simulate; + reg pck0; + reg [7:0] adc_d; + + + wire pwr_lo; + wire adc_clk; + wire ck_1356meg; + wire ck_1356megb; + wire ssp_frame; + wire ssp_din; + wire ssp_clk; + reg ssp_dout; + wire pwr_hi; + wire pwr_oe1; + wire pwr_oe2; + wire pwr_oe3; + wire pwr_oe4; + reg cross_lo; + wire cross_hi; + wire dbg; + + lo_simulate #(5,200) dut( + .pck0(pck0), + .ck_1356meg(ck_1356meg), + .ck_1356megb(ck_1356megb), + .pwr_lo(pwr_lo), + .pwr_hi(pwr_hi), + .pwr_oe1(pwr_oe1), + .pwr_oe2(pwr_oe2), + .pwr_oe3(pwr_oe3), + .pwr_oe4(pwr_oe4), + .adc_d(adc_d), + .adc_clk(adc_clk), + .ssp_frame(ssp_frame), + .ssp_din(ssp_din), + .ssp_dout(ssp_dout), + .ssp_clk(ssp_clk), + .cross_hi(cross_hi), + .cross_lo(cross_lo), + .dbg(dbg) + ); + + + integer i, counter=0; + + // main clock + always #5 pck0 = !pck0; + + //cross_lo is not really synced to pck0 but it's roughly pck0/192 (24Mhz/192=125Khz) + task crank_dut; + begin + @(posedge pck0) ; + counter = counter + 1; + if (counter == 192) begin + counter = 0; + ssp_dout = $random; + cross_lo = 1; + end else begin + cross_lo = 0; + end + + end + endtask + + initial begin + pck0 = 0; + for (i = 0 ; i < 4096 ; i = i + 1) begin + crank_dut; + end + $finish; + end + +endmodule // main diff --git a/fpga/util.v b/fpga/util.v index c500edb4..0842ac64 100644 --- a/fpga/util.v +++ b/fpga/util.v @@ -1,27 +1,27 @@ -//----------------------------------------------------------------------------- -// General-purpose miscellany. -// -// Jonathan Westhues, April 2006. -//----------------------------------------------------------------------------- - -module mux8(sel, y, x0, x1, x2, x3, x4, x5, x6, x7); - input [2:0] sel; - input x0, x1, x2, x3, x4, x5, x6, x7; - output y; - reg y; - -always @(x0 or x1 or x2 or x3 or x4 or x5 or x6 or x7 or sel) -begin - case (sel) - 3'b000: y = x0; - 3'b001: y = x1; - 3'b010: y = x2; - 3'b011: y = x3; - 3'b100: y = x4; - 3'b101: y = x5; - 3'b110: y = x6; - 3'b111: y = x7; - endcase -end - -endmodule +//----------------------------------------------------------------------------- +// General-purpose miscellany. +// +// Jonathan Westhues, April 2006. +//----------------------------------------------------------------------------- + +module mux8(sel, y, x0, x1, x2, x3, x4, x5, x6, x7); + input [2:0] sel; + input x0, x1, x2, x3, x4, x5, x6, x7; + output y; + reg y; + +always @(x0 or x1 or x2 or x3 or x4 or x5 or x6 or x7 or sel) +begin + case (sel) + 3'b000: y = x0; + 3'b001: y = x1; + 3'b010: y = x2; + 3'b011: y = x3; + 3'b100: y = x4; + 3'b101: y = x5; + 3'b110: y = x6; + 3'b111: y = x7; + endcase +end + +endmodule diff --git a/fpga/xst.scr b/fpga/xst.scr index 365db39a..60d24c64 100644 --- a/fpga/xst.scr +++ b/fpga/xst.scr @@ -1 +1 @@ -run -ifn fpga.v -ifmt Verilog -ofn fpga.ngc -ofmt NGC -p xc2s30-6vq100 -opt_mode Speed -opt_level 1 -ent fpga +run -ifn fpga.v -ifmt Verilog -ofn fpga.ngc -ofmt NGC -p xc2s30-6vq100 -opt_mode Speed -opt_level 1 -ent fpga diff --git a/tools/at91sam7s256-armusbocd-flash-program.cfg b/tools/at91sam7s256-armusbocd-flash-program.cfg index 2dce014f..1884407a 100644 --- a/tools/at91sam7s256-armusbocd-flash-program.cfg +++ b/tools/at91sam7s256-armusbocd-flash-program.cfg @@ -1,39 +1,39 @@ -#define our ports -telnet_port 4444 -gdb_port 3333 - -#commands specific to the Olimex ARM-USB-OCD Dongle -interface ft2232 -ft2232_device_desc "Olimex OpenOCD JTAG" -ft2232_layout "olimex-jtag" -ft2232_vid_pid 0x15BA 0x0003 -jtag_speed 2 -jtag_nsrst_delay 200 -jtag_ntrst_delay 200 - -#reset_config [combination] [trst_type] [srst_type] -reset_config srst_only srst_pulls_trst - -#jtag_device -jtag_device 4 0x1 0xf 0xe - -#daemon_startup <'attach'|'reset'> -daemon_startup reset - -#target [variant] -target arm7tdmi little run_and_init 0 arm7tdmi_r4 - -#run_and_halt_time -run_and_halt_time 0 30 - -# commands below are specific to AT91sam7 Flash Programming -# --------------------------------------------------------- - -#target_script specifies the flash programming script file -target_script 0 reset script.ocd - -#working_area
<'backup'|'nobackup'> -working_area 0 0x40000000 0x4000 nobackup - -#flash bank at91sam7 0 0 0 0 -flash bank at91sam7 0 0 0 0 0 +#define our ports +telnet_port 4444 +gdb_port 3333 + +#commands specific to the Olimex ARM-USB-OCD Dongle +interface ft2232 +ft2232_device_desc "Olimex OpenOCD JTAG" +ft2232_layout "olimex-jtag" +ft2232_vid_pid 0x15BA 0x0003 +jtag_speed 2 +jtag_nsrst_delay 200 +jtag_ntrst_delay 200 + +#reset_config [combination] [trst_type] [srst_type] +reset_config srst_only srst_pulls_trst + +#jtag_device +jtag_device 4 0x1 0xf 0xe + +#daemon_startup <'attach'|'reset'> +daemon_startup reset + +#target [variant] +target arm7tdmi little run_and_init 0 arm7tdmi_r4 + +#run_and_halt_time +run_and_halt_time 0 30 + +# commands below are specific to AT91sam7 Flash Programming +# --------------------------------------------------------- + +#target_script specifies the flash programming script file +target_script 0 reset script.ocd + +#working_area
<'backup'|'nobackup'> +working_area 0 0x40000000 0x4000 nobackup + +#flash bank at91sam7 0 0 0 0 +flash bank at91sam7 0 0 0 0 0 diff --git a/tools/at91sam7s256-jtagkey.cfg b/tools/at91sam7s256-jtagkey.cfg index 5b56608c..2c32b795 100644 --- a/tools/at91sam7s256-jtagkey.cfg +++ b/tools/at91sam7s256-jtagkey.cfg @@ -1,24 +1,24 @@ -#define our ports -telnet_port 4444 -gdb_port 3333 - -#commands specific to the Amontec JTAGKey -interface ft2232 -ft2232_device_desc "Amontec JTAGkey A" -ft2232_layout jtagkey -ft2232_vid_pid 0x0403 0xcff8 -jtag_khz 200 -jtag_nsrst_delay 200 -jtag_ntrst_delay 200 - -#reset_config [combination] [trst_type] [srst_type] -reset_config srst_only srst_pulls_trst - -jtag newtap sam7x256 cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x3f0f0f0f - -target create sam7x256.cpu arm7tdmi -endian little -chain-position sam7x256.cpu -variant arm7tdmi - -gdb_memory_map enable - -sam7x256.cpu configure -work-area-virt 0 -work-area-phys 0x00200000 -work-area-size 0x10000 -work-area-backup 0 -flash bank at91sam7 0x100000 0x40000 0 4 sam7x256.cpu +#define our ports +telnet_port 4444 +gdb_port 3333 + +#commands specific to the Amontec JTAGKey +interface ft2232 +ft2232_device_desc "Amontec JTAGkey A" +ft2232_layout jtagkey +ft2232_vid_pid 0x0403 0xcff8 +jtag_khz 200 +jtag_nsrst_delay 200 +jtag_ntrst_delay 200 + +#reset_config [combination] [trst_type] [srst_type] +reset_config srst_only srst_pulls_trst + +jtag newtap sam7x256 cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x3f0f0f0f + +target create sam7x256.cpu arm7tdmi -endian little -chain-position sam7x256.cpu -variant arm7tdmi + +gdb_memory_map enable + +sam7x256.cpu configure -work-area-virt 0 -work-area-phys 0x00200000 -work-area-size 0x10000 -work-area-backup 0 +flash bank at91sam7 0x100000 0x40000 0 4 sam7x256.cpu diff --git a/tools/at91sam7s256-wiggler.cfg b/tools/at91sam7s256-wiggler.cfg index 83156fe5..83180dc9 100644 --- a/tools/at91sam7s256-wiggler.cfg +++ b/tools/at91sam7s256-wiggler.cfg @@ -1,39 +1,39 @@ -telnet_port 4444 -gdb_port 3333 - -interface parport -parport_port 0x378 -parport_cable wiggler -jtag_speed 0 -jtag_nsrst_delay 200 -jtag_ntrst_delay 200 - -reset_config srst_only srst_pulls_trst - -jtag newtap sam7x256 cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x3f0f0f0f -#jtag newtap xilinx tap -irlen 6 -ircapture 0x1 -irmask 0xf -expected-id 0x1c1a093 - -target create sam7x256.cpu arm7tdmi -endian little -chain-position sam7x256.cpu -variant arm7tdmi -sam7x256.cpu configure -event reset-init { - # disable watchdog - mww 0xfffffd44 0x00008000 - # enable user reset - mww 0xfffffd08 0xa5000001 - # CKGR_MOR : enable the main oscillator - mww 0xfffffc20 0x00000601 - sleep 10 - # CKGR_PLLR: 16 MHz * (5+1) /1 = 96Mhz - mww 0xfffffc2c 0x00051c01 - sleep 10 - # PMC_MCKR : MCK = PLL / 2 = 48 MHz - mww 0xfffffc30 0x00000007 - sleep 10 - # MC_FMR: flash mode (FWS=1,FMCN=60) - mww 0xffffff60 0x003c0100 - sleep 100 -} - -gdb_memory_map enable - -sam7x256.cpu configure -work-area-virt 0 -work-area-phys 0x00200000 -work-area-size 0x10000 -work-area-backup 0 -flash bank at91sam7 0 0 0 0 0 +telnet_port 4444 +gdb_port 3333 + +interface parport +parport_port 0x378 +parport_cable wiggler +jtag_speed 0 +jtag_nsrst_delay 200 +jtag_ntrst_delay 200 + +reset_config srst_only srst_pulls_trst + +jtag newtap sam7x256 cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x3f0f0f0f +#jtag newtap xilinx tap -irlen 6 -ircapture 0x1 -irmask 0xf -expected-id 0x1c1a093 + +target create sam7x256.cpu arm7tdmi -endian little -chain-position sam7x256.cpu -variant arm7tdmi +sam7x256.cpu configure -event reset-init { + # disable watchdog + mww 0xfffffd44 0x00008000 + # enable user reset + mww 0xfffffd08 0xa5000001 + # CKGR_MOR : enable the main oscillator + mww 0xfffffc20 0x00000601 + sleep 10 + # CKGR_PLLR: 16 MHz * (5+1) /1 = 96Mhz + mww 0xfffffc2c 0x00051c01 + sleep 10 + # PMC_MCKR : MCK = PLL / 2 = 48 MHz + mww 0xfffffc30 0x00000007 + sleep 10 + # MC_FMR: flash mode (FWS=1,FMCN=60) + mww 0xffffff60 0x003c0100 + sleep 100 +} + +gdb_memory_map enable + +sam7x256.cpu configure -work-area-virt 0 -work-area-phys 0x00200000 -work-area-size 0x10000 -work-area-backup 0 +flash bank at91sam7 0 0 0 0 0 -- 2.39.5 From 913d23c661c72190c7f16e3cb42264fda76c089c Mon Sep 17 00:00:00 2001 From: "izsh@fail0verflow.com" Date: Tue, 23 Feb 2010 20:52:50 +0000 Subject: [PATCH 03/16] client/cmdlfem4x.c: Fix a warning about probable uninitialized variable with gcc 4.4 --- client/cmdlfem4x.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/cmdlfem4x.c b/client/cmdlfem4x.c index fea4bd29..8bb4d109 100644 --- a/client/cmdlfem4x.c +++ b/client/cmdlfem4x.c @@ -281,6 +281,7 @@ int CmdEM4x50Read(const char *Cmd) high= low= 0; clock= 64; + memset(tmpbuff, 0, MAX_GRAPH_TRACE_LEN / 64); /* first get high and low values */ for (i = 0; i < GraphTraceLen; i++) -- 2.39.5 From 13bb3b4b117db3787675f2af40cb9769b416cd3d Mon Sep 17 00:00:00 2001 From: "izsh@fail0verflow.com" Date: Tue, 23 Feb 2010 20:55:35 +0000 Subject: [PATCH 04/16] client/COMPILING: Simplify dev. environment initial setup for Windows (WORK STILL IN PROGRESS) --- client/COMPILING | 70 +++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/client/COMPILING b/client/COMPILING index 3751f469..4e15107f 100644 --- a/client/COMPILING +++ b/client/COMPILING @@ -11,45 +11,47 @@ and optionally libQT To compile, just run "make". -========== -= MingGW = -========== -The following is a complete list of packages required to build the compile environment: - -- MSYS-1.0.11 -- binutils-2.20-1-mingw32-bin -- gcc-c++-4.4.0-mingw32-bin -- gcc-c++-4.4.0-mingw32-dll -- gcc-core-4.4.0-mingw32-bin -- gcc-core-4.4.0-mingw32-dll -- gmp-4.2.4-mingw32-dll -- libpthread-2.8.0-3-mingw32-dll-2 -- mingwrt-3.17-mingw32-dev -- mingwrt-3.17-mingw32-dll -- mpfr-2.4.1-mingw32-dll -- perl-5.8.6-4.tar (minimal from cygwin) -- pthreads-w32-2.8.0-3-mingw32-dev -- readline-5.0-1-bin -- w32api-3.14-mingw32-dev -- libusb-win32-device-bin-0.1.12.2 - Be careful here, it is *NOT* working with the filter version! - You have to use the device version and use the inf-wizard - to create a driver for your proxmark and install it. - -Additionally to compile the ARM code you need: -- devkitARM-r27 +=========== += Windows = +=========== +The following is a complete list of packages required to setup the compile environment yourself. Alternatively you can download an archive of the full environment (see below). + +1 - Install QT SDK for Windows [1] + +In the following instructions, we'll assume you installed it to C:\QT + +2 - MSYS-1.0.11 [2] + +Just follow the installation procedure. +When asked if you have MinGW installed and for its path, provide: +C:/QT/mingw + +3 - readline-5.0-1-bin [5] + +From this archive, copy: +bin/* to C:\QT\mingw\bin +include/* to C:\QT\mingw\include +lib/*.a to C:\QT\mingw\lib + +4 - libusb-win32-device-bin-0.1.12.2 [6] + +Be careful here, it is *NOT* working with the filter version! +Likewise copy: +include/usb.h to C:\QT\mingw\include +lib/gcc/libusb.a to C:\QT\mingw\lib + +Download links: + +[1] http://qt.nokia.com/downloads/sdk-windows-cpp +[2] http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe +[3] http://sourceforge.net/projects/gnuwin32/files/readline/5.0-1/readline-5.0-1-bin.zip/download +[4] http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/0.1.12.2/libusb-win32-device-bin-0.1.12.2.tar.gz/download Rather than download and install every one of these packages, a new ProxSpace environment archive file will be made available for download on the project page at http://code.google.com/p/proxmark3/downloads/list -Download the ProxSpace environment archive and extract it to your C:\ drive, then you -can run 0setpath.bat and 5makeall.bat in the cockpit directory and have the source -tree compiled. - -If you choose to extract it to another dir/path = , you must modify the -paths in \ProxSpace\pm3\cockpit\0setpath.bat dir as well as in the file -\ProxSpace\msys\etc\fstab +Download the ProxSpace environment archive and extract it to C:\ ============ = Mac OS X = -- 2.39.5 From 9cc7c4b4d13702122da3b7306391f411c030dc27 Mon Sep 17 00:00:00 2001 From: "izsh@fail0verflow.com" Date: Tue, 23 Feb 2010 22:10:35 +0000 Subject: [PATCH 05/16] client/COMPILING: move to /COMPILING and add instructions to be able to compile the firmware as well. --- client/COMPILING => COMPILING | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) rename client/COMPILING => COMPILING (69%) diff --git a/client/COMPILING b/COMPILING similarity index 69% rename from client/COMPILING rename to COMPILING index 4e15107f..118305fa 100644 --- a/client/COMPILING +++ b/COMPILING @@ -1,12 +1,14 @@ -The client compiles on Linux, Mac OS X and Windows (MinGW/MSYS). +The project compiles on Linux, Mac OS X and Windows (MinGW/MSYS). it requires: -- gcc +- gcc >= 4.4 - libpthread - libreadline - libusb +- perl +- an ARM cross-compiler to compile the firmware -and optionally libQT +and optionally QT for the GUI To compile, just run "make". @@ -40,12 +42,25 @@ Likewise copy: include/usb.h to C:\QT\mingw\include lib/gcc/libusb.a to C:\QT\mingw\lib + +5 - Install DevkitPro [5] + +You'll need it to compile the firmware (ARM) side. +You only need devkitARM, nothing more (no extra lib or anything else) +Assuming you installed it to C:\devkitpro, make sure you set +the DEVKITARM environment variable to /c/devkitPro/devkitARM : +export DEVKITARM=/c/devkitPro/devkitARM + +6 - Install Strawberry Perl [6] + Download links: [1] http://qt.nokia.com/downloads/sdk-windows-cpp [2] http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe [3] http://sourceforge.net/projects/gnuwin32/files/readline/5.0-1/readline-5.0-1-bin.zip/download [4] http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/0.1.12.2/libusb-win32-device-bin-0.1.12.2.tar.gz/download +[5] http://sourceforge.net/projects/devkitpro/files/Automated%20Installer/devkitProUpdater-1.5.0.exe/download +[6] http://strawberry-perl.googlecode.com/files/strawberry-perl-5.10.1.1.msi Rather than download and install every one of these packages, a new ProxSpace environment archive file will be made available for download on the project -- 2.39.5 From 8691f5b7bbe9138e9a4aa421da9a374536a8b556 Mon Sep 17 00:00:00 2001 From: "izsh@fail0verflow.com" Date: Wed, 24 Feb 2010 19:33:29 +0000 Subject: [PATCH 06/16] Fix QT compilation for Windows/MinGW and update the compilation instructions accordingly. --- COMPILING | 7 +++++++ client/Makefile | 19 +++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/COMPILING b/COMPILING index 118305fa..21782e2f 100644 --- a/COMPILING +++ b/COMPILING @@ -53,6 +53,13 @@ export DEVKITARM=/c/devkitPro/devkitARM 6 - Install Strawberry Perl [6] +7 - Setup a few variables + +In your shell from MSYS, make sure you set QTDIR to your QT installation: +export QTDIR=/c/QT/qt +And add its bin to your path as well: +export PATH=$PATH:$QTDIR/bin + Download links: [1] http://qt.nokia.com/downloads/sdk-windows-cpp diff --git a/client/Makefile b/client/Makefile index 4eae4bc7..b6d40c57 100644 --- a/client/Makefile +++ b/client/Makefile @@ -14,19 +14,26 @@ LDLIBS = -L/opt/local/lib -L/usr/local/lib -lusb -lreadline -lpthread LDFLAGS = $(COMMON_FLAGS) CFLAGS = -std=gnu99 -I. -I../include -I../common -I/opt/local/include -Wall -Wno-unused-function $(COMMON_FLAGS) -g -O3 -CXXFLAGS = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null) -Wall -O3 -QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null) +platform = $(shell uname) -ifeq ($(shell uname),Darwin) -CXXFLAGS = -I/Library/Frameworks/QtGui.framework/Versions/Current/Headers -I/Library/Frameworks/QtCore.framework/Versions/Current/Headers -QTLDLIBS = -framework QtGui -framework QtCore +ifneq (,$(findstring MINGW,$(platform))) +CXXFLAGS = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui +QTLDLIBS = -L$(QTDIR)/lib -lQtCore4 -lQtGui4 MOC = moc +else ifeq ($(platform),Darwin) +CXXFLAGS = -I/Library/Frameworks/QtGui.framework/Version/Current/Headers -I/Library/Frameworks/QtCore.framework/Versions/Current/Headers +QTLDLIBS = -framework QtGui -framework QtCore +MOC = moc +else +CXXFLAGS = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null) -Wall -O3 +QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null) +MOC = $(shell pkg-config --variable=moc_location QtCore) endif + ifneq ($(QTLDLIBS),) QTGUI = $(OBJDIR)/proxgui.o $(OBJDIR)/proxguiqt.o $(OBJDIR)/proxguiqt.moc.o CFLAGS += -DHAVE_GUI -MOC ?= $(shell pkg-config --variable=moc_location QtCore) LINK.o = $(LINK.cpp) else QTGUI = guidummy.o -- 2.39.5 From f1d7d574283f445310b136a3867f41cb0fde6d88 Mon Sep 17 00:00:00 2001 From: "izsh@fail0verflow.com" Date: Wed, 24 Feb 2010 19:49:16 +0000 Subject: [PATCH 07/16] COMPILING: move to COMPILING.txt. --- COMPILING => COMPILING.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename COMPILING => COMPILING.txt (100%) diff --git a/COMPILING b/COMPILING.txt similarity index 100% rename from COMPILING rename to COMPILING.txt -- 2.39.5 From e3e96e56df5adbe0264a2f2c088353aec049e23f Mon Sep 17 00:00:00 2001 From: "izsh@fail0verflow.com" Date: Wed, 24 Feb 2010 20:33:55 +0000 Subject: [PATCH 08/16] client/Makefile: Typo for Darwin --- client/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/Makefile b/client/Makefile index b6d40c57..66986daf 100644 --- a/client/Makefile +++ b/client/Makefile @@ -21,7 +21,7 @@ CXXFLAGS = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui QTLDLIBS = -L$(QTDIR)/lib -lQtCore4 -lQtGui4 MOC = moc else ifeq ($(platform),Darwin) -CXXFLAGS = -I/Library/Frameworks/QtGui.framework/Version/Current/Headers -I/Library/Frameworks/QtCore.framework/Versions/Current/Headers +CXXFLAGS = -I/Library/Frameworks/QtGui.framework/Versions/Current/Headers -I/Library/Frameworks/QtCore.framework/Versions/Current/Headers QTLDLIBS = -framework QtGui -framework QtCore MOC = moc else -- 2.39.5 From 9e13f8751786076891e068ad23fac6a64e6dbad2 Mon Sep 17 00:00:00 2001 From: "izsh@fail0verflow.com" Date: Wed, 24 Feb 2010 20:34:13 +0000 Subject: [PATCH 09/16] Fix a couple of warnings --- armsrc/printf.h | 2 +- armsrc/util.h | 2 +- client/cmdlfem4x.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/armsrc/printf.h b/armsrc/printf.h index c6059922..ff2b6b68 100644 --- a/armsrc/printf.h +++ b/armsrc/printf.h @@ -17,4 +17,4 @@ int kvsprintf(const char *format, void *arg, int radix, va_list ap) __attribute_ int vsprintf(char *str, const char *format, va_list ap) __attribute__ ((format (printf, 2, 0))); int sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3))); -#endif \ No newline at end of file +#endif diff --git a/armsrc/util.h b/armsrc/util.h index 1f4a8174..6f69fba8 100644 --- a/armsrc/util.h +++ b/armsrc/util.h @@ -35,4 +35,4 @@ int BUTTON_CLICKED(int ms); int BUTTON_HELD(int ms); void FormatVersionInformation(char *dst, int len, const char *prefix, void *version_information); -#endif \ No newline at end of file +#endif diff --git a/client/cmdlfem4x.c b/client/cmdlfem4x.c index 8bb4d109..37355ef2 100644 --- a/client/cmdlfem4x.c +++ b/client/cmdlfem4x.c @@ -9,6 +9,7 @@ //----------------------------------------------------------------------------- #include +#include #include "proxusb.h" #include "ui.h" #include "graph.h" -- 2.39.5 From 243dc6900194c533e49daae0d30623918ef31252 Mon Sep 17 00:00:00 2001 From: "izsh@fail0verflow.com" Date: Wed, 24 Feb 2010 20:47:32 +0000 Subject: [PATCH 10/16] Fix memset warning --- client/proxusb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/proxusb.c b/client/proxusb.c index 0a50b991..15513bf0 100644 --- a/client/proxusb.c +++ b/client/proxusb.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include -- 2.39.5 From da133b47a91b3127746552d8493e9919165222ab Mon Sep 17 00:00:00 2001 From: d18c7db Date: Thu, 25 Feb 2010 20:02:01 +0000 Subject: [PATCH 11/16] Delete obsolete windows files --- cockpit/0setpath.bat | 3 - cockpit/1makearm.bat | 10 --- cockpit/2makeboot.bat | 10 --- cockpit/3makewin.bat | 7 -- cockpit/4flashos.bat | 3 - cockpit/5makeall.bat | 7 -- cockpit/_checkmake.bat | 14 --- cockpit/prox.bat | 2 - doc/CHANGES.TXT | 189 ----------------------------------------- doc/README.TXT | 39 --------- 10 files changed, 284 deletions(-) delete mode 100644 cockpit/0setpath.bat delete mode 100644 cockpit/1makearm.bat delete mode 100644 cockpit/2makeboot.bat delete mode 100644 cockpit/3makewin.bat delete mode 100644 cockpit/4flashos.bat delete mode 100644 cockpit/5makeall.bat delete mode 100644 cockpit/_checkmake.bat delete mode 100644 cockpit/prox.bat delete mode 100644 doc/CHANGES.TXT delete mode 100644 doc/README.TXT diff --git a/cockpit/0setpath.bat b/cockpit/0setpath.bat deleted file mode 100644 index 791536b3..00000000 --- a/cockpit/0setpath.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -set PATH=C:\ProxSpace\msys\bin;C:\ProxSpace\msys\mingw\bin;C:\ProxSpace\devkitARM\bin;%PATH% -cmd.exe \ No newline at end of file diff --git a/cockpit/1makearm.bat b/cockpit/1makearm.bat deleted file mode 100644 index f4a53992..00000000 --- a/cockpit/1makearm.bat +++ /dev/null @@ -1,10 +0,0 @@ -@echo off -call _checkmake -IF %MAKE_FAILED%==1 GOTO end -cd ..\armsrc -@echo ************** -@echo *** armsrc *** -@echo ************** -make %1 -cd ..\cockpit -:end diff --git a/cockpit/2makeboot.bat b/cockpit/2makeboot.bat deleted file mode 100644 index 47057037..00000000 --- a/cockpit/2makeboot.bat +++ /dev/null @@ -1,10 +0,0 @@ -@echo off -call _checkmake -IF %MAKE_FAILED%==1 GOTO end -cd ..\bootrom -@echo *************** -@echo *** bootrom *** -@echo *************** -make %1 -cd ..\cockpit -:end diff --git a/cockpit/3makewin.bat b/cockpit/3makewin.bat deleted file mode 100644 index 0332f468..00000000 --- a/cockpit/3makewin.bat +++ /dev/null @@ -1,7 +0,0 @@ -@echo off -cd ..\client -@echo ************** -@echo *** client *** -@echo ************** -make %1 -cd ..\cockpit diff --git a/cockpit/4flashos.bat b/cockpit/4flashos.bat deleted file mode 100644 index d1b794ae..00000000 --- a/cockpit/4flashos.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -REM these actually do the real work -..\client\prox.exe os,fpga ..\armsrc\obj\osimage.s19 ..\armsrc\obj\fpgaimage.s19 diff --git a/cockpit/5makeall.bat b/cockpit/5makeall.bat deleted file mode 100644 index 23ee6e83..00000000 --- a/cockpit/5makeall.bat +++ /dev/null @@ -1,7 +0,0 @@ -@echo off -call _checkmake -IF %MAKE_FAILED%==1 GOTO end -call 1makearm.bat %1 -call 2makeboot.bat %1 -call 3makewin.bat %1 -:end \ No newline at end of file diff --git a/cockpit/_checkmake.bat b/cockpit/_checkmake.bat deleted file mode 100644 index fabb72e6..00000000 --- a/cockpit/_checkmake.bat +++ /dev/null @@ -1,14 +0,0 @@ -@echo off -make -C .. -s _test -IF ERRORLEVEL 1 GOTO fail -SET MAKE_FAILED=0 -GOTO end -:fail -echo ************************************************ -echo * A compatible (GNU) make was not detected * -echo * Please get an updated version of the Windows * -echo * compile environment, or install GNU make * -echo * manually * -echo ************************************************ -SET MAKE_FAILED=1 -:end diff --git a/cockpit/prox.bat b/cockpit/prox.bat deleted file mode 100644 index e0c5bf8d..00000000 --- a/cockpit/prox.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -call ..\client\prox %1 diff --git a/doc/CHANGES.TXT b/doc/CHANGES.TXT deleted file mode 100644 index 815d0cf1..00000000 --- a/doc/CHANGES.TXT +++ /dev/null @@ -1,189 +0,0 @@ -################ -## 2009/04/09 ## -################ -winsrc/gui.cpp - Changes to PaintGraph to create X axis labels that are snapped to a power of two (useful when analysing low freq tags - with cycle times that are a power of two). Also small changes to keep the X axis labels fixed within the graph window - as the width of the graph window is resized. -armsrc/apps.h - New defines for FPGA commands FPGA_CMD_SET_CONFREG, FPGA_CMD_SET_DIVISOR_REG -armsrc/appmain.c - -armsrc/fpga.c - FpgaWriteConfWord(data) is now a special case of FpgaSendCommand(FPGA_CMD_SET_CONFREG, data) to avoid changing every - source file containing FpgaWriteConfWord() -fpga/fpga.v - Changes to the serial conf word, now takes a 4 bit command and 12 bit data code -fpga/lo_read.v - Significant changes to lo_read, it now can be configured with a divisor value to produce a configurable drive clock - for the antenna. - Recompiled FPGA code - -################ -## 2009/04/09 ## -################ - -Initial SVN commit plus: - - Added indala demodulation algorithm - full documentation on https://www.lafargue.name/proxmark3/ - - losim should also be able to simulate an indala tag after indalademod - - offline mode for the proxmark3 CLI: if no Proxmark is detected, it will - still go on, but all commands requiring USB will fail (obviously). - A proper implementation would require only enabling offline commands - in this mode. - - -################ -## 2009/03/28 ## -################ -winsrc/command.cpp - Added two new LF commands for tag exploration : - - - askdemod: takes 2 arguments, one is the clock rate, one is the modulation - convention (high mod is 1 or high mod is zero) - - This command demodulates the stream into a binary stream into - the trace buffer (0's and 1's) - - - mandemod: manchester decoding of a bitstream: takes a binary stream from - the trace buffer (see askdemod) and attempts to do manchester decoding - to it. One argument: clock rate. Outputs the bitstream to the scrollback buffer. - - Those two helped me to validate that the unknown tag I had was indeed an EM4100 type of tag - - -################ -## 2008/12/11 ## -################ -bootrom/bootrom.c - Significant changes to bootloader. Use of Chip ID register to detect if running on a SAM7S512 then configure FLASH - waitstates as per SummoningDark's suggestion for a SAM7S512 or SAM7S256. - Deleted idle loops waiting blindly for clocks to settle and now using status registers to detect when clocks are stable. - - ************************* - * IMPORTANT INFORMATION * - ************************************************************************************************************************** - * With this boot code, the device can now only be flashed if button is held down after power on or a software reset. - * The flash procedure is this: - * Hold down button. Either plug in USB or software reset it. _While_holding_down_button_ (red and yellow LEDs are lit) you can - * issue one or more of the "prox bootrom " "prox fpga " "prox load ", be sure to hold button down for the - * entire duration of the flash process. Only release the button when flashing is complete and you want to let the board boot. - * This process may be less convenient but it's safer and avoids "unintentional" flashing of the board. - ************************************************************************************************************************** - LED boot sequence now changed, C (red) lights up when boot code jumps from flash to RAM boot code, A (yellow) lights up after - clocks have been initialized, B (green) lights up when jumping from boot code to main code, then D (red led away from the others) - lights up while code is being downloaded to FPGA, then all leds turn off and board is ready for action. - - With these changes the board now boots and is ready to use in about 3 seconds. Also since the USB bus is not initialized - twice (once during boot, then again when the main code runs) unless the button is held down at boot, this seems to avoid - the double USB connect and "USB device not recognized" when device is connected to the USB bus or software reset. - -################ -## 2008/12/06 ## -################ -armsrc/fpga.c - Implemented function SetupSpi() to initialize the Serial Peripheral Interface (SPI) in preparation to adding an LCD to the board. - Changed FpgaWriteConfWord() to use the SPI communication now instead of bit banging the serial data to the FPGA. - -fpga/fpga.v - The FPGA config word serializer required non standard SPI communication (ie for shifting in a 8 bit word, it required a 9th clock - cycle with NCS high to load the word from the shift register to the conf register). This was OK for manually bitbanging it but not - suitable for using SPI comms. The serializer was fixed to load the conf word from the shift register on a NCS lo-hi transition and - not require additional clocking. - -armsrc/fpgaimg.c - Recompiled FPGA code after changes above. - -armsrc/LCD.c - LCD driver for PCF8833 based LCDs like those found on Nokia models 2600,2650,3100,3120,5140,6030,6100,6610,7210,7250 maybe - others. These color LCDs have a resolution of 132x132 and a serial interface. They are very cheap like even down to $2/pc - This LCD driver is a straight rip of that found at http://www.sparkfun.com/datasheets/LCD/Jimbo-Nokia-SAM7-Example.zip with - very small changes, mainly to integrate it and make it compile with our codebase. Also comented out the circle subroutines - to keep the code to integer math only. - -armsrc/fonts.c - Font definition for LCD driver - -armsrc/appmain.c - Fixed a small bug in CmdHIDdemodFSK (added case 4) which prevented reading some tags. When a logic 0 is immediately followed - by the start of the next transmisson (special pattern) a pattern of 4 bit duration lengths is created. - -################ -## 2008/11/27 ## -################ -armsrc/appmain.c - Implemented an HID tag FSK demodulator (CmdHIDdemodFSK) to obtain the tag ID code from the raw sampled waveform. - Implemented CmdHIDsimTAG which takes a 44bit HID tag ID as a hex number then creates the waveform and simulates the tag - -winsrc/command.cpp - Added command "hidfskdemod" that calls CmdHIDdemodFSK, the ARM FSK demodulator for HID tags. - -include/usb-cmd.h - New defines CMD_HID_DEMOD_FSK and CMD_HID_SIM_TAG - -2008/11/25 -common/iso14443_crc.c - Moved CRC calculation code into this file as it's common to both ARM and Windows side. This file is now included as needed. - -################ -## 2008/11/21 ## -################ -armsrc/Makefile - Changes to split up the compilation of the ARM and produce separate S files for the FPGA code and the ARM code. - -armsrc/appmain.c - Replaced some of the hex value params in FpgaWriteConfWord with more explanatory defines. - Changes to the Tune command as it assumes wrong HF capacitor value (130pF) and produces wrong voltage readings. - Combined some of the integer arithmetic statements to improve accuracy slightly, since the voltage divider ratio is not an integer. - Voltage divider resistor network is 10M/240k = ratio of 41.6666 - - Originally the calculation was rounding the ratio down to 41 - 3300 (mV) * 41 * sample_value / 1024 - New calculation without rounding error is - 3300 (mV) * 41.66666 * sample_value / 1024 => 137500 * sample_value / 1024 - - New define BUTTON_PRESS() returns status of button - -armsrc/fpga.c - The current board can only take a X2S30 as there is no larger FPGA in PQFP100 package and - the smaller X2S15 FPGA can't fit the current code. The X2S30 FPGA config is fixed at 336,768 bits - The FPGA code base address and length is hard coded to occupy FLASH region 0x2000 - 0xC470. - -armsrc/ldscript-fpga - New file to place the FPGA code at FLASH address 0x2000 - -bootrom/Makefile - Slight changes, commented out the generation of byteswapped S file, the other S files are generated in the same section of the makefile now. - -bootrom/bootrom.c - Changed some thumb code with a one line ARM code which is clearer and more explicit. Processor runs in ARM mode at reset anyway. - Changed jump to RAM address, used to jump to 0x2000 (now FPGA area), now jumps to 0x10000. - -bootrom/flash-reset.s - Changed name of CMain to CopyBootToRAM. Streamlined reset code, fixed up stack pointer initialization. - -bootrom/fromflash.c - Removed the whole section of initializing clocks, this is redundant as it's being done once we jump to boot code in RAM - All fromflash.c does now is copy the boot code to ram and jumps to it. - -bootrom/ram-reset.s - Fixed up stack pointer initialization that caused crash when using "loread" - -include/at91sam7s128.h - New defines for debug register, lets you identify what processor flavour the code runs on, RAM and FLASH sizes, etc. - -include/proxmark3.h - New useful defines for relay and button - -winsrc/Makefile - Added new define /D_CRT_SECURE_NO_WARNINGS to elliminate a _whole bunch_ of bogus compilation warnings - -winsrc/command.cpp - Changed CmdLosamples to take a numeric argument (number of samples x4 to retrieve from buffer) - New command Quit to exit the program from the GUI command prompt. - -winsrc/gui.cpp - Fixup compilation warnings. - -winsrc/prox.cpp - Tidy up printing to stdout, flashing progress now updates on the same line instead of scrolling up. - New command line parameter to load FPGA image to FLASH. diff --git a/doc/README.TXT b/doc/README.TXT deleted file mode 100644 index f3b49c77..00000000 --- a/doc/README.TXT +++ /dev/null @@ -1,39 +0,0 @@ -This is a bare minimum compile environment for the proxmark3 sources. - -CONTENTS - -This bundle contains the ARM cross compiler in devkitARM and a _tiny_ subset -of the Visual C++ 2008 Express Edition in devkitWIN which is the bare minimum -required for compilation of this current source. - -If you plan on further source code development you are strongly encouraged -to download the full Visual C++ 2008 available for free download from -http://www.microsoft.com/express/download/ - -CAVEATS - -There is no provision in this environment for compiling the FPGA source. To -do that you need to download the free (registration required) ISE WebPack -from Xilinx at http://www.xilinx.com/ise/logic_design_prod/webpack.htm -Be warned, the pack is huge, 2Gb download and >4Gb installed. - -USAGE - -First of all run the .msi file in devkitWIN\vcredist_x86 to install the VC++ -redistributables, without these, nmake, cl and link won't run. - -Get a command prompts in the cockpit directory and pretty much run the batch -files in the order they appear: - -0setpath.bat - sets the environment vars for the compile environment -1makearm.bat - compiles the files in armsrc, output files in armsrc\obj -2makeboot.bat - compiles the files in bootrom, output files in bootrom\obj -3makewin.bat - compiles the files in winsrc, output files in winsrc\obj -4flashos.bat - attempts to upload the OS image to the proxmark3 board - -ACKNOWLEDGMENTS - -Thanks to J Westhues for the original proxmark, Roel and the proxmark.org -community. This pack may contain F/OSS or free but copyrighted software -from Xilinx, Microsoft and others. All trademarks are the property of -their respective owners. All rights reserved. -- 2.39.5 From 212ef3a04d19bcb5299c38fd153ee434e0f26efd Mon Sep 17 00:00:00 2001 From: "izsh@fail0verflow.com" Date: Thu, 25 Feb 2010 21:57:35 +0000 Subject: [PATCH 13/16] Apply copyright patch from Michael Gernoth --- client/guidummy.c | 2 ++ client/proxgui.cpp | 2 ++ client/proxgui.h | 2 ++ client/proxguiqt.cpp | 2 ++ client/proxguiqt.h | 2 ++ client/proxmark3.c | 1 + client/proxmark3.h | 1 + client/proxusb.c | 1 + client/snooper.c | 2 ++ client/ui.c | 1 + 10 files changed, 16 insertions(+) diff --git a/client/guidummy.c b/client/guidummy.c index 2c813002..b42dea24 100644 --- a/client/guidummy.c +++ b/client/guidummy.c @@ -1,4 +1,6 @@ //----------------------------------------------------------------------------- +// Copyright (C) 2009 Michael Gernoth +// // This code is licensed to you under the terms of the GNU GPL, version 2 or, // at your option, any later version. See the LICENSE.txt file for the text of // the license. diff --git a/client/proxgui.cpp b/client/proxgui.cpp index fabbd204..12faab79 100644 --- a/client/proxgui.cpp +++ b/client/proxgui.cpp @@ -1,4 +1,6 @@ //----------------------------------------------------------------------------- +// Copyright (C) 2009 Michael Gernoth +// // This code is licensed to you under the terms of the GNU GPL, version 2 or, // at your option, any later version. See the LICENSE.txt file for the text of // the license. diff --git a/client/proxgui.h b/client/proxgui.h index 32121e58..8e86bd9c 100644 --- a/client/proxgui.h +++ b/client/proxgui.h @@ -1,4 +1,6 @@ //----------------------------------------------------------------------------- +// Copyright (C) 2009 Michael Gernoth +// // This code is licensed to you under the terms of the GNU GPL, version 2 or, // at your option, any later version. See the LICENSE.txt file for the text of // the license. diff --git a/client/proxguiqt.cpp b/client/proxguiqt.cpp index f687bdf4..f0038683 100644 --- a/client/proxguiqt.cpp +++ b/client/proxguiqt.cpp @@ -1,4 +1,6 @@ //----------------------------------------------------------------------------- +// Copyright (C) 2009 Michael Gernoth +// // This code is licensed to you under the terms of the GNU GPL, version 2 or, // at your option, any later version. See the LICENSE.txt file for the text of // the license. diff --git a/client/proxguiqt.h b/client/proxguiqt.h index b76a5ea7..303a37d0 100644 --- a/client/proxguiqt.h +++ b/client/proxguiqt.h @@ -1,4 +1,6 @@ //----------------------------------------------------------------------------- +// Copyright (C) 2009 Michael Gernoth +// // This code is licensed to you under the terms of the GNU GPL, version 2 or, // at your option, any later version. See the LICENSE.txt file for the text of // the license. diff --git a/client/proxmark3.c b/client/proxmark3.c index b98afd9a..08a4e264 100644 --- a/client/proxmark3.c +++ b/client/proxmark3.c @@ -1,4 +1,5 @@ //----------------------------------------------------------------------------- +// Copyright (C) 2009 Michael Gernoth // Copyright (C) 2010 iZsh // // This code is licensed to you under the terms of the GNU GPL, version 2 or, diff --git a/client/proxmark3.h b/client/proxmark3.h index d70170dd..f5dd2b7f 100644 --- a/client/proxmark3.h +++ b/client/proxmark3.h @@ -1,4 +1,5 @@ //----------------------------------------------------------------------------- +// Copyright (C) 2009 Michael Gernoth // Copyright (C) 2010 iZsh // // This code is licensed to you under the terms of the GNU GPL, version 2 or, diff --git a/client/proxusb.c b/client/proxusb.c index 15513bf0..55ce9d68 100644 --- a/client/proxusb.c +++ b/client/proxusb.c @@ -1,4 +1,5 @@ //----------------------------------------------------------------------------- +// Copyright (C) 2009 Michael Gernoth // Copyright (C) 2010 iZsh // // This code is licensed to you under the terms of the GNU GPL, version 2 or, diff --git a/client/snooper.c b/client/snooper.c index ccff8333..009a89f7 100644 --- a/client/snooper.c +++ b/client/snooper.c @@ -1,4 +1,6 @@ //----------------------------------------------------------------------------- +// Copyright (C) 2009 Michael Gernoth +// // This code is licensed to you under the terms of the GNU GPL, version 2 or, // at your option, any later version. See the LICENSE.txt file for the text of // the license. diff --git a/client/ui.c b/client/ui.c index 0b4183df..da21049e 100644 --- a/client/ui.c +++ b/client/ui.c @@ -1,4 +1,5 @@ //----------------------------------------------------------------------------- +// Copyright (C) 2009 Michael Gernoth // Copyright (C) 2010 iZsh // // This code is licensed to you under the terms of the GNU GPL, version 2 or, -- 2.39.5 From a63deed1722fbe3f08d72400793197200ba58062 Mon Sep 17 00:00:00 2001 From: "izsh@fail0verflow.com" Date: Fri, 26 Feb 2010 13:06:07 +0000 Subject: [PATCH 14/16] common/Makefile.common: Revert the DEVKITARM change. Just need to put the cross compiler in the path. No need to hardcode for a given distribution and a given version. --- common/Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/Makefile.common b/common/Makefile.common index 7072ede5..6fb2045f 100644 --- a/common/Makefile.common +++ b/common/Makefile.common @@ -41,7 +41,7 @@ PATHSEP=/ FLASH_TOOL=client/flasher DETECTED_OS=UNAME # You may/should set this in your environment -LIBGCC ?= $(DEVKITARM)/lib/gcc/arm-eabi/4.4.2/libgcc.a +LIBGCC ?= $(shell $(CC) -print-libgcc-file-name) PATH := $(PATH):$(DEVKITARM)/bin else -- 2.39.5 From e0c67c7f454e657a0ff0423cd70936feeebd8a48 Mon Sep 17 00:00:00 2001 From: "izsh@fail0verflow.com" Date: Fri, 26 Feb 2010 13:49:49 +0000 Subject: [PATCH 15/16] COMPILING.txt: Request for the arm crosscompiler to be in the PATH --- COMPILING.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/COMPILING.txt b/COMPILING.txt index 21782e2f..0d228c43 100644 --- a/COMPILING.txt +++ b/COMPILING.txt @@ -50,6 +50,8 @@ You only need devkitARM, nothing more (no extra lib or anything else) Assuming you installed it to C:\devkitpro, make sure you set the DEVKITARM environment variable to /c/devkitPro/devkitARM : export DEVKITARM=/c/devkitPro/devkitARM +Also, add its bin to your PATH: +export PATH=$PATH:$DEVKITARM/bin 6 - Install Strawberry Perl [6] -- 2.39.5 From 845ea63b7cf7dfcfc43d506be61da35021b0256f Mon Sep 17 00:00:00 2001 From: marcansoft Date: Fri, 26 Feb 2010 13:59:37 +0000 Subject: [PATCH 16/16] Clean up common linker script --- common/ldscript.common | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/common/ldscript.common b/common/ldscript.common index e149b452..7cde5891 100644 --- a/common/ldscript.common +++ b/common/ldscript.common @@ -11,18 +11,12 @@ /* AT91SAM7S256 has 256k Flash and 64k RAM */ MEMORY { - /* Important note: this memory map has the correct origins for all the flash sections. - However, this will confuse the currently deployed flash code which expects logical and and not - physical addresses and performs no sanity checks at all. If confronted with physical addresses, - it will happily erase everything and brick the device. So for the time being translate these addresses - down in the objcopy call while updating all the flash code with proper sanity checks, then come - back later and fix the addresses. -- Henryk Plötz 2009-08-27 */ - bootphase1 : ORIGIN = 0x00100000, LENGTH = 0x200 /* Phase 1 bootloader: Copies real bootloader to RAM */ - bootphase2 : ORIGIN = 0x00100200, LENGTH = 0x2000 - 0x200 /* Main bootloader code, stored in Flash, executed from RAM */ - fpgaimage : ORIGIN = 0x00102000, LENGTH = 64k - 0x2000 /* Place where the FPGA image will end up */ - osimage : ORIGIN = 0x00110000, LENGTH = 256K - 64k /* Place where the main OS will end up */ - ram : ORIGIN = 0x00200000, LENGTH = 64K - 0x20 /* RAM, minus small common area */ - commonarea : ORIGIN = 0x00200000 + 64K - 0x20, LENGTH = 0x20 /* Communication between bootloader and main OS */ + bootphase1 : ORIGIN = 0x00100000, LENGTH = 0x200 /* Phase 1 bootloader: Copies real bootloader to RAM */ + bootphase2 : ORIGIN = 0x00100200, LENGTH = 0x2000 - 0x200 /* Main bootloader code, stored in Flash, executed from RAM */ + fpgaimage : ORIGIN = 0x00102000, LENGTH = 64k - 0x2000 /* Place where the FPGA image will end up */ + osimage : ORIGIN = 0x00110000, LENGTH = 256K - 64k /* Place where the main OS will end up */ + ram : ORIGIN = 0x00200000, LENGTH = 64K - 0x20 /* RAM, minus small common area */ + commonarea : ORIGIN = 0x00200000 + 64K - 0x20, LENGTH = 0x20 /* Communication between bootloader and main OS */ } /* Export some information that can be used from within the firmware */ -- 2.39.5