Skip to content

Commit

Permalink
Merge pull request #14 from SiLab-Bonn/fifo_full_warning
Browse files Browse the repository at this point in the history
Fixed a bug in the FIFO is full warning log
  • Loading branch information
rpartzsch authored Jan 16, 2025
2 parents 960a401 + 0090b10 commit 5ef6e05
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
6 changes: 5 additions & 1 deletion aidatlu/main/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ def conf_dut(self) -> None:
self.tlu.dut_logic.set_dut_mask_mode(
dut_mode[0] | dut_mode[1] | dut_mode[2] | dut_mode[3]
)

self.log.debug("Set DUT mask: %s" % (dut[0] | dut[1] | dut[2] | dut[3]))
self.log.debug(
"Set DUT mask mode: %s"
% (dut_mode[0] | dut_mode[1] | dut_mode[2] | dut_mode[3])
)
# Special configs
self.tlu.dut_logic.set_dut_mask_mode_modifier(0)
self.tlu.dut_logic.set_dut_ignore_busy(0)
Expand Down
28 changes: 13 additions & 15 deletions aidatlu/main/tlu.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def set_enable_record_data(self, value: int) -> None:
self.i2c.write_register("Event_Formatter.Enable_Record_Data", value)

def get_event_fifo_csr(self) -> int:
"""Reads value from 'EventFifoCSR'
"""Reads value from 'EventFifoCSR', corresponds to status flags of the FIFO.
Returns:
int: number of events
Expand All @@ -176,6 +176,8 @@ def get_event_fifo_csr(self) -> int:

def get_event_fifo_fill_level(self) -> int:
"""Reads value from 'EventFifoFillLevel'
Returns the number of words written in
the FIFO. The lowest 14-bits are the actual data.
Returns:
int: buffer level of the fifi
Expand Down Expand Up @@ -207,8 +209,6 @@ def pull_fifo_event(self) -> list:
"""
event_numb = self.get_event_fifo_fill_level()
if event_numb:
if event_numb * 6 == 0xFEA:
self.log.warning("FIFO is full")
fifo_content = self.i2c_hw.getNode("eventBuffer.EventFifoData").readBlock(
event_numb
)
Expand Down Expand Up @@ -325,7 +325,7 @@ def log_sent_status(self, time: int) -> None:
self.log.debug("FIFO level 2: %s" % self.get_event_fifo_csr())
self.log.debug(
"fifo csr: %s fifo fill level: %s"
% (self.get_event_fifo_csr(), self.get_event_fifo_csr())
% (self.get_event_fifo_fill_level(), self.get_event_fifo_csr())
)
self.log.debug(
"post: %s pre: %s"
Expand All @@ -335,6 +335,14 @@ def log_sent_status(self, time: int) -> None:
)
)
self.log.debug("time stamp: %s" % (self.get_timestamp()))
if (
self.run_time < 10
): # Logs trigger configuration when logging level is debug for the first 10s
current_event = self.pull_fifo_event()
if np.size(current_event) > 1:
self.log_trigger_inputs(current_event[0:6])
if self.get_event_fifo_csr() == 0x10:
self.log.warning("FIFO is full")

def log_trigger_inputs(self, event_vector: list) -> None:
"""Logs which inputs triggered the event corresponding to the event vector.
Expand All @@ -349,8 +357,7 @@ def log_trigger_inputs(self, event_vector: list) -> None:
input_4 = (w0 >> 19) & 0x1
input_5 = (w0 >> 20) & 0x1
input_6 = (w0 >> 21) & 0x1
self.log.info("Event triggered:")
self.log.info(
self.log.debug(
"Input 1: %s, Input 2: %s, Input 3: %s, Input 4: %s, Input 5: %s, Input 6: %s"
% (input_1, input_2, input_3, input_4, input_5, input_6)
)
Expand All @@ -373,7 +380,6 @@ def run(self) -> None:
self.last_time = 0
self.last_triggers_freq = self.trigger_logic.get_post_veto_trigger()
self.last_particle_freq = self.trigger_logic.get_pre_veto_trigger()
first_event = True
self.stop_condition = False
# prepare data handling and zmq connection
save_data = self.config_parser.get_data_handling()
Expand Down Expand Up @@ -403,7 +409,6 @@ def run(self) -> None:
t.start()
while run_active:
try:
time.sleep(0.000001)
current_event = self.pull_fifo_event()
try:
if save_data and np.size(current_event) > 1:
Expand All @@ -419,13 +424,6 @@ def run(self) -> None:
# If this happens: poss. Hitrate to high for FIFO and or Data handling.
self.log.warning("Incomplete Event handling...")

# This loop sents which inputs produced the trigger signal for the first event.
if (
np.size(current_event) > 1
) and first_event: # TODO only first event?
self.log_trigger_inputs(current_event[0:6])
first_event = False

except KeyboardInterrupt:
run_active = False
t.do_run = False
Expand Down

0 comments on commit 5ef6e05

Please sign in to comment.