Skip to content

Commit

Permalink
Merge pull request #253 from larpix/issue/lightpix_config_bug
Browse files Browse the repository at this point in the history
fixing lightpix-v1 naming bugs and bugs in register building
  • Loading branch information
seg188 committed Aug 28, 2023
2 parents 7910985 + 8eca640 commit 23d38fa
Show file tree
Hide file tree
Showing 4 changed files with 230 additions and 6 deletions.
6 changes: 3 additions & 3 deletions larpix/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class for the key specification. Key can be specified by a valid keystring
self.config = Configuration_v1()
elif self.asic_version == 2:
self.config = Configuration_v2()
elif self.asic_version == 'lightpix-v1.0':
elif self.asic_version == 'lightpix-1':
self.config = Configuration_Lightpix_v1()
elif self.asic_version == '2b':
self.config = Configuration_v2b()
Expand Down Expand Up @@ -61,7 +61,7 @@ def is_chip_id_set(self):
'''
if self.asic_version == 1:
return True
elif self.asic_version in (2, 'lightpix-v1.0'):
elif self.asic_version in (2, 'lightpix-1'):
return self.config.chip_id == self.chip_id

def get_configuration_packets(self, packet_type, registers=None):
Expand All @@ -77,7 +77,7 @@ def get_configuration_packets(self, packet_type, registers=None):
packets = []
if self.asic_version == 1:
packet_register_data = enumerate(conf.all_data())
elif self.asic_version in (2, 'lightpix-v1.0', '2b'):
elif self.asic_version in (2, 'lightpix-1', '2b'):
packet_register_data = zip(*conf.some_data(registers))
for i, data in packet_register_data:
if i not in registers:
Expand Down
77 changes: 75 additions & 2 deletions larpix/configs/chip/default_lightpix_v1.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,83 @@
{
"_config_type": "chip",
"_include": ["chip/default_v2.json"],
"class": "Configuration_Lightpix_v1",
"register_values": {
"lightpix_mode": 0,
"pixel_trim_dac": [16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16],
"threshold_global": 255,
"csa_gain": 0,
"csa_bypass_enable": 0,
"bypass_caps_en": 1,
"csa_enable": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
"ibias_tdac": 8,
"ibias_comp": 8,
"ibias_buffer": 8,
"ibias_csa": 8,
"ibias_vref_buffer": 8,
"ibias_vcm_buffer": 8,
"ibias_tpulse": 5,
"ref_current_trim": 16,
"override_ref": 0,
"ref_kickstart": 0,
"vref_dac": 219,
"vcm_dac": 77,
"csa_bypass_select": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"csa_monitor_select": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"csa_testpulse_enable": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
"csa_testpulse_dac": 0,
"current_monitor_bank0": [0, 0, 0, 0],
"current_monitor_bank1": [0, 0, 0, 0],
"current_monitor_bank2": [0, 0, 0, 0],
"current_monitor_bank3": [0, 0, 0, 0],
"voltage_monitor_bank0": [0, 0, 0],
"voltage_monitor_bank1": [0, 0, 0],
"voltage_monitor_bank2": [0, 0, 0],
"voltage_monitor_bank3": [0, 0, 0],
"voltage_monitor_refgen": [0, 0, 0, 0, 0, 0, 0, 0],
"digital_monitor_enable": 0,
"digital_monitor_select": 0,
"digital_monitor_chan": 0,
"slope_control0": 0,
"slope_control1": 0,
"slope_control2": 0,
"slope_control3": 0,
"chip_id": 1,
"load_config_defaults": 0,
"enable_fifo_diagnostics": 0,
"clk_ctrl": 0,
"enable_miso_upstream": [0, 0, 0, 0],
"enable_miso_downstream": [0, 0, 0, 0],
"enable_miso_differential": [1, 1, 1, 1],
"enable_mosi": [1, 1, 1, 1],
"test_mode_uart0": 0,
"test_mode_uart1": 0,
"test_mode_uart2": 0,
"test_mode_uart3": 0,
"enable_cross_trigger": 0,
"enable_periodic_reset": 0,
"enable_rolling_periodic_reset": 0,
"enable_periodic_trigger": 0,
"enable_rolling_periodic_trigger": 0,
"enable_periodic_trigger_veto": 1,
"enable_hit_veto": 1,
"adc_hold_delay": 0,
"adc_burst_length": 0,
"channel_mask": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
"external_trigger_mask": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
"cross_trigger_mask": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
"periodic_trigger_mask": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
"periodic_reset_cycles": 4096,
"periodic_trigger_cycles": 0,
"enable_dynamic_reset": 0,
"enable_min_delta_adc": 0,
"threshold_polarity": 1,
"reset_length": 1,
"mark_first_packet": 1,
"reset_threshold": 0,
"min_delta_adc": 0,
"digital_threshold": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"lightpix_mode": 0,
"hit_threshold": 16,
"timeout": 30

}
}
148 changes: 147 additions & 1 deletion larpix/configuration/configuration_lightpix_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Configuration_Lightpix_v1(Configuration_v2):
'''

