mirror of
https://github.com/myhdl/myhdl.git
synced 2025-01-24 21:52:56 +08:00
refactored
This commit is contained in:
parent
104cfc78ff
commit
a4063744b0
@ -20,11 +20,10 @@
|
|||||||
""" myhdl misc objects.
|
""" myhdl misc objects.
|
||||||
|
|
||||||
This module provides the following myhdl objects:
|
This module provides the following myhdl objects:
|
||||||
downrange -- function that returns a downward range
|
instances -- function that returns instances in a generator function
|
||||||
Error -- myhdl Error exception
|
these are all generators in the local namespace
|
||||||
bin -- returns a binary string representation.
|
processes -- function that returns processes in a generator function
|
||||||
The optional width specifies the desired string
|
these are generators obtained by calling local generator functions
|
||||||
width: padding of the sign-bit is used.
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -32,11 +31,11 @@ __author__ = "Jan Decaluwe <jan@jandecaluwe.com>"
|
|||||||
__version__ = "$Revision$"
|
__version__ = "$Revision$"
|
||||||
__date__ = "$Date$"
|
__date__ = "$Date$"
|
||||||
|
|
||||||
import re
|
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
from types import GeneratorType, FunctionType, ListType, TupleType
|
from types import GeneratorType, ListType, TupleType
|
||||||
from myhdl import Cosimulation
|
from myhdl import Cosimulation
|
||||||
|
from util import _isgeneratorfunction
|
||||||
|
|
||||||
def _isGenSeq(seq):
|
def _isGenSeq(seq):
|
||||||
if not isinstance(seq, (ListType, TupleType)):
|
if not isinstance(seq, (ListType, TupleType)):
|
||||||
@ -62,14 +61,6 @@ def instances():
|
|||||||
return l
|
return l
|
||||||
|
|
||||||
|
|
||||||
def _isgeneratorfunction(obj):
|
|
||||||
if type(obj) is FunctionType:
|
|
||||||
s = inspect.getsource(obj)
|
|
||||||
if re.search(r"\byield\b", s):
|
|
||||||
return 1
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
def processes():
|
def processes():
|
||||||
f = inspect.currentframe()
|
f = inspect.currentframe()
|
||||||
d = inspect.getouterframes(f)[1][0].f_locals
|
d = inspect.getouterframes(f)[1][0].f_locals
|
||||||
|
@ -34,6 +34,9 @@ __date__ = "$Date$"
|
|||||||
|
|
||||||
import exceptions
|
import exceptions
|
||||||
import sys
|
import sys
|
||||||
|
import inspect
|
||||||
|
import re
|
||||||
|
from types import FunctionType
|
||||||
|
|
||||||
|
|
||||||
def downrange(start, stop=0):
|
def downrange(start, stop=0):
|
||||||
@ -80,4 +83,9 @@ def printExcInfo():
|
|||||||
msg += ": %s" % value
|
msg += ": %s" % value
|
||||||
print msg
|
print msg
|
||||||
|
|
||||||
|
def _isgeneratorfunction(obj):
|
||||||
|
if type(obj) is FunctionType:
|
||||||
|
s = inspect.getsource(obj)
|
||||||
|
if re.search(r"\byield\b", s):
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user