diff --git a/myhdl/_instance.py b/myhdl/_instance.py new file mode 100644 index 00000000..218dffdc --- /dev/null +++ b/myhdl/_instance.py @@ -0,0 +1,45 @@ +# This file is part of the myhdl library, a Python package for using +# Python as a Hardware Description Language. +# +# Copyright (C) 2003 Jan Decaluwe +# +# The myhdl library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of the +# License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +""" Module with the always function. """ + +__author__ = "Jan Decaluwe " +__revision__ = "$Revision$" +__date__ = "$Date$" + +from types import FunctionType + +from myhdl import InstanceError +from myhdl._util import _isGenFunc + +class _error: + pass +_error.NrOfArgs = "decorated generator function should not have arguments" +_error.ArgType = "decorated object should be a generator function" + + +def instance(genFunc): + if not isinstance(genFunc, FunctionType): + raise InstanceError(_error.ArgType) + if not _isGenFunc(genFunc): + raise InstanceError(_error.ArgType) + if genFunc.func_code.co_argcount > 0: + raise InstanceError(_error.NrOfArgs) + return genFunc() + diff --git a/myhdl/_intbv.py b/myhdl/_intbv.py index f7cc2baa..00d2609e 100644 --- a/myhdl/_intbv.py +++ b/myhdl/_intbv.py @@ -395,7 +395,7 @@ class intbv(object): return -self._val def __pos__(self): - return +self._val + return self._val def __abs__(self): return abs(self._val)