mirror of
https://github.com/myhdl/myhdl.git
synced 2025-01-24 21:52:56 +08:00
Merge branch 'jck-refactoring'
This commit is contained in:
commit
4b70a481e6
@ -3,6 +3,7 @@ python:
|
|||||||
- "2.6"
|
- "2.6"
|
||||||
- "2.7"
|
- "2.7"
|
||||||
- "pypy"
|
- "pypy"
|
||||||
|
- "3.4"
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- if [ $CI_TARGET == "icarus" ]; then
|
- if [ $CI_TARGET == "icarus" ]; then
|
||||||
@ -22,6 +23,10 @@ env:
|
|||||||
- CI_TARGET=icarus
|
- CI_TARGET=icarus
|
||||||
- CI_TARGET=ghdl
|
- CI_TARGET=ghdl
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
allow_failures:
|
||||||
|
- python: "3.4"
|
||||||
|
|
||||||
script: ./ci.sh
|
script: ./ci.sh
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
""" Module that provides the Cosimulation class """
|
""" Module that provides the Cosimulation class """
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@ -77,7 +78,7 @@ class Cosimulation(object):
|
|||||||
arglist[0] = os.path.basename(p)
|
arglist[0] = os.path.basename(p)
|
||||||
try:
|
try:
|
||||||
os.execvp(p, arglist)
|
os.execvp(p, arglist)
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
raise CosimulationError(_error.OSError, str(e))
|
raise CosimulationError(_error.OSError, str(e))
|
||||||
else:
|
else:
|
||||||
os.close(wt)
|
os.close(wt)
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
@ -26,6 +26,8 @@ posedge -- callable to model a rising edge on a signal in a yield statement
|
|||||||
negedge -- callable to model a falling edge on a signal in a yield statement
|
negedge -- callable to model a falling edge on a signal in a yield statement
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from inspect import currentframe, getouterframes
|
from inspect import currentframe, getouterframes
|
||||||
from copy import copy, deepcopy
|
from copy import copy, deepcopy
|
||||||
@ -295,16 +297,16 @@ class _Signal(object):
|
|||||||
|
|
||||||
# vcd print methods
|
# vcd print methods
|
||||||
def _printVcdStr(self):
|
def _printVcdStr(self):
|
||||||
print >> sim._tf, "s%s %s" % (str(self._val), self._code)
|
print("s%s %s" % (str(self._val), self._code), file=sim._tf)
|
||||||
|
|
||||||
def _printVcdHex(self):
|
def _printVcdHex(self):
|
||||||
print >> sim._tf, "s%s %s" % (hex(self._val), self._code)
|
print("s%s %s" % (hex(self._val), self._code), file=sim._tf)
|
||||||
|
|
||||||
def _printVcdBit(self):
|
def _printVcdBit(self):
|
||||||
print >> sim._tf, "%d%s" % (self._val, self._code)
|
print("%d%s" % (self._val, self._code), file=sim._tf)
|
||||||
|
|
||||||
def _printVcdVec(self):
|
def _printVcdVec(self):
|
||||||
print >> sim._tf, "b%s %s" % (bin(self._val, self._nrbits), self._code)
|
print("b%s %s" % (bin(self._val, self._nrbits), self._code), file=sim._tf)
|
||||||
|
|
||||||
### use call interface for shadow signals ###
|
### use call interface for shadow signals ###
|
||||||
def __call__(self, left, right=None):
|
def __call__(self, left, right=None):
|
||||||
@ -510,14 +512,14 @@ class _Signal(object):
|
|||||||
|
|
||||||
# augmented assignment not supported
|
# augmented assignment not supported
|
||||||
def _augm(self):
|
def _augm(self):
|
||||||
raise TypeError, "Signal object doesn't support augmented assignment"
|
raise TypeError("Signal object doesn't support augmented assignment")
|
||||||
|
|
||||||
__iadd__ = __isub__ = __idiv__ = __imul__ = __ipow__ = __imod__ = _augm
|
__iadd__ = __isub__ = __idiv__ = __imul__ = __ipow__ = __imod__ = _augm
|
||||||
__ior__ = __iand__ = __ixor__ = __irshift__ = __ilshift__ = _augm
|
__ior__ = __iand__ = __ixor__ = __irshift__ = __ilshift__ = _augm
|
||||||
|
|
||||||
# index and slice assignment not supported
|
# index and slice assignment not supported
|
||||||
def __setitem__(self, key, val):
|
def __setitem__(self, key, val):
|
||||||
raise TypeError, "Signal object doesn't support item/slice assignment"
|
raise TypeError("Signal object doesn't support item/slice assignment")
|
||||||
|
|
||||||
|
|
||||||
# continues assignment support
|
# continues assignment support
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
""" Module that provides the Simulation class """
|
""" Module that provides the Simulation class """
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@ -158,7 +160,7 @@ class Simulation(object):
|
|||||||
_futureEvents.sort()
|
_futureEvents.sort()
|
||||||
t = _simulator._time = _futureEvents[0][0]
|
t = _simulator._time = _futureEvents[0][0]
|
||||||
if tracing:
|
if tracing:
|
||||||
print >> tracefile, "#%s" % t
|
print("#%s" % t, file=tracefile)
|
||||||
if cosim:
|
if cosim:
|
||||||
cosim._put(t)
|
cosim._put(t)
|
||||||
while _futureEvents:
|
while _futureEvents:
|
||||||
@ -188,7 +190,7 @@ class Simulation(object):
|
|||||||
self._finished = True
|
self._finished = True
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if tracing:
|
if tracing:
|
||||||
tracefile.flush()
|
tracefile.flush()
|
||||||
# if the exception came from a yield, make sure we can resume
|
# if the exception came from a yield, make sure we can resume
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
""" Module that provides the _Waiter class """
|
""" Module that provides the _Waiter class """
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
|
||||||
from types import GeneratorType
|
from types import GeneratorType
|
||||||
|
@ -49,6 +49,8 @@ traceSignals -- function that enables signal tracing in a VCD file
|
|||||||
toVerilog -- function that converts a design to Verilog
|
toVerilog -- function that converts a design to Verilog
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
__version__ = "0.9dev"
|
__version__ = "0.9dev"
|
||||||
|
|
||||||
@ -106,36 +108,36 @@ class ToVHDLWarning(ConversionWarning):
|
|||||||
# warnings.filterwarnings('always', r".*", ToVerilogWarning)
|
# warnings.filterwarnings('always', r".*", ToVerilogWarning)
|
||||||
|
|
||||||
def showwarning(message, category, filename, lineno, *args):
|
def showwarning(message, category, filename, lineno, *args):
|
||||||
print >> sys.stderr, "** %s: %s" % (category.__name__, message)
|
print("** %s: %s" % (category.__name__, message), file=sys.stderr)
|
||||||
|
|
||||||
warnings.showwarning = showwarning
|
warnings.showwarning = showwarning
|
||||||
|
|
||||||
|
|
||||||
from _bin import bin
|
from ._bin import bin
|
||||||
from _concat import concat
|
from ._concat import concat
|
||||||
from _intbv import intbv
|
from ._intbv import intbv
|
||||||
from _modbv import modbv
|
from ._modbv import modbv
|
||||||
from _join import join
|
from ._join import join
|
||||||
from _Signal import posedge, negedge, Signal, SignalType
|
from ._Signal import posedge, negedge, Signal, SignalType
|
||||||
from _ShadowSignal import ConcatSignal
|
from ._ShadowSignal import ConcatSignal
|
||||||
from _ShadowSignal import TristateSignal
|
from ._ShadowSignal import TristateSignal
|
||||||
from _simulator import now
|
from ._simulator import now
|
||||||
from _delay import delay
|
from ._delay import delay
|
||||||
from _Cosimulation import Cosimulation
|
from ._Cosimulation import Cosimulation
|
||||||
from _Simulation import Simulation
|
from ._Simulation import Simulation
|
||||||
from _misc import instances, downrange
|
from ._misc import instances, downrange
|
||||||
from _always_comb import always_comb
|
from ._always_comb import always_comb
|
||||||
from _always_seq import always_seq, ResetSignal
|
from ._always_seq import always_seq, ResetSignal
|
||||||
from _always import always
|
from ._always import always
|
||||||
from _instance import instance
|
from ._instance import instance
|
||||||
from _enum import enum, EnumType, EnumItemType
|
from ._enum import enum, EnumType, EnumItemType
|
||||||
from _traceSignals import traceSignals
|
from ._traceSignals import traceSignals
|
||||||
|
|
||||||
from myhdl import conversion
|
from myhdl import conversion
|
||||||
from conversion import toVerilog
|
from .conversion import toVerilog
|
||||||
from conversion import toVHDL
|
from .conversion import toVHDL
|
||||||
|
|
||||||
from _tristate import Tristate
|
from ._tristate import Tristate
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["bin",
|
__all__ = ["bin",
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
""" Module with the always function. """
|
""" Module with the always function. """
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
|
||||||
from types import FunctionType
|
from types import FunctionType
|
||||||
@ -53,7 +54,7 @@ def always(*args):
|
|||||||
raise AlwaysError(_error.ArgType)
|
raise AlwaysError(_error.ArgType)
|
||||||
if _isGenFunc(func):
|
if _isGenFunc(func):
|
||||||
raise AlwaysError(_error.ArgType)
|
raise AlwaysError(_error.ArgType)
|
||||||
if func.func_code.co_argcount > 0:
|
if func.__code__.co_argcount > 0:
|
||||||
raise AlwaysError(_error.NrOfArgs)
|
raise AlwaysError(_error.NrOfArgs)
|
||||||
return _Always(func, args)
|
return _Always(func, args)
|
||||||
return _always_decorator
|
return _always_decorator
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
""" Module with the always_comb function. """
|
""" Module with the always_comb function. """
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import inspect
|
import inspect
|
||||||
@ -47,16 +48,16 @@ def always_comb(func):
|
|||||||
raise AlwaysCombError(_error.ArgType)
|
raise AlwaysCombError(_error.ArgType)
|
||||||
if _isGenFunc(func):
|
if _isGenFunc(func):
|
||||||
raise AlwaysCombError(_error.ArgType)
|
raise AlwaysCombError(_error.ArgType)
|
||||||
if func.func_code.co_argcount > 0:
|
if func.__code__.co_argcount > 0:
|
||||||
raise AlwaysCombError(_error.NrOfArgs)
|
raise AlwaysCombError(_error.NrOfArgs)
|
||||||
varnames = func.func_code.co_varnames
|
varnames = func.__code__.co_varnames
|
||||||
symdict = {}
|
symdict = {}
|
||||||
for n, v in func.func_globals.items():
|
for n, v in func.__globals__.items():
|
||||||
if n not in varnames:
|
if n not in varnames:
|
||||||
symdict[n] = v
|
symdict[n] = v
|
||||||
# handle free variables
|
# handle free variables
|
||||||
if func.func_code.co_freevars:
|
if func.__code__.co_freevars:
|
||||||
for n, c in zip(func.func_code.co_freevars, func.func_closure):
|
for n, c in zip(func.__code__.co_freevars, func.__closure__):
|
||||||
try:
|
try:
|
||||||
obj = _cell_deref(c)
|
obj = _cell_deref(c)
|
||||||
symdict[n] = obj
|
symdict[n] = obj
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
""" Module with the always_seq decorator. """
|
""" Module with the always_seq decorator. """
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@ -75,7 +76,7 @@ def always_seq(edge, reset):
|
|||||||
raise AlwaysSeqError(_error.ArgType)
|
raise AlwaysSeqError(_error.ArgType)
|
||||||
if _isGenFunc(func):
|
if _isGenFunc(func):
|
||||||
raise AlwaysSeqError(_error.ArgType)
|
raise AlwaysSeqError(_error.ArgType)
|
||||||
if func.func_code.co_argcount > 0:
|
if func.__code__.co_argcount > 0:
|
||||||
raise AlwaysSeqError(_error.NrOfArgs)
|
raise AlwaysSeqError(_error.NrOfArgs)
|
||||||
return _AlwaysSeq(func, edge, reset)
|
return _AlwaysSeq(func, edge, reset)
|
||||||
return _always_seq_decorator
|
return _always_seq_decorator
|
||||||
@ -106,14 +107,14 @@ class _AlwaysSeq(_Instantiator):
|
|||||||
|
|
||||||
# find symdict
|
# find symdict
|
||||||
# similar to always_comb, but in class constructor
|
# similar to always_comb, but in class constructor
|
||||||
varnames = func.func_code.co_varnames
|
varnames = func.__code__.co_varnames
|
||||||
symdict = {}
|
symdict = {}
|
||||||
for n, v in func.func_globals.items():
|
for n, v in func.__globals__.items():
|
||||||
if n not in varnames:
|
if n not in varnames:
|
||||||
symdict[n] = v
|
symdict[n] = v
|
||||||
# handle free variables
|
# handle free variables
|
||||||
if func.func_code.co_freevars:
|
if func.__code__.co_freevars:
|
||||||
for n, c in zip(func.func_code.co_freevars, func.func_closure):
|
for n, c in zip(func.__code__.co_freevars, func.__closure__):
|
||||||
try:
|
try:
|
||||||
obj = _cell_deref(c)
|
obj = _cell_deref(c)
|
||||||
symdict[n] = obj
|
symdict[n] = obj
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
# cell dereferencing hack, thanks to Samuele Pedroni
|
# cell dereferencing hack, thanks to Samuele Pedroni
|
||||||
|
|
||||||
import new
|
from types import FunctionType
|
||||||
|
|
||||||
def _proto_acc(v=None):
|
def _proto_acc(v=None):
|
||||||
def acc():
|
def acc():
|
||||||
@ -9,10 +10,10 @@ def _proto_acc(v=None):
|
|||||||
|
|
||||||
_acc0 = _proto_acc()
|
_acc0 = _proto_acc()
|
||||||
|
|
||||||
_make_acc = lambda cell: (new.function (_acc0.func_code,
|
_make_acc = lambda cell: (FunctionType(_acc0.__code__,
|
||||||
_acc0.func_globals,
|
_acc0.__globals__,
|
||||||
'#cell_acc',
|
'#cell_acc',
|
||||||
_acc0.func_defaults,
|
_acc0.__defaults__,
|
||||||
(cell,)
|
(cell,)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
""" module with the concat function.
|
""" module with the concat function.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from myhdl._intbv import intbv
|
from myhdl._intbv import intbv
|
||||||
from myhdl._Signal import _Signal
|
from myhdl._Signal import _Signal
|
||||||
@ -69,7 +70,7 @@ def concat(base, *args):
|
|||||||
raise TypeError("concat: inappropriate argument type: %s" \
|
raise TypeError("concat: inappropriate argument type: %s" \
|
||||||
% type(arg))
|
% type(arg))
|
||||||
if not w:
|
if not w:
|
||||||
raise TypeError, "concat: arg on pos %d should have length" % (i+1)
|
raise TypeError("concat: arg on pos %d should have length" % (i+1))
|
||||||
width += w
|
width += w
|
||||||
val = val << w | v & (1L << w)-1
|
val = val << w | v & (1L << w)-1
|
||||||
|
|
||||||
|
@ -34,5 +34,5 @@ class delay(object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
if not isinstance(val, (int, long)) or val < 0:
|
if not isinstance(val, (int, long)) or val < 0:
|
||||||
raise TypeError, _errmsg
|
raise TypeError(_errmsg)
|
||||||
self._time = val
|
self._time = val
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
""" Module that implements enum.
|
""" Module that implements enum.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
|
||||||
from types import StringType
|
from types import StringType
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
""" myhdl _extractHierarchy module.
|
""" myhdl _extractHierarchy module.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@ -320,10 +321,10 @@ class _HierExtr(object):
|
|||||||
#All nested functions will be in co_consts
|
#All nested functions will be in co_consts
|
||||||
if func:
|
if func:
|
||||||
local_gens = []
|
local_gens = []
|
||||||
consts = func.func_code.co_consts
|
consts = func.__code__.co_consts
|
||||||
for item in _flatten(arg):
|
for item in _flatten(arg):
|
||||||
genfunc = _genfunc(item)
|
genfunc = _genfunc(item)
|
||||||
if genfunc.func_code in consts:
|
if genfunc.__code__ in consts:
|
||||||
local_gens.append(item)
|
local_gens.append(item)
|
||||||
if local_gens:
|
if local_gens:
|
||||||
objlist = _resolveRefs(symdict, local_gens)
|
objlist = _resolveRefs(symdict, local_gens)
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
""" Module with the always function. """
|
""" Module with the always function. """
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
|
||||||
from types import FunctionType
|
from types import FunctionType
|
||||||
@ -37,7 +38,7 @@ def instance(genFunc):
|
|||||||
raise InstanceError(_error.ArgType)
|
raise InstanceError(_error.ArgType)
|
||||||
if not _isGenFunc(genFunc):
|
if not _isGenFunc(genFunc):
|
||||||
raise InstanceError(_error.ArgType)
|
raise InstanceError(_error.ArgType)
|
||||||
if genFunc.func_code.co_argcount > 0:
|
if genFunc.__code__.co_argcount > 0:
|
||||||
raise InstanceError(_error.NrOfArgs)
|
raise InstanceError(_error.NrOfArgs)
|
||||||
return _Instantiator(genFunc)
|
return _Instantiator(genFunc)
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
""" Module with the intbv class """
|
""" Module with the intbv class """
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ class intbv(object):
|
|||||||
# iterator method
|
# iterator method
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
if not self._nrbits:
|
if not self._nrbits:
|
||||||
raise TypeError, "Cannot iterate over unsized intbv"
|
raise TypeError("Cannot iterate over unsized intbv")
|
||||||
return iter([self[i] for i in range(self._nrbits-1, -1, -1)])
|
return iter([self[i] for i in range(self._nrbits-1, -1, -1)])
|
||||||
|
|
||||||
# logical testing
|
# logical testing
|
||||||
@ -136,14 +137,14 @@ class intbv(object):
|
|||||||
j = 0
|
j = 0
|
||||||
j = int(j)
|
j = int(j)
|
||||||
if j < 0:
|
if j < 0:
|
||||||
raise ValueError, "intbv[i:j] requires j >= 0\n" \
|
raise ValueError("intbv[i:j] requires j >= 0\n" \
|
||||||
" j == %s" % j
|
" j == %s" % j)
|
||||||
if i is None: # default
|
if i is None: # default
|
||||||
return intbv(self._val >> j)
|
return intbv(self._val >> j)
|
||||||
i = int(i)
|
i = int(i)
|
||||||
if i <= j:
|
if i <= j:
|
||||||
raise ValueError, "intbv[i:j] requires i > j\n" \
|
raise ValueError("intbv[i:j] requires i > j\n" \
|
||||||
" i, j == %s, %s" % (i, j)
|
" i, j == %s, %s" % (i, j))
|
||||||
res = intbv((self._val & (1L << i)-1) >> j, _nrbits=i-j)
|
res = intbv((self._val & (1L << i)-1) >> j, _nrbits=i-j)
|
||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
@ -162,8 +163,8 @@ class intbv(object):
|
|||||||
j = 0
|
j = 0
|
||||||
j = int(j)
|
j = int(j)
|
||||||
if j < 0:
|
if j < 0:
|
||||||
raise ValueError, "intbv[i:j] = v requires j >= 0\n" \
|
raise ValueError("intbv[i:j] = v requires j >= 0\n" \
|
||||||
" j == %s" % j
|
" j == %s" % j)
|
||||||
if i is None: # default
|
if i is None: # default
|
||||||
q = self._val % (1L << j)
|
q = self._val % (1L << j)
|
||||||
self._val = val * (1L << j) + q
|
self._val = val * (1L << j) + q
|
||||||
@ -171,12 +172,12 @@ class intbv(object):
|
|||||||
return
|
return
|
||||||
i = int(i)
|
i = int(i)
|
||||||
if i <= j:
|
if i <= j:
|
||||||
raise ValueError, "intbv[i:j] = v requires i > j\n" \
|
raise ValueError("intbv[i:j] = v requires i > j\n" \
|
||||||
" i, j, v == %s, %s, %s" % (i, j, val)
|
" i, j, v == %s, %s, %s" % (i, j, val))
|
||||||
lim = (1L << (i-j))
|
lim = (1L << (i-j))
|
||||||
if val >= lim or val < -lim:
|
if val >= lim or val < -lim:
|
||||||
raise ValueError, "intbv[i:j] = v abs(v) too large\n" \
|
raise ValueError("intbv[i:j] = v abs(v) too large\n" \
|
||||||
" i, j, v == %s, %s, %s" % (i, j, val)
|
" i, j, v == %s, %s, %s" % (i, j, val))
|
||||||
mask = (lim-1) << j
|
mask = (lim-1) << j
|
||||||
self._val &= ~mask
|
self._val &= ~mask
|
||||||
self._val |= (val << j)
|
self._val |= (val << j)
|
||||||
@ -188,8 +189,8 @@ class intbv(object):
|
|||||||
elif val == 0:
|
elif val == 0:
|
||||||
self._val &= ~(1L << i)
|
self._val &= ~(1L << i)
|
||||||
else:
|
else:
|
||||||
raise ValueError, "intbv[i] = v requires v in (0, 1)\n" \
|
raise ValueError("intbv[i] = v requires v in (0, 1)\n" \
|
||||||
" i == %s " % i
|
" i == %s " % i)
|
||||||
|
|
||||||
self._handleBounds()
|
self._handleBounds()
|
||||||
|
|
||||||
|
@ -24,21 +24,19 @@ instances -- function that returns instances in a generator function
|
|||||||
downrange -- function that returns a downward range
|
downrange -- function that returns a downward range
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
from types import GeneratorType
|
|
||||||
from types import GeneratorType, ListType, TupleType
|
|
||||||
|
|
||||||
from myhdl._Cosimulation import Cosimulation
|
from myhdl._Cosimulation import Cosimulation
|
||||||
from myhdl._instance import _Instantiator
|
from myhdl._instance import _Instantiator
|
||||||
|
|
||||||
def _isGenSeq(obj):
|
def _isGenSeq(obj):
|
||||||
if isinstance(obj, (Cosimulation, _Instantiator)):
|
if isinstance(obj, (Cosimulation, _Instantiator)):
|
||||||
return True
|
return True
|
||||||
if not isinstance(obj, (ListType, TupleType, set)):
|
if not isinstance(obj, (list, tuple, set)):
|
||||||
return False
|
return False
|
||||||
## if not obj:
|
## if not obj:
|
||||||
## return False
|
## return False
|
||||||
|
@ -18,8 +18,9 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
""" Module with the modbv class """
|
""" Module with the modbv class """
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from _intbv import intbv
|
from ._intbv import intbv
|
||||||
|
|
||||||
class modbv(intbv):
|
class modbv(intbv):
|
||||||
__slots__ = []
|
__slots__ = []
|
||||||
@ -44,14 +45,14 @@ class modbv(intbv):
|
|||||||
j = 0
|
j = 0
|
||||||
j = int(j)
|
j = int(j)
|
||||||
if j < 0:
|
if j < 0:
|
||||||
raise ValueError, "modbv[i:j] requires j >= 0\n" \
|
raise ValueError("modbv[i:j] requires j >= 0\n" \
|
||||||
" j == %s" % j
|
" j == %s" % j)
|
||||||
if i is None: # default
|
if i is None: # default
|
||||||
return modbv(self._val >> j)
|
return modbv(self._val >> j)
|
||||||
i = int(i)
|
i = int(i)
|
||||||
if i <= j:
|
if i <= j:
|
||||||
raise ValueError, "modbv[i:j] requires i > j\n" \
|
raise ValueError("modbv[i:j] requires i > j\n" \
|
||||||
" i, j == %s, %s" % (i, j)
|
" i, j == %s, %s" % (i, j))
|
||||||
res = modbv((self._val & (1L << i)-1) >> j, _nrbits=i-j)
|
res = modbv((self._val & (1L << i)-1) >> j, _nrbits=i-j)
|
||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import ast
|
import ast
|
||||||
from types import FunctionType
|
from types import FunctionType
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
""" myhdl traceSignals module.
|
""" myhdl traceSignals module.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -74,7 +76,7 @@ class _TraceSignalsClass(object):
|
|||||||
_tracing = 1
|
_tracing = 1
|
||||||
try:
|
try:
|
||||||
if self.name is None:
|
if self.name is None:
|
||||||
name = dut.func_name
|
name = dut.__name__
|
||||||
else:
|
else:
|
||||||
name = str(self.name)
|
name = str(self.name)
|
||||||
if name is None:
|
if name is None:
|
||||||
@ -118,16 +120,16 @@ def _namecode(n):
|
|||||||
return code
|
return code
|
||||||
|
|
||||||
def _writeVcdHeader(f, timescale):
|
def _writeVcdHeader(f, timescale):
|
||||||
print >> f, "$date"
|
print("$date", file=f)
|
||||||
print >> f, " %s" % time.asctime()
|
print(" %s" % time.asctime(), file=f)
|
||||||
print >> f, "$end"
|
print("$end", file=f)
|
||||||
print >> f, "$version"
|
print("$version", file=f)
|
||||||
print >> f, " MyHDL %s" % __version__
|
print(" MyHDL %s" % __version__, file=f)
|
||||||
print >> f, "$end"
|
print("$end", file=f)
|
||||||
print >> f, "$timescale"
|
print("$timescale", file=f)
|
||||||
print >> f, " %s" % timescale
|
print(" %s" % timescale, file=f)
|
||||||
print >> f, "$end"
|
print("$end", file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
|
|
||||||
def _writeVcdSigs(f, hierarchy, tracelists):
|
def _writeVcdSigs(f, hierarchy, tracelists):
|
||||||
curlevel = 0
|
curlevel = 0
|
||||||
@ -143,8 +145,8 @@ def _writeVcdSigs(f, hierarchy, tracelists):
|
|||||||
assert(delta >= -1)
|
assert(delta >= -1)
|
||||||
if delta >= 0:
|
if delta >= 0:
|
||||||
for i in range(delta + 1):
|
for i in range(delta + 1):
|
||||||
print >> f, "$upscope $end"
|
print("$upscope $end", file=f)
|
||||||
print >> f, "$scope module %s $end" % name
|
print("$scope module %s $end" % name, file=f)
|
||||||
for n, s in sigdict.items():
|
for n, s in sigdict.items():
|
||||||
if s._val is None:
|
if s._val is None:
|
||||||
raise ValueError("%s of module %s has no initial value" % (n, name))
|
raise ValueError("%s of module %s has no initial value" % (n, name))
|
||||||
@ -156,11 +158,11 @@ def _writeVcdSigs(f, hierarchy, tracelists):
|
|||||||
# use real for enum strings
|
# use real for enum strings
|
||||||
if w and not isinstance(s._val, EnumItemType):
|
if w and not isinstance(s._val, EnumItemType):
|
||||||
if w == 1:
|
if w == 1:
|
||||||
print >> f, "$var reg 1 %s %s $end" % (s._code, n)
|
print("$var reg 1 %s %s $end" % (s._code, n), file=f)
|
||||||
else:
|
else:
|
||||||
print >> f, "$var reg %s %s %s $end" % (w, s._code, n)
|
print("$var reg %s %s %s $end" % (w, s._code, n), file=f)
|
||||||
else:
|
else:
|
||||||
print >> f, "$var real 1 %s %s $end" % (s._code, n)
|
print("$var real 1 %s %s $end" % (s._code, n), file=f)
|
||||||
# Memory dump by Frederik Teichert, http://teichert-ing.de, date: 2011.03.28
|
# Memory dump by Frederik Teichert, http://teichert-ing.de, date: 2011.03.28
|
||||||
# The Value Change Dump standard doesn't support multidimensional arrays so
|
# The Value Change Dump standard doesn't support multidimensional arrays so
|
||||||
# all memories are flattened and renamed.
|
# all memories are flattened and renamed.
|
||||||
@ -177,20 +179,20 @@ def _writeVcdSigs(f, hierarchy, tracelists):
|
|||||||
w = s._nrbits
|
w = s._nrbits
|
||||||
if w:
|
if w:
|
||||||
if w == 1:
|
if w == 1:
|
||||||
print >> f, "$var reg 1 %s %s(%i) $end" % (s._code, n, memindex)
|
print("$var reg 1 %s %s(%i) $end" % (s._code, n, memindex), file=f)
|
||||||
else:
|
else:
|
||||||
print >> f, "$var reg %s %s %s(%i) $end" % (w, s._code, n, memindex)
|
print("$var reg %s %s %s(%i) $end" % (w, s._code, n, memindex), file=f)
|
||||||
else:
|
else:
|
||||||
print >> f, "$var real 1 %s %s(%i) $end" % (s._code, n, memindex)
|
print("$var real 1 %s %s(%i) $end" % (s._code, n, memindex), file=f)
|
||||||
memindex += 1
|
memindex += 1
|
||||||
for i in range(curlevel):
|
for i in range(curlevel):
|
||||||
print >> f, "$upscope $end"
|
print("$upscope $end", file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
print >> f, "$enddefinitions $end"
|
print("$enddefinitions $end", file=f)
|
||||||
print >> f, "$dumpvars"
|
print("$dumpvars", file=f)
|
||||||
for s in siglist:
|
for s in siglist:
|
||||||
s._printVcd() # initial value
|
s._printVcd() # initial value
|
||||||
print >> f, "$end"
|
print("$end", file=f)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from myhdl._Signal import _Signal, _DelayedSignal
|
from myhdl._Signal import _Signal, _DelayedSignal
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
""" unparse module
|
""" unparse module
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
|
||||||
import compiler
|
import compiler
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
""" Module with utilility objects for MyHDL.
|
""" Module with utilility objects for MyHDL.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
@ -36,7 +38,7 @@ def _printExcInfo():
|
|||||||
# msg = msg[msg.rindex('.')+1:]
|
# msg = msg[msg.rindex('.')+1:]
|
||||||
if str(value):
|
if str(value):
|
||||||
msg += ": %s" % value
|
msg += ": %s" % value
|
||||||
print >> sys.stderr, msg
|
print(msg, file=sys.stderr)
|
||||||
|
|
||||||
_isGenFunc = inspect.isgeneratorfunction
|
_isGenFunc = inspect.isgeneratorfunction
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from _verify import verify, analyze, registerSimulator
|
from __future__ import absolute_import
|
||||||
from _toVerilog import toVerilog
|
from ._verify import verify, analyze, registerSimulator
|
||||||
from _toVHDL import toVHDL
|
from ._toVerilog import toVerilog
|
||||||
|
from ._toVHDL import toVHDL
|
||||||
|
|
||||||
__all__ = ["verify",
|
__all__ = ["verify",
|
||||||
"analyze",
|
"analyze",
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
""" MyHDL conversion analysis module.
|
""" MyHDL conversion analysis module.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
# import compiler
|
# import compiler
|
||||||
@ -42,7 +43,7 @@ from myhdl.conversion._misc import (_error, _access, _kind,
|
|||||||
from myhdl._extractHierarchy import _isMem, _getMemInfo, _UserCode
|
from myhdl._extractHierarchy import _isMem, _getMemInfo, _UserCode
|
||||||
from myhdl._Signal import _Signal, _WaiterList
|
from myhdl._Signal import _Signal, _WaiterList
|
||||||
from myhdl._ShadowSignal import _ShadowSignal, _SliceSignal
|
from myhdl._ShadowSignal import _ShadowSignal, _SliceSignal
|
||||||
from myhdl._util import _isTupleOfInts, _dedent
|
from myhdl._util import _isTupleOfInts, _dedent, _makeAST
|
||||||
from myhdl._resolverefs import _AttrRefTransformer
|
from myhdl._resolverefs import _AttrRefTransformer
|
||||||
|
|
||||||
myhdlObjects = myhdl.__dict__.values()
|
myhdlObjects = myhdl.__dict__.values()
|
||||||
@ -76,13 +77,6 @@ def _makeName(n, prefixes, namedict):
|
|||||||
## print name
|
## print name
|
||||||
return name
|
return name
|
||||||
|
|
||||||
def _makeAST(f):
|
|
||||||
s = inspect.getsource(f)
|
|
||||||
s = _dedent(s)
|
|
||||||
tree = ast.parse(s)
|
|
||||||
tree.sourcefile = inspect.getsourcefile(f)
|
|
||||||
tree.lineoffset = inspect.getsourcelines(f)[1]-1
|
|
||||||
return tree
|
|
||||||
|
|
||||||
def _analyzeSigs(hierarchy, hdl='Verilog'):
|
def _analyzeSigs(hierarchy, hdl='Verilog'):
|
||||||
curlevel = 0
|
curlevel = 0
|
||||||
@ -158,18 +152,13 @@ def _analyzeGens(top, absnames):
|
|||||||
tree = g
|
tree = g
|
||||||
elif isinstance(g, (_AlwaysComb, _AlwaysSeq, _Always)):
|
elif isinstance(g, (_AlwaysComb, _AlwaysSeq, _Always)):
|
||||||
f = g.func
|
f = g.func
|
||||||
s = inspect.getsource(f)
|
tree = _makeAST(f)
|
||||||
s = _dedent(s)
|
tree.symdict = f.__globals__.copy()
|
||||||
tree = ast.parse(s)
|
|
||||||
#print ast.dump(tree)
|
|
||||||
tree.sourcefile = inspect.getsourcefile(f)
|
|
||||||
tree.lineoffset = inspect.getsourcelines(f)[1]-1
|
|
||||||
tree.symdict = f.func_globals.copy()
|
|
||||||
tree.callstack = []
|
tree.callstack = []
|
||||||
# handle free variables
|
# handle free variables
|
||||||
tree.nonlocaldict = {}
|
tree.nonlocaldict = {}
|
||||||
if f.func_code.co_freevars:
|
if f.__code__.co_freevars:
|
||||||
for n, c in zip(f.func_code.co_freevars, f.func_closure):
|
for n, c in zip(f.__code__.co_freevars, f.__closure__):
|
||||||
obj = _cell_deref(c)
|
obj = _cell_deref(c)
|
||||||
tree.symdict[n] = obj
|
tree.symdict[n] = obj
|
||||||
# currently, only intbv as automatic nonlocals (until Python 3.0)
|
# currently, only intbv as automatic nonlocals (until Python 3.0)
|
||||||
@ -189,12 +178,7 @@ def _analyzeGens(top, absnames):
|
|||||||
v.visit(tree)
|
v.visit(tree)
|
||||||
else: # @instance
|
else: # @instance
|
||||||
f = g.gen.gi_frame
|
f = g.gen.gi_frame
|
||||||
s = inspect.getsource(f)
|
tree = _makeAST(f)
|
||||||
s = _dedent(s)
|
|
||||||
tree = ast.parse(s)
|
|
||||||
# print ast.dump(tree)
|
|
||||||
tree.sourcefile = inspect.getsourcefile(f)
|
|
||||||
tree.lineoffset = inspect.getsourcelines(f)[1]-1
|
|
||||||
tree.symdict = f.f_globals.copy()
|
tree.symdict = f.f_globals.copy()
|
||||||
tree.symdict.update(f.f_locals)
|
tree.symdict.update(f.f_locals)
|
||||||
tree.nonlocaldict = {}
|
tree.nonlocaldict = {}
|
||||||
@ -607,24 +591,18 @@ class _AnalyzeVisitor(ast.NodeVisitor, _ConversionMixin):
|
|||||||
pass
|
pass
|
||||||
elif type(f) is FunctionType:
|
elif type(f) is FunctionType:
|
||||||
argsAreInputs = False
|
argsAreInputs = False
|
||||||
s = inspect.getsource(f)
|
tree = _makeAST(f)
|
||||||
s = _dedent(s)
|
|
||||||
tree = ast.parse(s)
|
|
||||||
# print ast.dump(tree)
|
|
||||||
# print tree
|
|
||||||
fname = f.__name__
|
fname = f.__name__
|
||||||
tree.name = _Label(fname)
|
tree.name = _Label(fname)
|
||||||
tree.sourcefile = inspect.getsourcefile(f)
|
tree.symdict = f.__globals__.copy()
|
||||||
tree.lineoffset = inspect.getsourcelines(f)[1]-1
|
|
||||||
tree.symdict = f.func_globals.copy()
|
|
||||||
tree.nonlocaldict = {}
|
tree.nonlocaldict = {}
|
||||||
if fname in self.tree.callstack:
|
if fname in self.tree.callstack:
|
||||||
self.raiseError(node, _error.NotSupported, "Recursive call")
|
self.raiseError(node, _error.NotSupported, "Recursive call")
|
||||||
tree.callstack = self.tree.callstack[:]
|
tree.callstack = self.tree.callstack[:]
|
||||||
tree.callstack.append(fname)
|
tree.callstack.append(fname)
|
||||||
# handle free variables
|
# handle free variables
|
||||||
if f.func_code.co_freevars:
|
if f.__code__.co_freevars:
|
||||||
for n, c in zip(f.func_code.co_freevars, f.func_closure):
|
for n, c in zip(f.__code__.co_freevars, f.__closure__):
|
||||||
obj = _cell_deref(c)
|
obj = _cell_deref(c)
|
||||||
if not isinstance(obj, (int, long, _Signal)):
|
if not isinstance(obj, (int, long, _Signal)):
|
||||||
self.raiseError(node, _error.FreeVarTypeError, n)
|
self.raiseError(node, _error.FreeVarTypeError, n)
|
||||||
@ -769,7 +747,7 @@ class _AnalyzeVisitor(ast.NodeVisitor, _ConversionMixin):
|
|||||||
self.kind = _kind.DECLARATION
|
self.kind = _kind.DECLARATION
|
||||||
try:
|
try:
|
||||||
self.visit(node.elt)
|
self.visit(node.elt)
|
||||||
except ConversionError, e:
|
except ConversionError as e:
|
||||||
if e.kind == _error.UnboundLocal:
|
if e.kind == _error.UnboundLocal:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -20,18 +20,16 @@
|
|||||||
""" myhdl toVerilog package.
|
""" myhdl toVerilog package.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
import compiler
|
|
||||||
from compiler import ast as astNode
|
|
||||||
import ast
|
import ast
|
||||||
|
|
||||||
import myhdl
|
import myhdl
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
from myhdl import ConversionError
|
from myhdl import ConversionError
|
||||||
from myhdl._util import _flatten
|
from myhdl._util import _flatten
|
||||||
from myhdl._unparse import _unparse
|
|
||||||
|
|
||||||
class _error(object):
|
class _error(object):
|
||||||
FirstArgType = "first argument should be a classic function"
|
FirstArgType = "first argument should be a classic function"
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
""" myhdl toVHDL conversion module.
|
""" myhdl toVHDL conversion module.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@ -125,7 +127,7 @@ class _ToVHDLConvertor(object):
|
|||||||
|
|
||||||
_converting = 1
|
_converting = 1
|
||||||
if self.name is None:
|
if self.name is None:
|
||||||
name = func.func_name
|
name = func.__name__
|
||||||
else:
|
else:
|
||||||
name = str(self.name)
|
name = str(self.name)
|
||||||
try:
|
try:
|
||||||
@ -197,7 +199,7 @@ class _ToVHDLConvertor(object):
|
|||||||
|
|
||||||
if pfile:
|
if pfile:
|
||||||
_writeFileHeader(pfile, ppath)
|
_writeFileHeader(pfile, ppath)
|
||||||
print >> pfile, _package
|
print(_package, file=pfile)
|
||||||
pfile.close()
|
pfile.close()
|
||||||
|
|
||||||
_writeFileHeader(vfile, vpath)
|
_writeFileHeader(vfile, vpath)
|
||||||
@ -258,45 +260,45 @@ def _writeFileHeader(f, fn):
|
|||||||
date=datetime.today().ctime()
|
date=datetime.today().ctime()
|
||||||
)
|
)
|
||||||
if toVHDL.header:
|
if toVHDL.header:
|
||||||
print >> f, string.Template(toVHDL.header).substitute(vars)
|
print(string.Template(toVHDL.header).substitute(vars), file=f)
|
||||||
if not toVHDL.no_myhdl_header:
|
if not toVHDL.no_myhdl_header:
|
||||||
print >> f, string.Template(myhdl_header).substitute(vars)
|
print(string.Template(myhdl_header).substitute(vars), file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
|
|
||||||
|
|
||||||
def _writeCustomPackage(f, intf):
|
def _writeCustomPackage(f, intf):
|
||||||
print >> f
|
print(file=f)
|
||||||
print >> f, "package pck_%s is" % intf.name
|
print("package pck_%s is" % intf.name, file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
print >> f, "attribute enum_encoding: string;"
|
print("attribute enum_encoding: string;", file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
sortedList = list(_enumPortTypeSet)
|
sortedList = list(_enumPortTypeSet)
|
||||||
sortedList.sort(cmp=lambda a, b: cmp(a._name, b._name))
|
sortedList.sort(cmp=lambda a, b: cmp(a._name, b._name))
|
||||||
for t in sortedList:
|
for t in sortedList:
|
||||||
print >> f, " %s" % t._toVHDL()
|
print(" %s" % t._toVHDL(), file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
print >> f, "end package pck_%s;" % intf.name
|
print("end package pck_%s;" % intf.name, file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
|
|
||||||
|
|
||||||
def _writeModuleHeader(f, intf, needPck, lib, arch, useClauses, doc, numeric):
|
def _writeModuleHeader(f, intf, needPck, lib, arch, useClauses, doc, numeric):
|
||||||
print >> f, "library IEEE;"
|
print("library IEEE;", file=f)
|
||||||
print >> f, "use IEEE.std_logic_1164.all;"
|
print("use IEEE.std_logic_1164.all;", file=f)
|
||||||
print >> f, "use IEEE.numeric_std.all;"
|
print("use IEEE.numeric_std.all;", file=f)
|
||||||
print >> f, "use std.textio.all;"
|
print("use std.textio.all;", file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
if lib != "work":
|
if lib != "work":
|
||||||
print >> f, "library %s;" % lib
|
print("library %s;" % lib, file=f)
|
||||||
if useClauses is not None:
|
if useClauses is not None:
|
||||||
f.write(useClauses)
|
f.write(useClauses)
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
else:
|
else:
|
||||||
print >> f, "use %s.pck_myhdl_%s.all;" % (lib, _shortversion)
|
print("use %s.pck_myhdl_%s.all;" % (lib, _shortversion), file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
if needPck:
|
if needPck:
|
||||||
print >> f, "use %s.pck_%s.all;" % (lib, intf.name)
|
print("use %s.pck_%s.all;" % (lib, intf.name), file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
print >> f, "entity %s is" % intf.name
|
print("entity %s is" % intf.name, file=f)
|
||||||
if intf.argnames:
|
if intf.argnames:
|
||||||
f.write(" port (")
|
f.write(" port (")
|
||||||
c = ''
|
c = ''
|
||||||
@ -326,11 +328,11 @@ def _writeModuleHeader(f, intf, needPck, lib, arch, useClauses, doc, numeric):
|
|||||||
)
|
)
|
||||||
f.write("\n %s: in %s%s" % (portname, p, r))
|
f.write("\n %s: in %s%s" % (portname, p, r))
|
||||||
f.write("\n );\n")
|
f.write("\n );\n")
|
||||||
print >> f, "end entity %s;" % intf.name
|
print("end entity %s;" % intf.name, file=f)
|
||||||
print >> f, doc
|
print(doc, file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
print >> f, "architecture %s of %s is" % (arch, intf.name)
|
print("architecture %s of %s is" % (arch, intf.name), file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
|
|
||||||
|
|
||||||
def _writeFuncDecls(f):
|
def _writeFuncDecls(f):
|
||||||
@ -385,7 +387,7 @@ def _writeSigDecls(f, intf, siglist, memlist):
|
|||||||
)
|
)
|
||||||
# the following line implements initial value assignments
|
# the following line implements initial value assignments
|
||||||
# print >> f, "%s %s%s = %s;" % (s._driven, r, s._name, int(s._val))
|
# print >> f, "%s %s%s = %s;" % (s._driven, r, s._name, int(s._val))
|
||||||
print >> f, "signal %s: %s%s;" % (s._name, p, r)
|
print("signal %s: %s%s;" % (s._name, p, r), file=f)
|
||||||
elif s._read:
|
elif s._read:
|
||||||
# the original exception
|
# the original exception
|
||||||
# raise ToVHDLError(_error.UndrivenSignal, s._name)
|
# raise ToVHDLError(_error.UndrivenSignal, s._name)
|
||||||
@ -394,7 +396,7 @@ def _writeSigDecls(f, intf, siglist, memlist):
|
|||||||
category=ToVHDLWarning
|
category=ToVHDLWarning
|
||||||
)
|
)
|
||||||
constwires.append(s)
|
constwires.append(s)
|
||||||
print >> f, "signal %s: %s%s;" % (s._name, p, r)
|
print("signal %s: %s%s;" % (s._name, p, r), file=f)
|
||||||
for m in memlist:
|
for m in memlist:
|
||||||
if not m._used:
|
if not m._used:
|
||||||
continue
|
continue
|
||||||
@ -409,16 +411,16 @@ def _writeSigDecls(f, intf, siglist, memlist):
|
|||||||
r = _getRangeString(m.elObj)
|
r = _getRangeString(m.elObj)
|
||||||
p = _getTypeString(m.elObj)
|
p = _getTypeString(m.elObj)
|
||||||
t = "t_array_%s" % m.name
|
t = "t_array_%s" % m.name
|
||||||
print >> f, "type %s is array(0 to %s-1) of %s%s;" % (t, m.depth, p, r)
|
print("type %s is array(0 to %s-1) of %s%s;" % (t, m.depth, p, r), file=f)
|
||||||
print >> f, "signal %s: %s;" % (m.name, t)
|
print("signal %s: %s;" % (m.name, t), file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
|
|
||||||
def _writeCompDecls(f, compDecls):
|
def _writeCompDecls(f, compDecls):
|
||||||
if compDecls is not None:
|
if compDecls is not None:
|
||||||
print >> f, compDecls
|
print(compDecls, file=f)
|
||||||
|
|
||||||
def _writeModuleFooter(f, arch):
|
def _writeModuleFooter(f, arch):
|
||||||
print >> f, "end architecture %s;" % arch
|
print("end architecture %s;" % arch, file=f)
|
||||||
|
|
||||||
def _getRangeString(s):
|
def _getRangeString(s):
|
||||||
if isinstance(s._val, EnumItemType):
|
if isinstance(s._val, EnumItemType):
|
||||||
@ -469,8 +471,8 @@ def _convertGens(genlist, siglist, memlist, vfile):
|
|||||||
v = Visitor(tree, blockBuf, funcBuf)
|
v = Visitor(tree, blockBuf, funcBuf)
|
||||||
v.visit(tree)
|
v.visit(tree)
|
||||||
vfile.write(funcBuf.getvalue()); funcBuf.close()
|
vfile.write(funcBuf.getvalue()); funcBuf.close()
|
||||||
print >> vfile, "begin"
|
print("begin", file=vfile)
|
||||||
print >> vfile
|
print(file=vfile)
|
||||||
for s in constwires:
|
for s in constwires:
|
||||||
if s._type is bool:
|
if s._type is bool:
|
||||||
c = int(s._val)
|
c = int(s._val)
|
||||||
@ -485,19 +487,19 @@ def _convertGens(genlist, siglist, memlist, vfile):
|
|||||||
pre, suf = "to_unsigned(", ", %s)" % w
|
pre, suf = "to_unsigned(", ", %s)" % w
|
||||||
else:
|
else:
|
||||||
raise ToVHDLError("Unexpected type for constant signal", s._name)
|
raise ToVHDLError("Unexpected type for constant signal", s._name)
|
||||||
print >> vfile, "%s <= %s%s%s;" % (s._name, pre, c, suf)
|
print("%s <= %s%s%s;" % (s._name, pre, c, suf), file=vfile)
|
||||||
print >> vfile
|
print(file=vfile)
|
||||||
# shadow signal assignments
|
# shadow signal assignments
|
||||||
for s in siglist:
|
for s in siglist:
|
||||||
if hasattr(s, 'toVHDL') and s._read:
|
if hasattr(s, 'toVHDL') and s._read:
|
||||||
print >> vfile, s.toVHDL()
|
print(s.toVHDL(), file=vfile)
|
||||||
# hack for slice signals in a list
|
# hack for slice signals in a list
|
||||||
for m in memlist:
|
for m in memlist:
|
||||||
if m._read:
|
if m._read:
|
||||||
for s in m.mem:
|
for s in m.mem:
|
||||||
if hasattr(s, 'toVHDL'):
|
if hasattr(s, 'toVHDL'):
|
||||||
print >> vfile, s.toVHDL()
|
print(s.toVHDL(), file=vfile)
|
||||||
print >> vfile
|
print(file=vfile)
|
||||||
vfile.write(blockBuf.getvalue()); blockBuf.close()
|
vfile.write(blockBuf.getvalue()); blockBuf.close()
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
# This file is part of the myhdl library, a Python package for using
|
# This file is part of the myhdl library, a Python package for using
|
||||||
# Python as a Hardware Description Language.
|
# Python as a Hardware Description Language.
|
||||||
#
|
#
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
""" myhdl toVerilog conversion module.
|
""" myhdl toVerilog conversion module.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@ -121,7 +123,7 @@ class _ToVerilogConvertor(object):
|
|||||||
|
|
||||||
_converting = 1
|
_converting = 1
|
||||||
if self.name is None:
|
if self.name is None:
|
||||||
name = func.func_name
|
name = func.__name__
|
||||||
else:
|
else:
|
||||||
name = str(self.name)
|
name = str(self.name)
|
||||||
try:
|
try:
|
||||||
@ -214,24 +216,24 @@ def _writeFileHeader(f, fn, ts):
|
|||||||
date=datetime.today().ctime()
|
date=datetime.today().ctime()
|
||||||
)
|
)
|
||||||
if not toVerilog.no_myhdl_header:
|
if not toVerilog.no_myhdl_header:
|
||||||
print >> f, string.Template(myhdl_header).substitute(vars)
|
print(string.Template(myhdl_header).substitute(vars), file=f)
|
||||||
if toVerilog.header:
|
if toVerilog.header:
|
||||||
print >> f, string.Template(toVerilog.header).substitute(vars)
|
print(string.Template(toVerilog.header).substitute(vars), file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
print >> f, "`timescale %s" % ts
|
print("`timescale %s" % ts, file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
|
|
||||||
|
|
||||||
def _writeModuleHeader(f, intf, doc):
|
def _writeModuleHeader(f, intf, doc):
|
||||||
print >> f, "module %s (" % intf.name
|
print("module %s (" % intf.name, file=f)
|
||||||
b = StringIO()
|
b = StringIO()
|
||||||
for portname in intf.argnames:
|
for portname in intf.argnames:
|
||||||
print >> b, " %s," % portname
|
print(" %s," % portname, file=b)
|
||||||
print >> f, b.getvalue()[:-2]
|
print(b.getvalue()[:-2], file=f)
|
||||||
b.close()
|
b.close()
|
||||||
print >> f, ");"
|
print(");", file=f)
|
||||||
print >> f, doc
|
print(doc, file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
for portname in intf.argnames:
|
for portname in intf.argnames:
|
||||||
s = intf.argdict[portname]
|
s = intf.argdict[portname]
|
||||||
if s._name is None:
|
if s._name is None:
|
||||||
@ -247,18 +249,18 @@ def _writeModuleHeader(f, intf, doc):
|
|||||||
warnings.warn("%s: %s" % (_error.OutputPortRead, portname),
|
warnings.warn("%s: %s" % (_error.OutputPortRead, portname),
|
||||||
category=ToVerilogWarning
|
category=ToVerilogWarning
|
||||||
)
|
)
|
||||||
print >> f, "output %s%s%s;" % (p, r, portname)
|
print("output %s%s%s;" % (p, r, portname), file=f)
|
||||||
if s._driven == 'reg':
|
if s._driven == 'reg':
|
||||||
print >> f, "reg %s%s%s;" % (p, r, portname)
|
print("reg %s%s%s;" % (p, r, portname), file=f)
|
||||||
else:
|
else:
|
||||||
print >> f, "wire %s%s%s;" % (p, r, portname)
|
print("wire %s%s%s;" % (p, r, portname), file=f)
|
||||||
else:
|
else:
|
||||||
if not s._read:
|
if not s._read:
|
||||||
warnings.warn("%s: %s" % (_error.UnusedPort, portname),
|
warnings.warn("%s: %s" % (_error.UnusedPort, portname),
|
||||||
category=ToVerilogWarning
|
category=ToVerilogWarning
|
||||||
)
|
)
|
||||||
print >> f, "input %s%s%s;" % (p, r, portname)
|
print("input %s%s%s;" % (p, r, portname), file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
|
|
||||||
|
|
||||||
def _writeSigDecls(f, intf, siglist, memlist):
|
def _writeSigDecls(f, intf, siglist, memlist):
|
||||||
@ -280,7 +282,7 @@ def _writeSigDecls(f, intf, siglist, memlist):
|
|||||||
k = 'reg'
|
k = 'reg'
|
||||||
# the following line implements initial value assignments
|
# the following line implements initial value assignments
|
||||||
# print >> f, "%s %s%s = %s;" % (k, r, s._name, int(s._val))
|
# print >> f, "%s %s%s = %s;" % (k, r, s._name, int(s._val))
|
||||||
print >> f, "%s %s%s%s;" % (k, p, r, s._name)
|
print("%s %s%s%s;" % (k, p, r, s._name), file=f)
|
||||||
elif s._read:
|
elif s._read:
|
||||||
# the original exception
|
# the original exception
|
||||||
# raise ToVerilogError(_error.UndrivenSignal, s._name)
|
# raise ToVerilogError(_error.UndrivenSignal, s._name)
|
||||||
@ -289,8 +291,8 @@ def _writeSigDecls(f, intf, siglist, memlist):
|
|||||||
category=ToVerilogWarning
|
category=ToVerilogWarning
|
||||||
)
|
)
|
||||||
constwires.append(s)
|
constwires.append(s)
|
||||||
print >> f, "wire %s%s;" % (r, s._name)
|
print("wire %s%s;" % (r, s._name), file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
for m in memlist:
|
for m in memlist:
|
||||||
if not m._used:
|
if not m._used:
|
||||||
continue
|
continue
|
||||||
@ -307,29 +309,29 @@ def _writeSigDecls(f, intf, siglist, memlist):
|
|||||||
k = 'wire'
|
k = 'wire'
|
||||||
if m._driven:
|
if m._driven:
|
||||||
k = m._driven
|
k = m._driven
|
||||||
print >> f, "%s %s%s%s [0:%s-1];" % (k, p, r, m.name, m.depth)
|
print("%s %s%s%s [0:%s-1];" % (k, p, r, m.name, m.depth), file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
for s in constwires:
|
for s in constwires:
|
||||||
if s._type in (bool, intbv):
|
if s._type in (bool, intbv):
|
||||||
c = int(s.val)
|
c = int(s.val)
|
||||||
else:
|
else:
|
||||||
raise ToVerilogError("Unexpected type for constant signal", s._name)
|
raise ToVerilogError("Unexpected type for constant signal", s._name)
|
||||||
print >> f, "assign %s = %s;" % (s._name, c)
|
print("assign %s = %s;" % (s._name, c), file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
# shadow signal assignments
|
# shadow signal assignments
|
||||||
for s in siglist:
|
for s in siglist:
|
||||||
if hasattr(s, 'toVerilog') and s._read:
|
if hasattr(s, 'toVerilog') and s._read:
|
||||||
print >> f, s.toVerilog()
|
print(s.toVerilog(), file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
|
|
||||||
|
|
||||||
def _writeModuleFooter(f):
|
def _writeModuleFooter(f):
|
||||||
print >> f, "endmodule"
|
print("endmodule", file=f)
|
||||||
|
|
||||||
|
|
||||||
def _writeTestBench(f, intf, trace=False):
|
def _writeTestBench(f, intf, trace=False):
|
||||||
print >> f, "module tb_%s;" % intf.name
|
print("module tb_%s;" % intf.name, file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
fr = StringIO()
|
fr = StringIO()
|
||||||
to = StringIO()
|
to = StringIO()
|
||||||
pm = StringIO()
|
pm = StringIO()
|
||||||
@ -337,32 +339,32 @@ def _writeTestBench(f, intf, trace=False):
|
|||||||
s = intf.argdict[portname]
|
s = intf.argdict[portname]
|
||||||
r = _getRangeString(s)
|
r = _getRangeString(s)
|
||||||
if s._driven:
|
if s._driven:
|
||||||
print >> f, "wire %s%s;" % (r, portname)
|
print("wire %s%s;" % (r, portname), file=f)
|
||||||
print >> to, " %s," % portname
|
print(" %s," % portname, file=to)
|
||||||
else:
|
else:
|
||||||
print >> f, "reg %s%s;" % (r, portname)
|
print("reg %s%s;" % (r, portname), file=f)
|
||||||
print >> fr, " %s," % portname
|
print(" %s," % portname, file=fr)
|
||||||
print >> pm, " %s," % portname
|
print(" %s," % portname, file=pm)
|
||||||
print >> f
|
print(file=f)
|
||||||
print >> f, "initial begin"
|
print("initial begin", file=f)
|
||||||
if trace:
|
if trace:
|
||||||
print >> f, ' $dumpfile("%s.vcd");' % intf.name
|
print(' $dumpfile("%s.vcd");' % intf.name, file=f)
|
||||||
print >> f, ' $dumpvars(0, dut);'
|
print(' $dumpvars(0, dut);', file=f)
|
||||||
if fr.getvalue():
|
if fr.getvalue():
|
||||||
print >> f, " $from_myhdl("
|
print(" $from_myhdl(", file=f)
|
||||||
print >> f, fr.getvalue()[:-2]
|
print(fr.getvalue()[:-2], file=f)
|
||||||
print >> f, " );"
|
print(" );", file=f)
|
||||||
if to.getvalue():
|
if to.getvalue():
|
||||||
print >> f, " $to_myhdl("
|
print(" $to_myhdl(", file=f)
|
||||||
print >> f, to.getvalue()[:-2]
|
print(to.getvalue()[:-2], file=f)
|
||||||
print >> f, " );"
|
print(" );", file=f)
|
||||||
print >> f, "end"
|
print("end", file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
print >> f, "%s dut(" % intf.name
|
print("%s dut(" % intf.name, file=f)
|
||||||
print >> f, pm.getvalue()[:-2]
|
print(pm.getvalue()[:-2], file=f)
|
||||||
print >> f, ");"
|
print(");", file=f)
|
||||||
print >> f
|
print(file=f)
|
||||||
print >> f, "endmodule"
|
print("endmodule", file=f)
|
||||||
|
|
||||||
|
|
||||||
def _getRangeString(s):
|
def _getRangeString(s):
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
@ -103,8 +105,8 @@ class _VerificationClass(object):
|
|||||||
def __call__(self, func, *args, **kwargs):
|
def __call__(self, func, *args, **kwargs):
|
||||||
|
|
||||||
vals = {}
|
vals = {}
|
||||||
vals['topname'] = func.func_name
|
vals['topname'] = func.__name__
|
||||||
vals['unitname'] = func.func_name.lower()
|
vals['unitname'] = func.__name__.lower()
|
||||||
vals['version'] = _version
|
vals['version'] = _version
|
||||||
|
|
||||||
hdlsim = self.simulator
|
hdlsim = self.simulator
|
||||||
@ -143,11 +145,11 @@ class _VerificationClass(object):
|
|||||||
#print(analyze)
|
#print(analyze)
|
||||||
ret = subprocess.call(analyze, shell=True)
|
ret = subprocess.call(analyze, shell=True)
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
print >> sys.stderr, "Analysis failed"
|
print("Analysis failed", file=sys.stderr)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
if self._analyzeOnly:
|
if self._analyzeOnly:
|
||||||
print >> sys.stderr, "Analysis succeeded"
|
print("Analysis succeeded", file=sys.stderr)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
f = tempfile.TemporaryFile()
|
f = tempfile.TemporaryFile()
|
||||||
@ -161,7 +163,7 @@ class _VerificationClass(object):
|
|||||||
flines = f.readlines()
|
flines = f.readlines()
|
||||||
f.close()
|
f.close()
|
||||||
if not flines:
|
if not flines:
|
||||||
print >> sys.stderr, "No MyHDL simulation output - nothing to verify"
|
print("No MyHDL simulation output - nothing to verify", file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
@ -169,7 +171,7 @@ class _VerificationClass(object):
|
|||||||
#print(elaborate)
|
#print(elaborate)
|
||||||
ret = subprocess.call(elaborate, shell=True)
|
ret = subprocess.call(elaborate, shell=True)
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
print >> sys.stderr, "Elaboration failed"
|
print("Elaboration failed", file=sys.stderr)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
g = tempfile.TemporaryFile()
|
g = tempfile.TemporaryFile()
|
||||||
@ -214,9 +216,9 @@ class _VerificationClass(object):
|
|||||||
d.close()
|
d.close()
|
||||||
|
|
||||||
if not s:
|
if not s:
|
||||||
print >> sys.stderr, "Conversion verification succeeded"
|
print("Conversion verification succeeded", file=sys.stderr)
|
||||||
else:
|
else:
|
||||||
print >> sys.stderr, "Conversion verification failed"
|
print("Conversion verification failed", file=sys.stderr)
|
||||||
# print >> sys.stderr, s ,
|
# print >> sys.stderr, s ,
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from test_lfsr24 import test_lfsr24
|
from test_lfsr24 import test_lfsr24
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
def lfsr24(lfsr, enable, clock, reset):
|
def lfsr24(lfsr, enable, clock, reset):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
def long_divider(
|
def long_divider(
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
def random_generator(random_word, enable, clock, reset):
|
def random_generator(random_word, enable, clock, reset):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from glibc_random import glibc_random
|
from glibc_random import glibc_random
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from glibc_random import glibc_random
|
from glibc_random import glibc_random
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from lfsr24 import lfsr24
|
from lfsr24 import lfsr24
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from glibc_random import glibc_random
|
from glibc_random import glibc_random
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from test_longdiv import test_longdiv
|
from test_longdiv import test_longdiv
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from test_longdiv import test_longdiv
|
from test_longdiv import test_longdiv
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from test_longdiv import test_longdiv
|
from test_longdiv import test_longdiv
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from test_longdiv import test_longdiv
|
from test_longdiv import test_longdiv
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from test_longdiv import test_longdiv
|
from test_longdiv import test_longdiv
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from test_longdiv import test_longdiv
|
from test_longdiv import test_longdiv
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from test_longdiv import test_longdiv
|
from test_longdiv import test_longdiv
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from test_longdiv import test_longdiv
|
from test_longdiv import test_longdiv
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from test_longdiv import test_longdiv
|
from test_longdiv import test_longdiv
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from test_longdiv import test_longdiv
|
from test_longdiv import test_longdiv
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from random_generator import random_generator
|
from random_generator import random_generator
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from timer import timer_sig, timer_var
|
from timer import timer_sig, timer_var
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
from timer import timer_sig, timer_var
|
from timer import timer_sig, timer_var
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
def timer_sig(flag, clock, reset, MAXVAL):
|
def timer_sig(flag, clock, reset, MAXVAL):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl.conversion import verify
|
from myhdl.conversion import verify
|
||||||
|
|
||||||
verify.simulator = "GHDL"
|
verify.simulator = "GHDL"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl.conversion import verify
|
from myhdl.conversion import verify
|
||||||
|
|
||||||
verify.simulator = "cver"
|
verify.simulator = "cver"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl.conversion import verify
|
from myhdl.conversion import verify
|
||||||
|
|
||||||
verify.simulator = "icarus"
|
verify.simulator = "icarus"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
path = os.path
|
path = os.path
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
path = os.path
|
path = os.path
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
path = os.path
|
path = os.path
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
from myhdl import ConversionError
|
from myhdl import ConversionError
|
||||||
from myhdl.conversion._misc import _error
|
from myhdl.conversion._misc import _error
|
||||||
@ -25,7 +26,7 @@ yin = Signal(bool(0))
|
|||||||
def test_bug_1837003():
|
def test_bug_1837003():
|
||||||
try:
|
try:
|
||||||
toVerilog(SubFunction,xout,yout,x,y)
|
toVerilog(SubFunction,xout,yout,x,y)
|
||||||
except ConversionError, e:
|
except ConversionError as e:
|
||||||
assert e.kind == _error.ShadowingVar
|
assert e.kind == _error.ShadowingVar
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
def bug_28(dout, channel):
|
def bug_28(dout, channel):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
def bug_3529686(clr, clk, run, ack, serialout):
|
def bug_3529686(clr, clk, run, ack, serialout):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
from myhdl.conversion import analyze
|
from myhdl.conversion import analyze
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
from myhdl.conversion import verify
|
from myhdl.conversion import verify
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
|
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
|
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
|
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
WIDTH=4
|
WIDTH=4
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
from myhdl.conversion import verify
|
from myhdl.conversion import verify
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
INT_CONDITION_0 = 0
|
INT_CONDITION_0 = 0
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
def gray_counter (clk, reset, enable, gray_count):
|
def gray_counter (clk, reset, enable, gray_count):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
#t_state = enum('WAIT_POSEDGE', 'WAIT_NEGEDGE', encoding='one_hot')
|
#t_state = enum('WAIT_POSEDGE', 'WAIT_NEGEDGE', encoding='one_hot')
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
t_state = enum('WAIT_POSEDGE', 'WAIT_NEGEDGE', encoding='one_hot')
|
t_state = enum('WAIT_POSEDGE', 'WAIT_NEGEDGE', encoding='one_hot')
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
#!/usr/bin/python2.7-32
|
#!/usr/bin/python2.7-32
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""Failed VHDL code example
|
"""Failed VHDL code example
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
from myhdl.conversion import verify
|
from myhdl.conversion import verify
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
from myhdl.conversion import analyze
|
from myhdl.conversion import analyze
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
def issue_9():
|
def issue_9():
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl.conversion import verify, analyze
|
from myhdl.conversion import verify, analyze
|
||||||
|
|
||||||
verify.simulator = analyze.simulator = "vcom"
|
verify.simulator = analyze.simulator = "vcom"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl.conversion import verify, analyze
|
from myhdl.conversion import verify, analyze
|
||||||
|
|
||||||
verify.simulator = analyze.simulator = "vlog"
|
verify.simulator = analyze.simulator = "vlog"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl.conversion import verify, analyze
|
from myhdl.conversion import verify, analyze
|
||||||
|
|
||||||
verify.simulator = analyze.simulator = "GHDL"
|
verify.simulator = analyze.simulator = "GHDL"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl.conversion import verify, analyze
|
from myhdl.conversion import verify, analyze
|
||||||
|
|
||||||
verify.simulator = analyze.simulator = "cver"
|
verify.simulator = analyze.simulator = "cver"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl.conversion import verify, analyze
|
from myhdl.conversion import verify, analyze
|
||||||
|
|
||||||
verify.simulator = analyze.simulator = "icarus"
|
verify.simulator = analyze.simulator = "icarus"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
def bench_SliceSignal():
|
def bench_SliceSignal():
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
def adapter(o_err, i_err, o_spec, i_spec):
|
def adapter(o_err, i_err, o_spec, i_spec):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import os
|
import os
|
||||||
path = os.path
|
path = os.path
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
def map_case4(z, a):
|
def map_case4(z, a):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
def constants(v, u, x, y, z, a):
|
def constants(v, u, x, y, z, a):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import os
|
import os
|
||||||
path = os.path
|
path = os.path
|
||||||
import random
|
import random
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
from myhdl import ConversionError
|
from myhdl import ConversionError
|
||||||
from myhdl.conversion._misc import _error
|
from myhdl.conversion._misc import _error
|
||||||
@ -15,7 +16,7 @@ def test_SigAugmAssignUnsupported():
|
|||||||
a = Signal(intbv(0)[8:])
|
a = Signal(intbv(0)[8:])
|
||||||
try:
|
try:
|
||||||
verify(sigAugmAssignUnsupported, z, a)
|
verify(sigAugmAssignUnsupported, z, a)
|
||||||
except ConversionError, e:
|
except ConversionError as e:
|
||||||
assert e.kind == _error.NotSupported
|
assert e.kind == _error.NotSupported
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
@ -34,7 +35,7 @@ def test_modbvRange():
|
|||||||
b = Signal(intbv(0)[4:])
|
b = Signal(intbv(0)[4:])
|
||||||
try:
|
try:
|
||||||
verify(modbvRange, z, a, b)
|
verify(modbvRange, z, a, b)
|
||||||
except ConversionError, e:
|
except ConversionError as e:
|
||||||
assert e.kind == _error.ModbvRange
|
assert e.kind == _error.ModbvRange
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
@ -51,7 +52,7 @@ def test_modbvSigRange():
|
|||||||
b = Signal(intbv(0)[4:])
|
b = Signal(intbv(0)[4:])
|
||||||
try:
|
try:
|
||||||
verify(modbvSigRange, z, a, b)
|
verify(modbvSigRange, z, a, b)
|
||||||
except ConversionError, e:
|
except ConversionError as e:
|
||||||
assert e.kind == _error.ModbvRange
|
assert e.kind == _error.ModbvRange
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import os
|
import os
|
||||||
path = os.path
|
path = os.path
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import os
|
import os
|
||||||
path = os.path
|
path = os.path
|
||||||
from random import randrange
|
from random import randrange
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
path = os.path
|
path = os.path
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
""" Run the intbv.signed() unit tests. """
|
""" Run the intbv.signed() unit tests. """
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
from myhdl import ConversionError
|
from myhdl import ConversionError
|
||||||
from myhdl.conversion._misc import _error
|
from myhdl.conversion._misc import _error
|
||||||
@ -298,7 +299,7 @@ def test_portInList():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
inst = conversion.analyze(portInList, z, a, b)
|
inst = conversion.analyze(portInList, z, a, b)
|
||||||
except ConversionError, e:
|
except ConversionError as e:
|
||||||
assert e.kind == _error.PortInList
|
assert e.kind == _error.PortInList
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
@ -323,7 +324,7 @@ def test_sigInMultipleLists():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
inst = conversion.analyze(sigInMultipleLists)
|
inst = conversion.analyze(sigInMultipleLists)
|
||||||
except ConversionError, e:
|
except ConversionError as e:
|
||||||
assert e.kind == _error.SignalInMultipleLists
|
assert e.kind == _error.SignalInMultipleLists
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
@ -344,7 +345,7 @@ def test_listAsPort():
|
|||||||
outp = [Signal(intbv(0)[8:0]) for index in range(count)]
|
outp = [Signal(intbv(0)[8:0]) for index in range(count)]
|
||||||
try:
|
try:
|
||||||
inst = conversion.analyze(my_register, clk, inp, outp)
|
inst = conversion.analyze(my_register, clk, inp, outp)
|
||||||
except ConversionError, e:
|
except ConversionError as e:
|
||||||
assert e.kind == _error.ListAsPort
|
assert e.kind == _error.ListAsPort
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import os
|
import os
|
||||||
path = os.path
|
path = os.path
|
||||||
from random import randrange
|
from random import randrange
|
||||||
@ -344,7 +345,7 @@ def testWhileBreakContinueLoop():
|
|||||||
def testForLoopError1():
|
def testForLoopError1():
|
||||||
try:
|
try:
|
||||||
analyze(LoopBench, ForLoopError1)
|
analyze(LoopBench, ForLoopError1)
|
||||||
except ConversionError, e:
|
except ConversionError as e:
|
||||||
assert e.kind == _error.Requirement
|
assert e.kind == _error.Requirement
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
@ -352,7 +353,7 @@ def testForLoopError1():
|
|||||||
def testForLoopError2():
|
def testForLoopError2():
|
||||||
try:
|
try:
|
||||||
analyze(LoopBench, ForLoopError2)
|
analyze(LoopBench, ForLoopError2)
|
||||||
except ConversionError, e:
|
except ConversionError as e:
|
||||||
assert e.kind == _error.Requirement
|
assert e.kind == _error.Requirement
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import sys
|
import sys
|
||||||
from myhdl import *
|
from myhdl import *
|
||||||
from myhdl.conversion import verify
|
from myhdl.conversion import verify
|
||||||
@ -105,7 +106,7 @@ def ObjBench(hObj):
|
|||||||
hdlobj_inst = hObj()
|
hdlobj_inst = hObj()
|
||||||
hdl_inst = hdlobj_inst.method_func(clk, srst, x, y)
|
hdl_inst = hdlobj_inst.method_func(clk, srst, x, y)
|
||||||
else:
|
else:
|
||||||
raise StandardError, "Incorrect hOjb %s" % (type(hObj), str(hObj))
|
raise StandardError("Incorrect hOjb %s" % (type(hObj), str(hObj)))
|
||||||
|
|
||||||
|
|
||||||
@instance
|
@instance
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user