Commit 3151ff60 authored by Federico Vaga's avatar Federico Vaga

Merge branch '22-fmc-tdc-tstamp-displays-timestamps-with-ps-part-more-than-1s' into 'master'

Resolve "fmc-tdc-tstamp displays timestamps with ps part more than 1s"

Closes #22

See merge request be-cem-edl/fec/hardware-modules/fmc-tdc-1ns-5cha!12
parents 37f54785 88927d39
...@@ -13,26 +13,28 @@ from PyFmcTdc import FmcTdc, FmcTdcTime ...@@ -13,26 +13,28 @@ from PyFmcTdc import FmcTdc, FmcTdcTime
TDC_FD_CABLING = [1, 2, 3, 4, 4] TDC_FD_CABLING = [1, 2, 3, 4, 4]
fmctdc_acq_100ns_spec = [(200, 65000), fmctdc_acq_100ns_spec = [(200, 65000), # 5 MHz
(250, 65000), (250, 65000), # 4 MHz
(500, 65000), (500, 65000), # 2 MHz
(1000, 65000), (1000, 65000), # 1 Mhz
(1700, 65000), (1700, 65000), # 588 kHz
# Let's keep the test within 100ms duration # Let's keep the test within 100ms duration
# vvvvvvvvvvv # vvvvvvvvvvv
(1875, 60000), (1875, 60000), # 533 khz
(2500, 40000), (2500, 40000), # 400 kHz
(5000, 20000), (5000, 20000), # 200 khz
(10000, 10000), (10000, 10000), # 100 kHz
(12500, 8000), (12500, 8000), # 80 kHz
(100000, 1000), (20000, 5000), # 50 kHz
(1000000, 100), (100000, 1000), # 10 kHz
(10000000, 10)] (1000000, 100), # 1 kHz
(10000000, 10)] # 100 Hz
fmctdc_acq_100ns_svec = [(12500, 8000), fmctdc_acq_100ns_svec = [(13333, 8000), # 75 kHz
(100000, 1000), (20000, 5000), # 50 kHz
(1000000, 100), (100000, 1000), # 10 kHz
(10000000, 10)] (1000000, 100), # 1 kHz
(10000000, 10)] # 100 Hz
fmctdc_acq_100ns = fmctdc_acq_100ns_svec if pytest.transfer_mode == "fifo" else fmctdc_acq_100ns_spec fmctdc_acq_100ns = fmctdc_acq_100ns_svec if pytest.transfer_mode == "fifo" else fmctdc_acq_100ns_spec
...@@ -73,22 +75,29 @@ class TestFmctdcAcquisition(object): ...@@ -73,22 +75,29 @@ class TestFmctdcAcquisition(object):
stats_after = fmctdc_chan.stats stats_after = fmctdc_chan.stats
assert stats_before[0] + count == stats_after[0] assert stats_before[0] + count == stats_after[0]
@pytest.mark.parametrize("period_ns,count", fmctdc_acq_100ns) @pytest.mark.skipif(pytest.carrier != "spec" or \
def test_acq_chan_read_count(self, fmctdc_chan, fmcfd, period_ns, count): pytest.transfer_mode != "dma",
"""Check that unders a controlled acquisiton the number of read reason="Only SPEC with DMA can perform this test")
timestamps is correct. Test 100 milli-second acquisition at different @pytest.mark.parametrize("period_ns", [200, 250, 500, 1000])
frequencies""" @pytest.mark.repeat(100)
fmctdc_chan.buffer_len = max(count + 1, 64) def test_acq_chan_high_speed(self, fmctdc_chan, fmcfd, period_ns):
"""Check that at hign speed we get all samples. Do it many times.
We could use the infinite feature, but it will be then hard to see
if we missed a timestamp or not. this is a fine-delay limitation"""
count = 0xFFFF
stats_before = fmctdc_chan.stats
fmctdc_chan.buffer_len = count + 1
fmcfd.generate_pulse(TDC_FD_CABLING[fmctdc_chan.idx], 1000, fmcfd.generate_pulse(TDC_FD_CABLING[fmctdc_chan.idx], 1000,
period_ns, count, True) period_ns, count, True)
ts = fmctdc_chan.read(count, os.O_NONBLOCK) stats_after = fmctdc_chan.stats
assert len(ts) == count assert stats_before[0] + count == stats_after[0]
@pytest.mark.parametrize("period_ns,count", fmctdc_acq_100ns) @pytest.mark.parametrize("period_ns,count", fmctdc_acq_100ns)
def test_acq_timestamp_seq_num(self, fmctdc_chan, fmcfd, period_ns, count): def test_acq_timestamp_valid(self, fmctdc_chan, fmcfd, period_ns, count):
"""Check that unders a controlled acquisiton the sequence """Check that under a controlled acquisiton the timestamps and their
number of each timestamps increase by 1. Test 100 milli-second metadata is valid. Coars and franc within range, and the sequence
acquisition at different frequencies""" number increases by 1 Test 100 milli-second acquisition at different
frequencies"""
fmctdc_chan.buffer_len = max(count + 1, 64) fmctdc_chan.buffer_len = max(count + 1, 64)
prev = None prev = None
fmcfd.generate_pulse(TDC_FD_CABLING[fmctdc_chan.idx], 1000, fmcfd.generate_pulse(TDC_FD_CABLING[fmctdc_chan.idx], 1000,
...@@ -96,6 +105,8 @@ class TestFmctdcAcquisition(object): ...@@ -96,6 +105,8 @@ class TestFmctdcAcquisition(object):
ts = fmctdc_chan.read(count, os.O_NONBLOCK) ts = fmctdc_chan.read(count, os.O_NONBLOCK)
assert len(ts) == count assert len(ts) == count
for i in range(len(ts)): for i in range(len(ts)):
assert 0 <= ts[i].coarse < 125000000
assert 0 <= ts[i].frac < 4096
if prev == None: if prev == None:
prev = ts[i] prev = ts[i]
continue continue
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment