From 101671fbbf20f06b8143bbf3baf09908e0098e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 10 Jan 2019 19:32:58 +0100 Subject: [PATCH] core_analyzer: support uniform VCD time intervals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit close #1236 Signed-off-by: Robert Jördens --- artiq/coredevice/comm_analyzer.py | 23 +++++++++++++++++++---- artiq/frontend/artiq_coreanalyzer.py | 15 +++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/artiq/coredevice/comm_analyzer.py b/artiq/coredevice/comm_analyzer.py index c6a2a3da4..be5902724 100644 --- a/artiq/coredevice/comm_analyzer.py +++ b/artiq/coredevice/comm_analyzer.py @@ -501,11 +501,13 @@ def get_message_time(message): return getattr(message, "timestamp", message.rtio_counter) -def decoded_dump_to_vcd(fileobj, devices, dump): +def decoded_dump_to_vcd(fileobj, devices, dump, uniform_interval=False): vcd_manager = VCDManager(fileobj) ref_period = get_ref_period(devices) + if ref_period is not None: - vcd_manager.set_timescale_ps(ref_period*1e12) + if not uniform_interval: + vcd_manager.set_timescale_ps(ref_period*1e12) else: logger.warning("unable to determine core device ref_period") ref_period = 1e-9 # guess @@ -527,6 +529,12 @@ def decoded_dump_to_vcd(fileobj, devices, dump): vcd_log_channels = get_vcd_log_channels(dump.log_channel, messages) channel_handlers[dump.log_channel] = LogHandler( vcd_manager, vcd_log_channels) + if uniform_interval: + # RTIO event timestamp in machine units + timestamp = vcd_manager.get_channel("timestamp", 64) + # RTIO time interval between this and the next timed event + # in SI seconds + interval = vcd_manager.get_channel("interval", 64) slack = vcd_manager.get_channel("rtio_slack", 64) vcd_manager.set_time(0) @@ -536,11 +544,18 @@ def decoded_dump_to_vcd(fileobj, devices, dump): if start_time: break - for message in messages: + t0 = 0 + for i, message in enumerate(messages): if message.channel in channel_handlers: t = get_message_time(message) - start_time if t >= 0: - vcd_manager.set_time(t) + if uniform_interval: + interval.set_value_double((t - t0)*ref_period) + vcd_manager.set_time(i) + timestamp.set_value("{:064b}".format(t)) + t0 = t + else: + vcd_manager.set_time(t) channel_handlers[message.channel].process_message(message) if isinstance(message, OutputMessage): slack.set_value_double( diff --git a/artiq/frontend/artiq_coreanalyzer.py b/artiq/frontend/artiq_coreanalyzer.py index 0a5fad21b..96ea83ee6 100755 --- a/artiq/frontend/artiq_coreanalyzer.py +++ b/artiq/frontend/artiq_coreanalyzer.py @@ -16,16 +16,22 @@ def get_argparser(): verbosity_args(parser) parser.add_argument("--device-db", default="device_db.py", - help="device database file (default: '%(default)s')") + help="device database file (default: '%(default)s')") parser.add_argument("-r", "--read-dump", type=str, default=None, help="read raw dump file instead of accessing device") - parser.add_argument("-p", "--print-decoded", default=False, action="store_true", - help="print raw decoded messages") + parser.add_argument("-p", "--print-decoded", default=False, + action="store_true", help="print raw decoded messages") parser.add_argument("-w", "--write-vcd", type=str, default=None, help="format and write contents to VCD file") parser.add_argument("-d", "--write-dump", type=str, default=None, help="write raw dump file") + + parser.add_argument("-u", "--vcd-uniform-interval", action="store_true", + help="emit uniform time intervals between timed VCD " + "events and show RTIO event interval (in SI " + "seconds) and timestamp (in machine units) as " + "separate VCD channels") return parser @@ -54,7 +60,8 @@ def main(): if args.write_vcd: with open(args.write_vcd, "w") as f: decoded_dump_to_vcd(f, device_mgr.get_device_db(), - decoded_dump) + decoded_dump, + uniform_interval=args.vcd_uniform_interval) if args.write_dump: with open(args.write_dump, "wb") as f: f.write(dump)