1
0
mirror of https://github.com/myhdl/myhdl.git synced 2024-12-14 07:44:38 +08:00

Fixed some bugs related to new copy strategy in Signal

--HG--
branch : 0.8-dev
This commit is contained in:
Jan Decaluwe 2011-05-25 10:54:40 +02:00
parent 0b5b88c62b
commit ae63cdb848
3 changed files with 32 additions and 49 deletions

View File

@ -1,7 +1,7 @@
# This file is part of the myhdl library, a Python package for using
# Python as a Hardware Description Language.
#
# Copyright (C) 2003-2008 Jan Decaluwe
# Copyright (C) 2003-2011 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
@ -23,7 +23,7 @@
"""
import warnings
from copy import deepcopy as copy
from copy import deepcopy
from myhdl._Signal import _Signal
from myhdl._Waiter import _SignalWaiter, _SignalTupleWaiter
@ -214,7 +214,7 @@ class _TristateSignal(_ShadowSignal):
self._drivers = []
# construct normally to set type / size info right
_ShadowSignal.__init__(self, val)
self._orival = val # keep for drivers
self._orival = deepcopy(val) # keep for drivers
# reset signal values to None
self._next = self._val = self._init = None
self._waiter = _SignalTupleWaiter(self._resolve())
@ -266,15 +266,15 @@ class _TristateDriver(_Signal):
self._sig = sig
def _set_next(self, val):
if isinstance(val, _Signal):
if isinstance(val, _Signal):
val = val._val
if val is None:
self._next = None
else:
# restore orignal value to cater for intbv handler
self._next = copy(self._sig._orival)
self._setNextVal(val)
_siglist.append(self)
if val is None:
self._next = None
else:
# restore original value to cater for intbv handler
self._next = self._sig._orival
self._setNextVal(val)
_siglist.append(self)
# redefine property because standard inheritance doesn't work for setter/getter functions
next = property(_Signal._get_next, _set_next, None, "'next' access methods")

View File

@ -1,7 +1,7 @@
# This file is part of the myhdl library, a Python package for using
# Python as a Hardware Description Language.
#
# Copyright (C) 2003-2008 Jan Decaluwe
# Copyright (C) 2003-2011 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
@ -128,31 +128,24 @@ class _Signal(object):
if isinstance(val, bool):
self._type = bool
self._setNextVal = self._setNextBool
#self._copyVal2Next = self._assignVal
self._printVcd = self._printVcdBit
self._nrbits = 1
elif isinstance(val, (int, long)):
self._type = (int, long)
self._setNextVal = self._setNextInt
#self._copyVal2Next = self._assignVal
elif isinstance(val, intbv):
self._type = intbv
self._min = val._min
self._max = val._max
self._nrbits = val._nrbits
self._setNextVal = self._setNextIntbv
#self._copyVal2Next = self._copyIntbv
if self._nrbits:
self._printVcd = self._printVcdVec
else:
self._printVcd = self._printVcdHex
# elif val is None:
# self._type = None
# self._setNextVal = self._setNext
else:
self._type = type(val)
self._setNextVal = self._setNextType
#self._copyVal2Next = self._deepcopyVal
if hasattr(val, '_nrbits'):
self._nrbits = val._nrbits
self._eventWaiters = _WaiterList()
@ -167,7 +160,8 @@ class _Signal(object):
del self._eventWaiters[:]
del self._posedgeWaiters[:]
del self._negedgeWaiters[:]
self._next = self._val = self._init
self._val = deepcopy(self._init)
self._next = deepcopy(self._init)
self._name = self._read = self._driven = None
for s in self._slicesigs:
s._clear()
@ -183,7 +177,9 @@ class _Signal(object):
elif not next and val:
waiters.extend(self._negedgeWaiters[:])
del self._negedgeWaiters[:]
if isinstance(val, intbv):
if next is None:
self._val = None
elif isinstance(val, intbv):
self._val._val = next._val
elif isinstance(val, (int, long)):
self._val = next
@ -280,20 +276,7 @@ class _Signal(object):
def _setNextType(self, val):
if not isinstance(val, self._type):
raise TypeError("Expected %s, got %s" % (self._type, type(val)))
self._next = deepcopy(val)
# def _setNext(self, val):
# self._next = val
# copy val to next methods
# def _assignVal(self):
# self._next = self._val
#
# def _copyIntbv(self):
# self._next = type(self._val)(self._val)
#
# def _deepcopyVal(self):
# self._next = deepcopy(self._val)
self._next = deepcopy(val)
# vcd print methods
def _printVcdStr(self):

View File

@ -3,39 +3,39 @@ Test: timer
=====
pypy
----
real 81.13
user 80.89
sys 0.06
real 82.32
user 82.28
sys 0.02
Test: lfsr24
=====
pypy
----
real 105.43
user 105.14
sys 0.04
real 104.06
user 104.00
sys 0.03
Test: randgen
=====
pypy
----
real 89.21
user 88.89
sys 0.11
real 90.33
user 90.05
sys 0.08
Test: longdiv
=====
pypy
----
real 88.25
user 87.98
sys 0.05
real 87.96
user 87.88
sys 0.04
Test: findmax
=====
pypy
----
real 112.74
user 112.44
real 113.69
user 113.62
sys 0.03