You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

44 lines
1.2 KiB

  1. proc xilinx_dna_addr {chip} {
  2. array set addrs {
  3. Spartan6 0x30
  4. Series7 0x17
  5. }
  6. return $addrs($chip)
  7. }
  8. # Get the "Device DNA".
  9. # Most Xilinx FPGA devices contain an embedded, unique device identifier.
  10. # The identifier is nonvolatile, permanently programmed into
  11. # the FPGA, and is unchangeable providing a great serial / tracking number.
  12. # This function returns the DNA as a 64 bit integer with the 7 LSBs zeroed.
  13. # This is compatible with the FUSE DNA which contains all 64 bits.
  14. proc xilinx_get_dna {tap chip} {
  15. set XC7_ISC_ENABLE 0x10
  16. set XC7_ISC_DISABLE 0x16
  17. set XC7_ISC_DNA [xilinx_dna_addr $chip]
  18. irscan $tap $XC7_ISC_ENABLE
  19. runtest 64
  20. irscan $tap $XC7_ISC_DNA
  21. scan [drscan $tap 32 0 32 0] "%08x %08x" hi lo
  22. runtest 64
  23. irscan $tap $XC7_ISC_DISABLE
  24. runtest 64
  25. # openocd interprets DR scans as LSB first, bit-reverse it
  26. return [scan [string reverse [format "%032b%032bb0" $lo $hi]] "%i"]
  27. }
  28. # Print out the "Device DNA" in the same format that impact uses.
  29. proc xilinx_print_dna {dna} {
  30. set dna [expr {$dna >> 64 - 57}]
  31. echo [format "DNA = %057b (0x%016x)" $dna $dna]
  32. }
  33. proc xc7_get_dna {tap} {
  34. return [xilinx_get_dna $tap Series7]
  35. }
  36. proc xc6s_get_dna {tap} {
  37. return [xilinx_get_dna $tap Spartan6]
  38. }