1
0
mirror of https://git.code.sf.net/p/openocd/code synced 2024-11-24 17:36:22 +00:00
openocd/tcl/fpga/xilinx-dna.cfg
George Voicu ed30c9a572 tcl/fpga/xilinx-dna: Support for reading Spartan3 DNA code
Add Xilinx Spartan3 ISC_DNA instruction

Signed-off-by: George Voicu <razvanvg@hotmail.com>
Change-Id: Iaddb079c9fdd1b91c65def36878fe81783098696
Reviewed-on: https://review.openocd.org/c/openocd/+/7331
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-06-15 14:13:28 +00:00

52 lines
1.4 KiB
INI

# SPDX-License-Identifier: GPL-2.0-or-later
# Spartan3: Table 9-5 in https://www.xilinx.com/support/documentation/user_guides/ug332.pdf
proc xilinx_dna_addr {chip} {
array set addrs {
Spartan3 0x31
Spartan6 0x30
Series7 0x17
}
return $addrs($chip)
}
# Get the "Device DNA".
# Most Xilinx FPGA devices contain an embedded, unique device identifier.
# The identifier is nonvolatile, permanently programmed into
# the FPGA, and is unchangeable providing a great serial / tracking number.
# This function returns the DNA as a 64 bit integer with the 7 LSBs zeroed.
# This is compatible with the FUSE DNA which contains all 64 bits.
proc xilinx_get_dna {tap chip} {
set XC7_ISC_ENABLE 0x10
set XC7_ISC_DISABLE 0x16
set XC7_ISC_DNA [xilinx_dna_addr $chip]
irscan $tap $XC7_ISC_ENABLE
runtest 64
irscan $tap $XC7_ISC_DNA
scan [drscan $tap 32 0 32 0] "%08x %08x" hi lo
runtest 64
irscan $tap $XC7_ISC_DISABLE
runtest 64
# openocd interprets DR scans as LSB first, bit-reverse it
return [scan [string reverse [format "%032b%032bb0" $lo $hi]] "%i"]
}
# Print out the "Device DNA" in the same format that impact uses.
proc xilinx_print_dna {dna} {
set dna [expr {$dna >> 64 - 57}]
echo [format "DNA = %057b (0x%016x)" $dna $dna]
}
proc xc7_get_dna {tap} {
return [xilinx_get_dna $tap Series7]
}
proc xc6s_get_dna {tap} {
return [xilinx_get_dna $tap Spartan6]
}
proc xc3s_get_dna {tap} {
return [xilinx_get_dna $tap Spartan3]
}