def __call__(self, dut, *args, **kwargs): global _tracing if _tracing: return dut(*args, **kwargs) # skip else: # clean start sys.setprofile(None) from myhdl.conversion import _toVerilog if _toVerilog._converting: raise TraceSignalsError( "Cannot use traceSignals while converting to Verilog") if not callable(dut): raise TraceSignalsError(_error.ArgType, "got %s" % type(dut)) if _simulator._tracing: raise TraceSignalsError(_error.MultipleTraces) _tracing = 1 try: if self.name is None: name = dut.__name__ else: name = str(self.name) if name is None: raise TraceSignalsError(_error.TopLevelName) if self.directory is None: directory = '' else: directory = self.directory h = _HierExtr(name, dut, *args, **kwargs) vcdpath = os.path.join(directory, name + ".vcd") if path.exists(vcdpath): backup = vcdpath + '.' + str(path.getmtime(vcdpath)) shutil.copyfile(vcdpath, backup) os.remove(vcdpath) vcdfile = open(vcdpath, 'w') _simulator._tracing = 1 _simulator._tf = vcdfile _writeVcdHeader(vcdfile, self.timescale) _writeVcdSigs(vcdfile, h.hierarchy, self.tracelists) finally: _tracing = 0 return h.top
def __call__(self, dut, *args, **kwargs): global _tracing, vcdpath if isinstance(dut, _Block): # now we go bottom-up: so clean up and start over # TODO: consider a warning for the overruled block if _simulator._tracing: _simulator._tracing = 0 _simulator._tf.close() os.remove(vcdpath) else: # deprecated if _tracing: return dut(*args, **kwargs) # skip else: # clean start sys.setprofile(None) from myhdl.conversion import _toVerilog if _toVerilog._converting: raise TraceSignalsError( "Cannot use traceSignals while converting to Verilog") if not isinstance(dut, _Block): if not callable(dut): raise TraceSignalsError(_error.ArgType, "got %s" % type(dut)) if _simulator._tracing: raise TraceSignalsError(_error.MultipleTraces) _tracing = 1 try: if self.name is None: name = dut.__name__ if isinstance(dut, _Block): name = dut.func.__name__ else: name = str(self.name) if name is None: raise TraceSignalsError(_error.TopLevelName) if self.directory is None: directory = '' else: directory = self.directory if isinstance(dut, _Block): h = _getHierarchy(name, dut) else: warnings.warn( "\n traceSignals(): Deprecated usage: See http://dev.myhdl.org/meps/mep-114.html", stacklevel=2) h = _HierExtr(name, dut, *args, **kwargs) if self.filename is None: filename = name else: filename = str(self.filename) 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) vcdfile = open(vcdpath, 'w') _simulator._tracing = 1 _simulator._tf = vcdfile _writeVcdHeader(vcdfile, self.timescale) _writeVcdSigs(vcdfile, h.hierarchy, self.tracelists) finally: _tracing = 0 return h.top