aboutsummaryrefslogtreecommitdiff
path: root/tcl/fpga
diff options
context:
space:
mode:
authorRobert Jordens <jordens@gmail.com>2018-02-05 11:54:29 +0000
committerMatthias Welwarsky <matthias@welwarsky.de>2018-03-30 16:22:42 +0100
commit3d3b45af465f6dcfc85ea69cc10a719bc3b2851c (patch)
tree170f61d0cbe32bb50e17b42dcbf93106a1330b3d /tcl/fpga
parent27473588a40604822dcbee1c1950d27fdf248fe9 (diff)
xilinx-dna.cfg: generic tools for reading Xilinx 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 commit adds generic support for reading the Xilinx Spartan 6 and 7 Series (Kintex, Artix, Ultrascale) Device DNA. The code is similar to the function in fpga/xilinx-xc6s.cfg for Spartan 6 but the register addresses are different and the logic has been simplified. The code was not placed in xilinx-xc7.cfg. The approach of defining taps in the same file as library code to use them is fundamentally broken on boards that have more than one FPGA or other chips. This commit (like the addition of support for Xilinx XADC) starts to remedy that by splitting library code from board-specific fixed definitions. The support code is sourced in the Kasli and KC705 board support files as it was tested on these boards. Change-Id: Iba559c7c1b7e93e1270535fd9e6650007f3794da Signed-off-by: Robert Jordens <jordens@gmail.com> Reviewed-on: http://openocd.zylin.com/4396 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Diffstat (limited to 'tcl/fpga')
-rw-r--r--tcl/fpga/xilinx-dna.cfg43
1 files changed, 43 insertions, 0 deletions
diff --git a/tcl/fpga/xilinx-dna.cfg b/tcl/fpga/xilinx-dna.cfg
new file mode 100644
index 00000000..a1d5ba37
--- /dev/null
+++ b/tcl/fpga/xilinx-dna.cfg
@@ -0,0 +1,43 @@
+proc xilinx_dna_addr {chip} {
+ array set addrs {
+ 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]
+}