mirror of
https://github.com/myhdl/myhdl.git
synced 2024-12-14 07:44:38 +08:00
Doc
This commit is contained in:
parent
f37e32e262
commit
815c1713f8
@ -44,24 +44,40 @@ class _WaiterList(list):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def posedge(sig):
|
def posedge(sig):
|
||||||
|
""" Return a posedge trigger object """
|
||||||
return sig.posedge
|
return sig.posedge
|
||||||
|
|
||||||
def negedge(sig):
|
def negedge(sig):
|
||||||
|
""" Return a negedge trigger object """
|
||||||
return sig.negedge
|
return sig.negedge
|
||||||
|
|
||||||
class Signal(object):
|
class Signal(object):
|
||||||
|
|
||||||
|
""" Signal class.
|
||||||
|
|
||||||
|
Properties:
|
||||||
|
val -- current value (read-only)
|
||||||
|
next -- next value (read-write)
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
__slots__ = ('_next', '_val', '_type',
|
__slots__ = ('_next', '_val', '_type',
|
||||||
'_eventWaiters', '_posedgeWaiters', '_negedgeWaiters',
|
'_eventWaiters', '_posedgeWaiters', '_negedgeWaiters',
|
||||||
)
|
)
|
||||||
|
|
||||||
def __new__(cls, val, delay=0):
|
def __new__(cls, val, delay=0):
|
||||||
|
""" Return a new Signal (default or delay 0) or DelayedSignal """
|
||||||
if delay:
|
if delay:
|
||||||
return object.__new__(DelayedSignal)
|
return object.__new__(DelayedSignal)
|
||||||
else:
|
else:
|
||||||
return object.__new__(cls)
|
return object.__new__(cls)
|
||||||
|
|
||||||
def __init__(self, val):
|
def __init__(self, val):
|
||||||
|
""" Construct a signal.
|
||||||
|
|
||||||
|
val -- initial value
|
||||||
|
|
||||||
|
"""
|
||||||
self._next = self._val = val
|
self._next = self._val = val
|
||||||
if type(val) in (int, long, intbv):
|
if type(val) in (int, long, intbv):
|
||||||
self._type = (int, long, intbv)
|
self._type = (int, long, intbv)
|
||||||
@ -122,6 +138,12 @@ class DelayedSignal(Signal):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, val, delay):
|
def __init__(self, val, delay):
|
||||||
|
""" Construct a new DelayedSignal.
|
||||||
|
|
||||||
|
Automatically invoked through the Signal new method.
|
||||||
|
val -- initial value
|
||||||
|
delay -- non-zero delay value
|
||||||
|
"""
|
||||||
Signal.__init__(self, val)
|
Signal.__init__(self, val)
|
||||||
self._nextZ = val
|
self._nextZ = val
|
||||||
self._delay = delay
|
self._delay = delay
|
||||||
@ -130,14 +152,12 @@ class DelayedSignal(Signal):
|
|||||||
def _update(self):
|
def _update(self):
|
||||||
if self._next != self._nextZ:
|
if self._next != self._nextZ:
|
||||||
self._timeStamp = _simulator._time
|
self._timeStamp = _simulator._time
|
||||||
# print "Update timestamp %s" % now()
|
|
||||||
self._nextZ = self._next
|
self._nextZ = self._next
|
||||||
t = _simulator._time + self._delay
|
t = _simulator._time + self._delay
|
||||||
_schedule((t, _SignalWrap(self, self._next, self._timeStamp)))
|
_schedule((t, _SignalWrap(self, self._next, self._timeStamp)))
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _apply(self, next, timeStamp):
|
def _apply(self, next, timeStamp):
|
||||||
# print "Apply %s %s %s" % (now(), timeStamp, self._timeStamp)
|
|
||||||
if timeStamp == self._timeStamp and self._val != next:
|
if timeStamp == self._timeStamp and self._val != next:
|
||||||
waiters = self._eventWaiters[:]
|
waiters = self._eventWaiters[:]
|
||||||
del self._eventWaiters[:]
|
del self._eventWaiters[:]
|
||||||
|
@ -49,8 +49,10 @@ class TestIntbvConcat(TestCase):
|
|||||||
for base in self.bases:
|
for base in self.bases:
|
||||||
for exts in self.extslist:
|
for exts in self.extslist:
|
||||||
bv = concat(intbv(base), *exts)
|
bv = concat(intbv(base), *exts)
|
||||||
|
# bv2 = concat(int(base, 2), *exts)
|
||||||
ref = long(base + reduce(operator.add, exts), 2)
|
ref = long(base + reduce(operator.add, exts), 2)
|
||||||
self.assertEqual(bv, ref)
|
self.assertEqual(bv, ref)
|
||||||
|
# self.assertEqual(bv2, ref)
|
||||||
|
|
||||||
def testIntbvConcatIntbv(self):
|
def testIntbvConcatIntbv(self):
|
||||||
for base in self.bases:
|
for base in self.bases:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user