mirror of
https://github.com/myhdl/myhdl.git
synced 2024-12-14 07:44:38 +08:00
Solved issue #9 by introducing rich comparions in the Signal class
This commit is contained in:
parent
8fa8387cf1
commit
17eae3d75b
@ -474,9 +474,20 @@ class _Signal(object):
|
||||
return int(self._val)
|
||||
|
||||
|
||||
# comparison
|
||||
def __cmp__(self, other):
|
||||
return cmp(self._val, other)
|
||||
# comparisons
|
||||
def __eq__(self, other):
|
||||
return self.val == other
|
||||
def __ne__(self, other):
|
||||
return self.val != other
|
||||
def __lt__(self, other):
|
||||
return self.val < other
|
||||
def __le__(self, other):
|
||||
return self.val <= other
|
||||
def __gt__(self, other):
|
||||
return self.val > other
|
||||
def __ge__(self, other):
|
||||
return self.val >= other
|
||||
|
||||
|
||||
# method lookup delegation
|
||||
def __getattr__(self, attr):
|
||||
|
14
myhdl/test/bugs/test_issue_9.py
Normal file
14
myhdl/test/bugs/test_issue_9.py
Normal file
@ -0,0 +1,14 @@
|
||||
from myhdl import *
|
||||
|
||||
def issue_9():
|
||||
|
||||
t_State = enum('foo', 'bar')
|
||||
|
||||
assert (Signal(t_State.foo) == Signal(t_State.bar)) == False
|
||||
assert (Signal(t_State.foo) != Signal(t_State.bar)) == True
|
||||
assert (Signal(t_State.foo) == Signal(t_State.foo)) == True
|
||||
assert (Signal(t_State.foo) != Signal(t_State.foo)) == False
|
||||
|
||||
|
||||
def test_issue_9():
|
||||
issue_9()
|
Loading…
x
Reference in New Issue
Block a user