From: Cesar Strauss Date: Sat, 24 Oct 2020 14:44:11 +0000 (-0300) Subject: Calculate the zoom level from the clock period X-Git-Tag: 24jan2021_ls180~9 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e9bdb0a27bf28b29b3cce061db397dd2594c62a3;p=nmutil.git Calculate the zoom level from the clock period --- diff --git a/src/nmutil/gtkw.py b/src/nmutil/gtkw.py index 5327bc0..ff1b237 100644 --- a/src/nmutil/gtkw.py +++ b/src/nmutil/gtkw.py @@ -1,9 +1,10 @@ from vcd.gtkw import GTKWSave, GTKWColor +from math import log2 def write_gtkw(gtkw_name, vcd_name, gtkw_dom, gtkw_style=None, module=None, loc=None, color=None, base=None, - zoom=-22.9, marker=-1): + zoom=None, marker=-1, clk_period=1e-6): """ Write a GTKWave document according to the supplied style and DOM. :param gtkw_name: name of the generated GTKWave document @@ -16,6 +17,8 @@ def write_gtkw(gtkw_name, vcd_name, gtkw_dom, gtkw_style=None, :param loc: source code location to include as a comment :param zoom: initial zoom level, in GTKWave format :param marker: initial location of a marker + :param clk_period: clock period in seconds, helping + to set a reasonable initial zoom level **gtkw_style format** @@ -67,6 +70,8 @@ def write_gtkw(gtkw_name, vcd_name, gtkw_dom, gtkw_style=None, gtkw.dumpfile(vcd_name) # set a reasonable zoom level # also, move the marker to an interesting place + if zoom is None: + zoom = -42.8 - log2(clk_period) gtkw.zoom_markers(zoom, marker) # create an empty style, if needed