xilinx-xc6s.cfg 2.7 KB

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