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.
 
 
 
 
 
 

91 lines
2.5 KiB

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