asic_version = 'lightpix-v1.0'
asic_version = 'lightpix-1'
default_configuration_file = 'chip/default_lightpix_v1.json'
num_registers = 239
num_bits = 1912
Expand All @@ -34,6 +34,152 @@ def __init__(self):
## Set up property info
#
_property_configuration = OrderedDict([
('pixel_trim_dac',
(v2_base._list_property, (int, 0, 31, Configuration_v2.num_channels, 8), (0,512))),
('threshold_global',
(v2_base._basic_property, (int, 0, 255), (512, 520))),
('csa_gain',
(v2_base._compound_property, (['csa_gain', 'csa_bypass_enable','bypass_caps_en'], (int,bool), 0, 1), (520,521))),
('csa_bypass_enable',
(v2_base._compound_property, (['csa_gain', 'csa_bypass_enable','bypass_caps_en'], (int,bool), 0, 1), (521,522))),
('bypass_caps_en',
(v2_base._compound_property, (['csa_gain', 'csa_bypass_enable','bypass_caps_en'], (int,bool), 0, 1), (522,523))),
('csa_enable',
(v2_base._list_property, ((int,bool), 0, 1, Configuration_v2.num_channels, 1), (528, 592))),
('ibias_tdac',
(v2_base._basic_property, (int, 0, 15), (592, 596))),
('ibias_comp',
(v2_base._basic_property, (int, 0, 15), (600, 604))),
('ibias_buffer',
(v2_base._basic_property, (int, 0, 15), (608, 612))),
('ibias_csa',
(v2_base._basic_property, (int, 0, 15), (616, 620))),
('ibias_vref_buffer',
(v2_base._basic_property, (int, 0, 15), (624, 628))),
('ibias_vcm_buffer',
(v2_base._basic_property, (int, 0, 15), (632, 636))),
('ibias_tpulse',
(v2_base._basic_property, (int, 0, 15), (640, 644))),
('ref_current_trim',
(v2_base._compound_property, (['ref_current_trim','override_ref','ref_kickstart'], int, 0, 31), (648, 653))),
('override_ref',
(v2_base._compound_property, (['ref_current_trim','override_ref','ref_kickstart'], (int,bool), 0, 1), (653, 654))),
('ref_kickstart',
(v2_base._compound_property, (['ref_current_trim','override_ref','ref_kickstart'], (int,bool), 0, 1), (654, 655))),
('vref_dac',
(v2_base._basic_property, (int, 0, 255), (656, 664))),
('vcm_dac',
(v2_base._basic_property, (int, 0, 255), (664,672))),
('csa_bypass_select',
(v2_base._list_property, ((int,bool), 0, 1, Configuration_v2.num_channels, 1), (672,736))),
('csa_monitor_select',
(v2_base._list_property, ((int,bool), 0, 1, Configuration_v2.num_channels, 1), (736,800))),
('csa_testpulse_enable',
(v2_base._list_property, ((int,bool), 0, 1, Configuration_v2.num_channels, 1), (800,864))),
('csa_testpulse_dac',
(v2_base._basic_property, (int, 0, 255), (864,872))),
('current_monitor_bank0',
(v2_base._list_property, ((int,bool), 0, 1, 4, 1), (872,876))),
('current_monitor_bank1',
(v2_base._list_property, ((int,bool), 0, 1, 4, 1), (880,884))),
('current_monitor_bank2',
(v2_base._list_property, ((int,bool), 0, 1, 4, 1), (888,892))),
('current_monitor_bank3',
(v2_base._list_property, ((int,bool), 0, 1, 4, 1), (896,900))),
('voltage_monitor_bank0',
(v2_base._list_property, ((int,bool), 0, 1, 3, 1), (904,907))),
('voltage_monitor_bank1',
(v2_base._list_property, ((int,bool), 0, 1, 3, 1), (912,915))),
('voltage_monitor_bank2',
(v2_base._list_property, ((int,bool), 0, 1, 3, 1), (920,923))),
('voltage_monitor_bank3',
(v2_base._list_property, ((int,bool), 0, 1, 3, 1), (928,931))),
('voltage_monitor_refgen',
(v2_base._list_property, ((int,bool), 0, 1, 8, 1), (936,944))),
('digital_monitor_enable',
(v2_base._compound_property, (['digital_monitor_enable','digital_monitor_select'], (int,bool), 0, 1), (944,945))),
('digital_monitor_select',
(v2_base._compound_property, (['digital_monitor_enable','digital_monitor_select'], (int,bool), 0, 10), (945,949))),
('digital_monitor_chan',
(v2_base._basic_property, (int, 0, 63), (952,958))),
('slope_control0',
(v2_base._compound_property, (['slope_control0', 'slope_control1'], int, 0, 15), (960,964))),
('slope_control1',
(v2_base._compound_property, (['slope_control0', 'slope_control1'], int, 0, 15), (964,968))),
('slope_control2',
(v2_base._compound_property, (['slope_control2', 'slope_control3'], int, 0, 15), (968,972))),
('slope_control3',
(v2_base._compound_property, (['slope_control2', 'slope_control3'], int, 0, 15), (972,976))),
('chip_id',
(v2_base._basic_property, (int, 0, 255), (976,984))),
('load_config_defaults',
(v2_base._compound_property, (['load_config_defaults', 'enable_fifo_diagnostics', 'clk_ctrl'], (int,bool), 0, 1), (985,986))),
('enable_fifo_diagnostics',
(v2_base._compound_property, (['load_config_defaults', 'enable_fifo_diagnostics', 'clk_ctrl'], (int,bool), 0, 1), (986,987))),
('clk_ctrl',
(v2_base._compound_property, (['load_config_defaults', 'enable_fifo_diagnostics', 'clk_ctrl'], (int), 0, 2), (987,989))),
('enable_miso_upstream',
(v2_base._list_property, ((int,bool), 0, 1, 4, 1), (992,996))),
('enable_miso_downstream',
(v2_base._compound_list_property, (['enable_miso_downstream', 'enable_miso_differential'], (int,bool), 0, 1, 4, 1), (1000,1004))),
('enable_miso_differential',
(v2_base._compound_list_property, (['enable_miso_downstream', 'enable_miso_differential'], (int,bool), 0, 1, 4, 1), (1004,1008))),
('enable_mosi',
(v2_base._list_property, ((int,bool), 0, 1, 4, 1), (1008,1012))),
('test_mode_uart0',
(v2_base._compound_property, (['test_mode_uart0', 'test_mode_uart1', 'test_mode_uart2', 'test_mode_uart3'], int, 0, 4), (1016,1018))),
('test_mode_uart1',
(v2_base._compound_property, (['test_mode_uart0', 'test_mode_uart1', 'test_mode_uart2', 'test_mode_uart3'], int, 0, 4), (1018,1020))),
('test_mode_uart2',
(v2_base._compound_property, (['test_mode_uart0', 'test_mode_uart1', 'test_mode_uart2', 'test_mode_uart3'], int, 0, 4), (1020,1022))),
('test_mode_uart3',
(v2_base._compound_property, (['test_mode_uart0', 'test_mode_uart1', 'test_mode_uart2', 'test_mode_uart3'], int, 0, 4), (1022,1024))),
('enable_cross_trigger',
(v2_base._compound_property, (['enable_cross_trigger', 'enable_periodic_reset', 'enable_rolling_periodic_reset', 'enable_periodic_trigger', 'enable_rolling_periodic_trigger', 'enable_periodic_trigger_veto', 'enable_hit_veto'], (int,bool), 0, 1), (1024,1025))),
('enable_periodic_reset',
(v2_base._compound_property, (['enable_cross_trigger', 'enable_periodic_reset', 'enable_rolling_periodic_reset', 'enable_periodic_trigger', 'enable_rolling_periodic_trigger', 'enable_periodic_trigger_veto', 'enable_hit_veto'], (int,bool), 0, 1), (1025,1026))),
('enable_rolling_periodic_reset',
(v2_base._compound_property, (['enable_cross_trigger', 'enable_periodic_reset', 'enable_rolling_periodic_reset', 'enable_periodic_trigger', 'enable_rolling_periodic_trigger', 'enable_periodic_trigger_veto', 'enable_hit_veto'], (int,bool), 0, 1), (1026,1027))),
('enable_periodic_trigger',
(v2_base._compound_property, (['enable_cross_trigger', 'enable_periodic_reset', 'enable_rolling_periodic_reset', 'enable_periodic_trigger', 'enable_rolling_periodic_trigger', 'enable_periodic_trigger_veto', 'enable_hit_veto'], (int,bool), 0, 1), (1027,1028))),
('enable_rolling_periodic_trigger',
(v2_base._compound_property, (['enable_cross_trigger', 'enable_periodic_reset', 'enable_rolling_periodic_reset', 'enable_periodic_trigger', 'enable_rolling_periodic_trigger', 'enable_periodic_trigger_veto', 'enable_hit_veto'], (int,bool), 0, 1), (1028,1029))),
('enable_periodic_trigger_veto',
(v2_base._compound_property, (['enable_cross_trigger', 'enable_periodic_reset', 'enable_rolling_periodic_reset', 'enable_periodic_trigger', 'enable_rolling_periodic_trigger', 'enable_periodic_trigger_veto', 'enable_hit_veto'], (int,bool), 0, 1), (1029,1030))),
('enable_hit_veto',
(v2_base._compound_property, (['enable_cross_trigger', 'enable_periodic_reset', 'enable_rolling_periodic_reset', 'enable_periodic_trigger', 'enable_rolling_periodic_trigger', 'enable_periodic_trigger_veto', 'enable_hit_veto'], (int,bool), 0, 1), (1030,1031))),
('adc_hold_delay',
(v2_base._basic_property, (int, 0, 15), (1032,1036))),
('adc_burst_length',
(v2_base._basic_property, (int, 0, 255), (1040,1048))),
('channel_mask',
(v2_base._list_property, ((int,bool), 0, 1, Configuration_v2.num_channels, 1), (1048,1112))),
('external_trigger_mask',
(v2_base._list_property, ((int,bool), 0, 1, Configuration_v2.num_channels, 1), (1112,1176))),
('cross_trigger_mask',
(v2_base._list_property, ((int,bool), 0, 1, Configuration_v2.num_channels, 1), (1176,1240))),
('periodic_trigger_mask',
(v2_base._list_property, ((int,bool), 0, 1, Configuration_v2.num_channels, 1), (1240,1304))),
('periodic_reset_cycles',
(v2_base._basic_property, (int, 0, 2**24-1), (1304,1328))),
('periodic_trigger_cycles',
(v2_base._basic_property, (int, 0, 2**32-1), (1328,1360))),
('enable_dynamic_reset',
(v2_base._compound_property, (['enable_dynamic_reset', 'enable_min_delta_adc', 'threshold_polarity', 'reset_length', 'mark_first_packet'], (int,bool), 0, 1), (1360,1361))),
('enable_min_delta_adc',
(v2_base._compound_property, (['enable_dynamic_reset', 'enable_min_delta_adc', 'threshold_polarity', 'reset_length', 'mark_first_packet'], (int,bool), 0, 1), (1361,1362))),
('threshold_polarity',
(v2_base._compound_property, (['enable_dynamic_reset', 'enable_min_delta_adc', 'threshold_polarity', 'reset_length', 'mark_first_packet'], (int,bool), 0, 1), (1362,1363))),
('reset_length',
(v2_base._compound_property, (['enable_dynamic_reset', 'enable_min_delta_adc', 'threshold_polarity', 'reset_length', 'mark_first_packet'], (int), 0, 7), (1363,1366))),
('mark_first_packet',
(v2_base._compound_property, (['enable_dynamic_reset', 'enable_min_delta_adc', 'threshold_polarity', 'reset_length', 'mark_first_packet'], (int,bool), 0, 1), (1366,1367))),
('reset_threshold',
(v2_base._basic_property, (int, 0, 255), (1368,1376))),
('min_delta_adc',
(v2_base._basic_property, (int, 0, 255), (1376,1384))),
('digital_threshold',
(v2_base._list_property, (int, 0, 255, Configuration_v2.num_channels, 8), (1384,1896))),
('lightpix_mode',
(v2_base._compound_property, (['lightpix_mode','hit_threshold'], (int,bool), 0, 1), (1896, 1897))),
('hit_threshold',
Expand Down
5 changes: 5 additions & 0 deletions larpix/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,17 @@ class Controller(object):

_enable_piso_upstream = {
2: 'enable_miso_upstream',
'lightpix-1': 'enable_miso_upstream',
'2b': 'enable_piso_upstream'
}
_enable_posi = {
2: 'enable_mosi',
'lightpix-1': 'enable_mosi',
'2b': 'enable_posi'
}
_enable_piso_downstream = {
2: 'enable_miso_downstream',
'lightpix-1': 'enable_miso_downstream',
'2b': 'enable_piso_downstream'
}

Expand Down Expand Up @@ -906,6 +909,8 @@ def send(self, packets):
'''
timestamp = time.time()
#for packet in packets:
# print(packet)
if self.io:
self.io.send(packets)
else:
Expand Down

0 comments on commit 23d38fa

Please sign in to comment.