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