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

Merge pull request #252 from NicoPy/patch-3

Adds full simulation configuration
This commit is contained in:
jandecaluwe 2018-03-15 23:11:11 +01:00 committed by GitHub
commit 0664ab3e0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -341,10 +341,12 @@ class _Block(object):
setattr(converter, k, v)
return converter(self)
def config_sim(self, trace=False, timescale='1ns'):
def config_sim(self, trace=False, **kwargs) :
self._config_sim['trace'] = trace
if trace:
myhdl.traceSignals(self, timescale=timescale)
for k, v in kwargs.items() :
setattr(myhdl.traceSignals, k, v)
myhdl.traceSignals(self)
def run_sim(self, duration=None, quiet=0):
if self.sim is None:

View File

@ -56,7 +56,8 @@ class _TraceSignalsClass(object):
"directory",
"filename",
"timescale",
"tracelists"
"tracelists",
"tracebackup"
)
def __init__(self):
@ -65,11 +66,10 @@ class _TraceSignalsClass(object):
self.filename = None
self.timescale = "1ns"
self.tracelists = True
self.tracebackup = True
def __call__(self, dut, *args, **kwargs):
global _tracing, vcdpath
if 'timescale' in kwargs:
self.timescale = kwargs['timescale']
if isinstance(dut, _Block):
# now we go bottom-up: so clean up and start over
# TODO: consider a warning for the overruled block
@ -124,8 +124,9 @@ class _TraceSignalsClass(object):
vcdpath = os.path.join(directory, filename + ".vcd")
if path.exists(vcdpath):
backup = vcdpath[:-4] + '.' + str(path.getmtime(vcdpath)) + '.vcd'
shutil.copyfile(vcdpath, backup)
if self.tracebackup :
backup = vcdpath[:-4] + '.' + str(path.getmtime(vcdpath)) + '.vcd'
shutil.copyfile(vcdpath, backup)
os.remove(vcdpath)
vcdfile = open(vcdpath, 'w')
_simulator._tracing = 1