Skip to content

Commit

Permalink
Merge pull request #145 from punkkeks/master
Browse files Browse the repository at this point in the history
Add 'filename' attribute to traceSignals
  • Loading branch information
jandecaluwe committed Mar 1, 2016
2 parents bb2882a + 04b9935 commit 8c4ae9d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions doc/source/manual/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion myhdl/_traceSignals.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ class _TraceSignalsClass(object):

__slot__ = ("name",
"directory",
"filename",
"timescale",
"tracelists"
)

def __init__(self):
self.name = None
self.directory = None
self.filename = None
self.timescale = "1ns"
self.tracelists = True

Expand Down Expand Up @@ -89,8 +91,13 @@ def __call__(self, dut, *args, **kwargs):
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)
Expand Down

0 comments on commit 8c4ae9d

Please sign in to comment.