mirror of
https://github.com/myhdl/myhdl.git
synced 2025-01-24 21:52:56 +08:00
preparing alpha
This commit is contained in:
parent
d4fe440519
commit
e2ffd84e97
45
myhdl/_instance.py
Normal file
45
myhdl/_instance.py
Normal file
@ -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 <jan@jandecaluwe.com>"
|
||||
__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()
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user