forked from M-Labs/artiq
1
0
Fork 0

coredevice/analyzer: add rtio_slack channel

This commit is contained in:
Sebastien Bourdeauducq 2015-12-25 00:40:47 +08:00
parent 7475b3813e
commit cd8eccfd46
1 changed files with 15 additions and 9 deletions

View File

@ -245,17 +245,17 @@ class DDSHandler:
self._decode_ad9914_write(message) self._decode_ad9914_write(message)
def get_timescale(devices): def get_ref_period(devices):
timescale = None ref_period = None
for desc in devices.values(): for desc in devices.values():
if isinstance(desc, dict) and desc["type"] == "local": if isinstance(desc, dict) and desc["type"] == "local":
if (desc["module"] == "artiq.coredevice.core" if (desc["module"] == "artiq.coredevice.core"
and desc["class"] == "Core"): and desc["class"] == "Core"):
if timescale is None: if ref_period is None:
timescale = desc["arguments"]["ref_period"]*1e9 ref_period = desc["arguments"]["ref_period"]
else: else:
return None # more than one core device found return None # more than one core device found
return timescale return ref_period
def create_channel_handlers(vcd_manager, devices, log_channel, def create_channel_handlers(vcd_manager, devices, log_channel,
@ -291,15 +291,17 @@ def get_message_time(message):
def decoded_dump_to_vcd(fileobj, devices, dump): def decoded_dump_to_vcd(fileobj, devices, dump):
vcd_manager = VCDManager(fileobj) vcd_manager = VCDManager(fileobj)
timescale = get_timescale(devices) ref_period = get_ref_period(devices)
if timescale is not None: if ref_period is not None:
vcd_manager.set_timescale_ns(timescale) vcd_manager.set_timescale_ns(ref_period*1e9)
else: else:
logger.warning("unable to determine VCD timescale") logger.warning("unable to determine core device ref_period")
ref_period = 1e-9 # guess
channel_handlers = create_channel_handlers( channel_handlers = create_channel_handlers(
vcd_manager, devices, vcd_manager, devices,
dump.log_channel, dump.dds_channel, dump.dds_onehot_sel) dump.log_channel, dump.dds_channel, dump.dds_onehot_sel)
slack = vcd_manager.get_channel("rtio_slack", 64)
vcd_manager.set_time(0) vcd_manager.set_time(0)
messages = sorted(dump.messages, key=get_message_time) messages = sorted(dump.messages, key=get_message_time)
@ -310,3 +312,7 @@ def decoded_dump_to_vcd(fileobj, devices, dump):
vcd_manager.set_time( vcd_manager.set_time(
get_message_time(message) - start_time) get_message_time(message) - start_time)
channel_handlers[message.channel].process_message(message) channel_handlers[message.channel].process_message(message)
if (hasattr(message, "rtio_counter")
and hasattr(message, "timestamp")):
slack.set_value_double(
(message.timestamp - message.rtio_counter)*ref_period)