mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-26 03:38:25 +08:00
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,11 +501,13 @@ def get_message_time(message):
|
|||||||
return getattr(message, "timestamp", message.rtio_counter)
|
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)
|
vcd_manager = VCDManager(fileobj)
|
||||||
ref_period = get_ref_period(devices)
|
ref_period = get_ref_period(devices)
|
||||||
|
|
||||||
if ref_period is not None:
|
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:
|
else:
|
||||||
logger.warning("unable to determine core device ref_period")
|
logger.warning("unable to determine core device ref_period")
|
||||||
ref_period = 1e-9 # guess
|
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)
|
vcd_log_channels = get_vcd_log_channels(dump.log_channel, messages)
|
||||||
channel_handlers[dump.log_channel] = LogHandler(
|
channel_handlers[dump.log_channel] = LogHandler(
|
||||||
vcd_manager, vcd_log_channels)
|
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)
|
slack = vcd_manager.get_channel("rtio_slack", 64)
|
||||||
|
|
||||||
vcd_manager.set_time(0)
|
vcd_manager.set_time(0)
|
||||||
@ -536,11 +544,18 @@ def decoded_dump_to_vcd(fileobj, devices, dump):
|
|||||||
if start_time:
|
if start_time:
|
||||||
break
|
break
|
||||||
|
|
||||||
for message in messages:
|
t0 = 0
|
||||||
|
for i, message in enumerate(messages):
|
||||||
if message.channel in channel_handlers:
|
if message.channel in channel_handlers:
|
||||||
t = get_message_time(message) - start_time
|
t = get_message_time(message) - start_time
|
||||||
if t >= 0:
|
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)
|
channel_handlers[message.channel].process_message(message)
|
||||||
if isinstance(message, OutputMessage):
|
if isinstance(message, OutputMessage):
|
||||||
slack.set_value_double(
|
slack.set_value_double(
|
||||||
|
@ -16,16 +16,22 @@ def get_argparser():
|
|||||||
|
|
||||||
verbosity_args(parser)
|
verbosity_args(parser)
|
||||||
parser.add_argument("--device-db", default="device_db.py",
|
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,
|
parser.add_argument("-r", "--read-dump", type=str, default=None,
|
||||||
help="read raw dump file instead of accessing device")
|
help="read raw dump file instead of accessing device")
|
||||||
parser.add_argument("-p", "--print-decoded", default=False, action="store_true",
|
parser.add_argument("-p", "--print-decoded", default=False,
|
||||||
help="print raw decoded messages")
|
action="store_true", help="print raw decoded messages")
|
||||||
parser.add_argument("-w", "--write-vcd", type=str, default=None,
|
parser.add_argument("-w", "--write-vcd", type=str, default=None,
|
||||||
help="format and write contents to VCD file")
|
help="format and write contents to VCD file")
|
||||||
parser.add_argument("-d", "--write-dump", type=str, default=None,
|
parser.add_argument("-d", "--write-dump", type=str, default=None,
|
||||||
help="write raw dump file")
|
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
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -54,7 +60,8 @@ def main():
|
|||||||
if args.write_vcd:
|
if args.write_vcd:
|
||||||
with open(args.write_vcd, "w") as f:
|
with open(args.write_vcd, "w") as f:
|
||||||
decoded_dump_to_vcd(f, device_mgr.get_device_db(),
|
decoded_dump_to_vcd(f, device_mgr.get_device_db(),
|
||||||
decoded_dump)
|
decoded_dump,
|
||||||
|
uniform_interval=args.vcd_uniform_interval)
|
||||||
if args.write_dump:
|
if args.write_dump:
|
||||||
with open(args.write_dump, "wb") as f:
|
with open(args.write_dump, "wb") as f:
|
||||||
f.write(dump)
|
f.write(dump)
|
||||||
|
Loading…
Reference in New Issue
Block a user