1
0
mirror of https://github.com/myhdl/myhdl.git synced 2025-01-24 21:52:56 +08:00

Merge pull request #145 from punkkeks/master

Add 'filename' attribute to traceSignals
This commit is contained in:
jandecaluwe 2016-03-01 20:39:12 +01:00
commit 8c4ae9d186
2 changed files with 13 additions and 1 deletions

View File

@ -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,

View File

@ -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)