mirror of
https://github.com/myhdl/myhdl.git
synced 2024-12-14 07:44:38 +08:00
turn profiling (for tracing) off for compile functions
This commit is contained in:
parent
6a383a8702
commit
d9eac86566
@ -25,12 +25,14 @@ __date__ = "$Date$"
|
||||
|
||||
from __future__ import generators
|
||||
|
||||
import sys
|
||||
import inspect
|
||||
from types import FunctionType
|
||||
import compiler
|
||||
|
||||
from myhdl import Signal
|
||||
from myhdl._util import _isgeneratorfunction
|
||||
from myhdl import _traceSignals
|
||||
|
||||
class Error(Exception):
|
||||
"""always_comb Error"""
|
||||
@ -59,8 +61,8 @@ class EmbeddedFunctionError(Error):
|
||||
|
||||
|
||||
|
||||
|
||||
def always_comb(func):
|
||||
sys.setprofile(None)
|
||||
f = inspect.getouterframes(inspect.currentframe())[1][0]
|
||||
if type(func) is not FunctionType:
|
||||
raise ArgumentError
|
||||
@ -77,6 +79,7 @@ def always_comb(func):
|
||||
if isinstance(v, Signal) and n not in varnames:
|
||||
sigdict[n] = v
|
||||
c = _AlwaysComb(func, sigdict)
|
||||
sys.setprofile(_traceSignals._profileFunc)
|
||||
return c.genfunc()
|
||||
|
||||
|
||||
|
@ -31,30 +31,37 @@ __author__ = "Jan Decaluwe <jan@jandecaluwe.com>"
|
||||
__revision__ = "$Revision$"
|
||||
__date__ = "$Date$"
|
||||
|
||||
import sys
|
||||
import inspect
|
||||
|
||||
from types import GeneratorType
|
||||
|
||||
from myhdl import Cosimulation
|
||||
from myhdl._util import _isgeneratorfunction, _isGenSeq
|
||||
from myhdl import _traceSignals
|
||||
|
||||
|
||||
|
||||
def instances():
|
||||
f = inspect.currentframe()
|
||||
d = inspect.getouterframes(f)[1][0].f_locals
|
||||
l = []
|
||||
for v in d.values():
|
||||
sys.setprofile(None)
|
||||
f = inspect.currentframe()
|
||||
d = inspect.getouterframes(f)[1][0].f_locals
|
||||
l = []
|
||||
for v in d.values():
|
||||
if type(v) in (GeneratorType, Cosimulation):
|
||||
l.append(v)
|
||||
elif _isGenSeq(v):
|
||||
l.append(v)
|
||||
return l
|
||||
sys.setprofile(_traceSignals._profileFunc)
|
||||
return l
|
||||
|
||||
|
||||
|
||||
def processes():
|
||||
f = inspect.currentframe()
|
||||
d = inspect.getouterframes(f)[1][0].f_locals
|
||||
l = []
|
||||
for v in d.values():
|
||||
sys.setprofile(None)
|
||||
f = inspect.currentframe()
|
||||
d = inspect.getouterframes(f)[1][0].f_locals
|
||||
l = []
|
||||
for v in d.values():
|
||||
if _isgeneratorfunction(v):
|
||||
l.append(v()) # call it
|
||||
return l
|
||||
sys.setprofile(_traceSignals._profileFunc)
|
||||
return l
|
||||
|
@ -45,6 +45,7 @@ from myhdl import _simulator, Signal, __version__
|
||||
from myhdl._util import _isGenSeq, _isgeneratorfunction
|
||||
|
||||
_tracing = 0
|
||||
_profileFunc = None
|
||||
|
||||
class Error(Exception):
|
||||
""" traceSignals Error"""
|
||||
@ -164,10 +165,12 @@ def _findInstanceName(framerec):
|
||||
class _HierExtr(object):
|
||||
|
||||
def __init__(self, name, dut, *args, **kwargs):
|
||||
global _profileFunc
|
||||
self.names = [name]
|
||||
self.instances = instances = []
|
||||
self.level = 0
|
||||
sys.setprofile(self.extractor)
|
||||
_profileFunc = self.extractor
|
||||
sys.setprofile(_profileFunc)
|
||||
try:
|
||||
_top = dut(*args, **kwargs)
|
||||
finally:
|
||||
|
Loading…
x
Reference in New Issue
Block a user