sequences.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. """
  2. Sequences for various board actions
  3. These methods are generators that will yield as first element the number
  4. of actions (other yields) excluding it self
  5. They will then perform the next action in row (setting registers or reading values from boards etc)
  6. and will yield True or False depending on the result of the action performed
  7. """
  8. import logging
  9. from . import *
  10. from utils import *
  11. def startup_sequence(board_id):
  12. NUMBER = 4
  13. yield NUMBER
  14. pci.start_dma(board_id)
  15. pci.write(board_id, '0x20001000', '0x9100')
  16. pci.write(board_id, '0x05', '0x9040')
  17. yield True
  18. pci.write(board_id, '0x3C1', '0x9040')
  19. logging.info("9040: " + str(pci.read(board_id, 1, '0x9040')[0]))
  20. yield True
  21. pci.write(board_id, '0x3F1', '0x9040')
  22. logging.info("9040: " + str(pci.read(board_id, 1, '0x9040')[0]))
  23. yield True
  24. pci.write(board_id, '0x3F0', '0x9040')
  25. logging.info("9040: " + str(pci.read(board_id, 1, '0x9040')[0]))
  26. yield True
  27. def calibration_sequence(board_id):
  28. NUMBER = 15
  29. yield NUMBER
  30. # Removing Board Reset
  31. pci.write(board_id, '0x2000003f0', '0x9040')
  32. yield True
  33. # SPI Fanout Programming...
  34. pci.write(board_id, '0x083', '0x9068')
  35. yield True
  36. pci.write(board_id, '0x6a2', '0x9068')
  37. yield True
  38. # PLL calibration start...
  39. # PLL Reset...
  40. pci.write(board_id, '0x80000000', '0x9060')
  41. yield True
  42. # Set CH_0 (FPGA) clock FPGA ...
  43. pci.write(board_id, '0x00050000', '0x9060')
  44. yield True
  45. # Set CH_3 clock fanout ...
  46. pci.write(board_id, '0x00050003', '0x9060')
  47. yield True
  48. # Set CH_4 clock ADC 1 ...
  49. pci.write(board_id, '0x00050004', '0x9060')
  50. yield True
  51. # Set CH_5 clock ADC 2 ...
  52. pci.write(board_id, '0x00050005', '0x9060')
  53. yield True
  54. # Set CH_6 clock ADC 3 ...
  55. pci.write(board_id, '0x00050006', '0x9060')
  56. yield True
  57. # Set CH_7 clock ADC 4 ...
  58. pci.write(board_id, '0x00050007', '0x9060')
  59. yield True
  60. # Set R8 ...
  61. pci.write(board_id, '0x10000908', '0x9060')
  62. yield True
  63. # Set R11 ...
  64. pci.write(board_id, '0x0082800B', '0x9060')
  65. yield True
  66. # Set R13 ...
  67. pci.write(board_id, '0x029F400D', '0x9060')
  68. yield True
  69. # Set R14 (F_out and Global_EN => ON) ...
  70. pci.write(board_id, '0x0830040E', '0x9060')
  71. yield True
  72. # Set R15 ...
  73. pci.write(board_id, '0xD000100F', '0x9060')
  74. yield True
  75. def synchronisation_sequence(board_id):
  76. NUMBER = 2
  77. yield NUMBER
  78. # Send the PLL sync signals ...
  79. pci.write(board_id, '0x1003f0', '0x9040')
  80. yield True
  81. pci.write(board_id, '0x0003f0', '0x9040')
  82. yield True
  83. def write_value_sequence(board_id):
  84. NUMBER = 8
  85. yield NUMBER
  86. # Set_FPGA_clock_delay.sh 0
  87. get_board_config(board_id).set_fpga_delay(get_board_config(board_id).get('fpga_delay'))
  88. yield True
  89. # Set_Delay_chip.sh 16 16 16 16
  90. factors = [get_board_config(board_id).get('chip_1_delay'), get_board_config(board_id).get('chip_2_delay'),
  91. get_board_config(board_id).get('chip_3_delay'), get_board_config(board_id).get('chip_4_delay')]
  92. get_board_config(board_id).set_chip_delay([0, 1, 2, 3], factors)
  93. yield True
  94. # Set_TH_Delay.sh 12
  95. get_board_config(board_id).set_th_delay(get_board_config(board_id).get('th_delay'))
  96. yield True
  97. # Set_ADC_1_Delay.sh 4
  98. get_board_config(board_id).set_adc_delay(0, get_board_config(board_id).get('adc_1_delay'))
  99. yield True
  100. # Set_ADC_2_Delay.sh 4
  101. get_board_config(board_id).set_adc_delay(1, get_board_config(board_id).get('adc_2_delay'))
  102. yield True
  103. # Set_ADC_3_Delay.sh 4
  104. get_board_config(board_id).set_adc_delay(2, get_board_config(board_id).get('adc_3_delay'))
  105. yield True
  106. # Set_ADC_4_Delay.sh 4
  107. get_board_config(board_id).set_adc_delay(3, get_board_config(board_id).get('adc_4_delay'))
  108. yield True
  109. pci.write(board_id, '{0:08x}'.format(get_board_config(board_id).get('orbits_observe')), '0x9020')
  110. yield True
  111. pci.write(board_id, '{0:08x}'.format(get_board_config(board_id).get('orbits_skip')), '0x9028')
  112. yield True