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:
commit
0664ab3e0b
@ -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:
|
||||
|
@ -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,6 +124,7 @@ class _TraceSignalsClass(object):
|
||||
vcdpath = os.path.join(directory, filename + ".vcd")
|
||||
|
||||
if path.exists(vcdpath):
|
||||
if self.tracebackup :
|
||||
backup = vcdpath[:-4] + '.' + str(path.getmtime(vcdpath)) + '.vcd'
|
||||
shutil.copyfile(vcdpath, backup)
|
||||
os.remove(vcdpath)
|
||||
|
Loading…
x
Reference in New Issue
Block a user