1 # SPDX-License-Identifier: GPL-2.0-or-later
4 # http://www.xilinx.com/support/documentation/user_guides/ug380.pdf
6 if { [info exists CHIPNAME] } {
7 set _CHIPNAME $CHIPNAME
12 # the 4 top bits (28:31) are the die stepping. ignore it.
13 jtag newtap $_CHIPNAME tap -irlen 6 -ignore-version \
14 -expected-id 0x04000093 \
15 -expected-id 0x04001093 \
16 -expected-id 0x04002093 \
17 -expected-id 0x04004093 \
18 -expected-id 0x04024093 \
19 -expected-id 0x04008093 \
20 -expected-id 0x04028093 \
21 -expected-id 0x0400E093 \
22 -expected-id 0x0402E093 \
23 -expected-id 0x04011093 \
24 -expected-id 0x04031093 \
25 -expected-id 0x0401D093 \
26 -expected-id 0x0403D093
28 pld device virtex2 $_CHIPNAME.tap
31 set XC6S_JSHUTDOWN 0x0d
32 set XC6S_JPROGRAM 0x0b
36 proc xc6s_program {tap} {
37 global XC6S_JSHUTDOWN XC6S_JPROGRAM XC6S_JSTART XC6S_BYPASS
38 irscan $tap $XC6S_JSHUTDOWN
39 irscan $tap $XC6S_JPROGRAM
40 irscan $tap $XC6S_JSTART
41 irscan $tap $XC6S_BYPASS
44 #xtp038 and xc3sprog approach
45 proc xc6s_program_iprog {tap} {
46 global XC6S_JSHUTDOWN XC6S_JSTART XC6S_BYPASS XC6S_CFG_IN
47 irscan $tap $XC6S_JSHUTDOWN
49 irscan $tap $XC6S_CFG_IN
50 # xtp038 IPROG 16bit flipped
51 drscan $tap 16 0xffff 16 0x9955 16 0x66aa 16 0x850c 16 0x7000 16 0x0004
52 irscan $tap $XC6S_JSTART
54 irscan $tap $XC6S_BYPASS
58 set XC6S_ISC_ENABLE 0x10
59 set XC6S_ISC_DISABLE 0x16
62 # Get the "Device DNA" from the Spartan 6.
63 # Most Xilinx FPGA devices contain an embedded, unique device identifier called
64 # the "Device DNA". The identifier is nonvolatile, permanently programmed into
65 # the FPGA, and is unchangeable providing a great serial / tracking number.
66 proc xc6s_get_dna {tap} {
67 global XC6S_ISC_ENABLE XC6S_ISC_DISABLE XC6S_ISC_DNA
68 irscan $tap $XC6S_ISC_ENABLE
70 irscan $tap $XC6S_ISC_DNA
71 # Device DNA is 57 bits long, but we can only read 32bits at a time
73 set dna [drscan $tap 16 0 16 0 16 0 9 0]
75 irscan $tap $XC6S_ISC_DISABLE
78 # Convert the binary data into the order impact uses
79 scan $dna "%x %x %x %x" v1 v2 v3 v4
80 set bin_dna [string reverse [concat [format "%09b" $v4][format "%016b" $v3][format "%016b" $v2][format "%016b" $v1]]]
82 # Return a hex version of binary
83 scan [format "0b%s" $bin_dna] "%i" hex_dna
87 # Print out the "Device DNA" in the same format that impact uses.
88 proc xc6s_print_dna {tap} {
89 set hex_dna [xc6s_get_dna $tap]
91 puts [format "DNA = %57b (0x%x)\n" $hex_dna $hex_dna]