Skip to content

Commit aaa4ed5

Browse files
committed
Merge branch 'rfsocs/mts-updates' into rfsocs/rfdc
2 parents 979a53a + 65d1a8e commit aaa4ed5

File tree

1 file changed

+56
-16
lines changed

1 file changed

+56
-16
lines changed

src/rfdc.py

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ def set_coarse_delay(self, ntile, nblk, converter_type, coarse_delay, event_sour
837837
>>>> rfdc.set_coarse_delay(0, 0, rfdc.ADC_TILE, 12, rfdc.EVNT_SRC_TILE)
838838
{'CoarseDelay': 12, 'EventSource': 2}
839839
# trigger update event to apply
840-
rfdc.update_event(0, 0, rfdc.EVENT_COARSE_DELAY)
840+
rfdc.update_event(0, 0, rfdc.ADC_TILE, rfdc.EVENT_COARSE_DLY)
841841
"""
842842
t = self.parent.transport
843843

@@ -1841,14 +1841,15 @@ def set_imr_mode(self, ntile, nblk, imr_mode):
18411841
return int(imr_mode)
18421842

18431843

1844-
def run_mts(self, tile_mask=15, target_latency=None):
1844+
def run_mts(self, converter_type, tile_mask=15, target_latency=-1):
18451845
"""
1846-
Execute multi-tile synchronization (MTS) to synchronize ADC tiles set by "tile_mask".
1847-
Optionally request to synch with latency specified by "target_latency".
1846+
Execute multi-tile synchronization (MTS) to synchronize ADC or DAC tiles set by "tile_mask".
1847+
Optionally request to a target latency specified by "target_latency".
18481848
1849-
:param mask: Bitmask for selecting which tiles to sync, defaults to all tiles 0x1111 = 15. LSB is ADC Tile 0.
1849+
:param converter_type: Represents the target converter type, "adc" or "dac"
1850+
:type converter_type: str
1851+
:param mask: Bitmask for selecting which tiles to sync, defaults to all tiles 0x1111 = 15. LSB is ADC/DAC Tile 0.
18501852
:type mask: int
1851-
18521853
:param target_latency: Requested target latency
18531854
:type target_latency: int
18541855
@@ -1858,31 +1859,70 @@ def run_mts(self, tile_mask=15, target_latency=None):
18581859
:raises KatcpRequestFail: If KatcpTransport encounters an error
18591860
"""
18601861

1861-
if target_latency is not None:
1862-
print("WARN: 'target_latency' not yet implemented, this argument is ignored")
1863-
18641862
t = self.parent.transport
1865-
self.mts_report = []
1866-
args = (tile_mask,)
1863+
args = ("adc" if converter_type == self.ADC_TILE else "dac",tile_mask,target_latency)
18671864
reply, informs = t.katcprequest(name='rfdc-run-mts', request_timeout=t._timeout, request_args=args)
1868-
for i in informs:
1869-
self.mts_report.append(i)
18701865

18711866
return True
18721867

1868+
def get_mts_latency(self, converter_type, ntile):
1869+
"""
1870+
Get the adc or dac mts latency for enabled tile "ntile" and block index "nblk". If a tile/block pair is
1871+
disabled or, no mts information is available, an empty dictionary is returned and nothing is done.
1872+
1873+
:param converter_type: Represents the target converter type, "adc" or "dac"
1874+
:type converter_type: str
1875+
:param ntile: Tile index of target adc tile to get mts latency, in the range (0-3)
1876+
:type ntile: int
1877+
1878+
:return: Dictionary with mts latency, empty dictionary if tile/block is disabled
1879+
:rtype: dict[str, int]
1880+
1881+
:raises KatcpRequestFail: If KatcpTransport encounters an error
1882+
1883+
Examples
1884+
----------
1885+
# get the mts latency for ADC 00
1886+
>>>> ntile=0
1887+
>>>> rfdc.get_mts_latency(rfdc.ADC_TILE, ntile)
1888+
{'Latency': 160, 'DelayOffset': 2, 'DecFactor': 4}
1889+
"""
1890+
t = self.parent.transport
1891+
1892+
args = ("adc" if converter_type == self.ADC_TILE else "dac",ntile)
1893+
reply, informs = t.katcprequest(name='rfdc-mts-tile-latency', request_timeout=t._timeout, request_args=args)
1894+
1895+
mts_latency = {}
1896+
info = informs[0].arguments[0].decode().split(', ')
1897+
if len(info) == 1: # (disabled) response
1898+
return mts_latency
1899+
1900+
for stat in info:
1901+
k,v = stat.split(' ')
1902+
mts_latency[k] = v
1903+
1904+
return mts_latency
1905+
18731906

1874-
def get_mts_report(self):
1907+
def mts_debug_info(self, converter_type):
18751908
"""
18761909
Prints a detailed report of the most recent multi-tile synchronization run. Including information
18771910
such as latency on each tile, delay maker, delay bit.
18781911
1912+
:param converter_type: Represents the target converter type, "adc" or "dac"
1913+
:type converter_type: str
1914+
18791915
:return: `True` if completes successfuly, `False` otherwise
18801916
:rtype: bool
18811917
18821918
:raises KatcpRequestFail: If KatcpTransport encounters an error
18831919
"""
1884-
for m in self.mts_report:
1885-
print(m)
1920+
t = self.parent.transport
1921+
args = ("adc" if converter_type == self.ADC_TILE else "dac",)
1922+
reply, informs = t.katcprequest(name='rfdc-mts-debug-info', request_timeout=t._timeout, request_args=args)
1923+
1924+
for i in informs:
1925+
print(i)
18861926

18871927
return True
18881928

0 commit comments

Comments
 (0)