forked from M-Labs/artiq
core_analyzer: support uniform VCD time intervals
close #1236 Signed-off-by: Robert Jördens <rj@quartiq.de>
This commit is contained in:
parent
58e872e7b5
commit
101671fbbf
|
@ -501,10 +501,12 @@ 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:
|
||||
if not uniform_interval:
|
||||
vcd_manager.set_timescale_ps(ref_period*1e12)
|
||||
else:
|
||||
logger.warning("unable to determine core device ref_period")
|
||||
|
@ -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,10 +544,17 @@ 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:
|
||||
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):
|
||||
|
|
|
@ -20,12 +20,18 @@ def get_argparser():
|
|||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue