diff --git a/doc/source/manual/reference.rst b/doc/source/manual/reference.rst index 38ce3afa..f3842684 100644 --- a/doc/source/manual/reference.rst +++ b/doc/source/manual/reference.rst @@ -90,6 +90,11 @@ Waveform tracing This attribute is used to set the directory to which VCD files are written. By default, the current working directory is used. + .. attribute:: filename + + This attribute is used to set the filename to which VCD files are written. By + default, the name attribbute is used. + .. attribute:: timescale This attribute is used to set the timescale corresponding to unit steps, diff --git a/myhdl/_traceSignals.py b/myhdl/_traceSignals.py index abd8dd5a..df4cc4ec 100644 --- a/myhdl/_traceSignals.py +++ b/myhdl/_traceSignals.py @@ -50,6 +50,7 @@ class _TraceSignalsClass(object): __slot__ = ("name", "directory", + "filename", "timescale", "tracelists" ) @@ -57,6 +58,7 @@ class _TraceSignalsClass(object): def __init__(self): self.name = None self.directory = None + self.filename = None self.timescale = "1ns" self.tracelists = True @@ -89,8 +91,13 @@ class _TraceSignalsClass(object): else: directory = self.directory + if self.filename is None: + filename = name + else: + filename = str(self.filename) + h = _HierExtr(name, dut, *args, **kwargs) - vcdpath = os.path.join(directory, name + ".vcd") + vcdpath = os.path.join(directory, filename + ".vcd") if path.exists(vcdpath): backup = vcdpath + '.' + str(path.getmtime(vcdpath)) shutil.copyfile(vcdpath, backup)