|
23 | 23 | "Initial",
|
24 | 24 | "Statement", "Switch",
|
25 | 25 | "Property", "Assign", "Assert", "Assume", "Cover",
|
26 |
| - "ValueKey", "ValueDict", "ValueSet", "SignalKey", "SignalDict", "SignalSet", |
| 26 | + "SignalKey", "SignalDict", "SignalSet", |
27 | 27 | ]
|
28 | 28 |
|
29 | 29 |
|
@@ -1954,110 +1954,6 @@ def __repr__(self):
|
1954 | 1954 | ", ".join(repr(x) for x in self))
|
1955 | 1955 |
|
1956 | 1956 |
|
1957 |
| -class ValueKey: |
1958 |
| - def __init__(self, value): |
1959 |
| - self.value = Value.cast(value) |
1960 |
| - if isinstance(self.value, Const): |
1961 |
| - self._hash = hash(self.value.value) |
1962 |
| - elif isinstance(self.value, (Signal, AnyValue)): |
1963 |
| - self._hash = hash(self.value.duid) |
1964 |
| - elif isinstance(self.value, (ClockSignal, ResetSignal)): |
1965 |
| - self._hash = hash(self.value.domain) |
1966 |
| - elif isinstance(self.value, Operator): |
1967 |
| - self._hash = hash((self.value.operator, |
1968 |
| - tuple(ValueKey(o) for o in self.value.operands))) |
1969 |
| - elif isinstance(self.value, Slice): |
1970 |
| - self._hash = hash((ValueKey(self.value.value), self.value.start, self.value.stop)) |
1971 |
| - elif isinstance(self.value, Part): |
1972 |
| - self._hash = hash((ValueKey(self.value.value), ValueKey(self.value.offset), |
1973 |
| - self.value.width, self.value.stride)) |
1974 |
| - elif isinstance(self.value, Cat): |
1975 |
| - self._hash = hash(tuple(ValueKey(o) for o in self.value.parts)) |
1976 |
| - elif isinstance(self.value, ArrayProxy): |
1977 |
| - self._hash = hash((ValueKey(self.value.index), |
1978 |
| - tuple(ValueKey(e) for e in self.value._iter_as_values()))) |
1979 |
| - elif isinstance(self.value, Initial): |
1980 |
| - self._hash = 0 |
1981 |
| - else: # :nocov: |
1982 |
| - raise TypeError("Object {!r} cannot be used as a key in value collections" |
1983 |
| - .format(self.value)) |
1984 |
| - |
1985 |
| - def __hash__(self): |
1986 |
| - return self._hash |
1987 |
| - |
1988 |
| - def __eq__(self, other): |
1989 |
| - if type(other) is not ValueKey: |
1990 |
| - return False |
1991 |
| - if type(self.value) is not type(other.value): |
1992 |
| - return False |
1993 |
| - |
1994 |
| - if isinstance(self.value, Const): |
1995 |
| - return self.value.value == other.value.value and self.value.width == other.value.width |
1996 |
| - elif isinstance(self.value, (Signal, AnyValue)): |
1997 |
| - return self.value is other.value |
1998 |
| - elif isinstance(self.value, (ClockSignal, ResetSignal)): |
1999 |
| - return self.value.domain == other.value.domain |
2000 |
| - elif isinstance(self.value, Operator): |
2001 |
| - return (self.value.operator == other.value.operator and |
2002 |
| - len(self.value.operands) == len(other.value.operands) and |
2003 |
| - all(ValueKey(a) == ValueKey(b) |
2004 |
| - for a, b in zip(self.value.operands, other.value.operands))) |
2005 |
| - elif isinstance(self.value, Slice): |
2006 |
| - return (ValueKey(self.value.value) == ValueKey(other.value.value) and |
2007 |
| - self.value.start == other.value.start and |
2008 |
| - self.value.stop == other.value.stop) |
2009 |
| - elif isinstance(self.value, Part): |
2010 |
| - return (ValueKey(self.value.value) == ValueKey(other.value.value) and |
2011 |
| - ValueKey(self.value.offset) == ValueKey(other.value.offset) and |
2012 |
| - self.value.width == other.value.width and |
2013 |
| - self.value.stride == other.value.stride) |
2014 |
| - elif isinstance(self.value, Cat): |
2015 |
| - return (len(self.value.parts) == len(other.value.parts) and |
2016 |
| - all(ValueKey(a) == ValueKey(b) |
2017 |
| - for a, b in zip(self.value.parts, other.value.parts))) |
2018 |
| - elif isinstance(self.value, ArrayProxy): |
2019 |
| - return (ValueKey(self.value.index) == ValueKey(other.value.index) and |
2020 |
| - len(self.value.elems) == len(other.value.elems) and |
2021 |
| - all(ValueKey(a) == ValueKey(b) |
2022 |
| - for a, b in zip(self.value._iter_as_values(), |
2023 |
| - other.value._iter_as_values()))) |
2024 |
| - elif isinstance(self.value, Initial): |
2025 |
| - return True |
2026 |
| - else: # :nocov: |
2027 |
| - raise TypeError("Object {!r} cannot be used as a key in value collections" |
2028 |
| - .format(self.value)) |
2029 |
| - |
2030 |
| - def __lt__(self, other): |
2031 |
| - if not isinstance(other, ValueKey): |
2032 |
| - return False |
2033 |
| - if type(self.value) != type(other.value): |
2034 |
| - return False |
2035 |
| - |
2036 |
| - if isinstance(self.value, Const): |
2037 |
| - return self.value < other.value |
2038 |
| - elif isinstance(self.value, (Signal, AnyValue)): |
2039 |
| - return self.value.duid < other.value.duid |
2040 |
| - elif isinstance(self.value, Slice): |
2041 |
| - return (ValueKey(self.value.value) < ValueKey(other.value.value) and |
2042 |
| - self.value.start < other.value.start and |
2043 |
| - self.value.end < other.value.end) |
2044 |
| - else: # :nocov: |
2045 |
| - raise TypeError("Object {!r} cannot be used as a key in value collections") |
2046 |
| - |
2047 |
| - def __repr__(self): |
2048 |
| - return f"<{__name__}.ValueKey {self.value!r}>" |
2049 |
| - |
2050 |
| - |
2051 |
| -class ValueDict(_MappedKeyDict): |
2052 |
| - _map_key = ValueKey |
2053 |
| - _unmap_key = lambda self, key: key.value |
2054 |
| - |
2055 |
| - |
2056 |
| -class ValueSet(_MappedKeySet): |
2057 |
| - _map_key = ValueKey |
2058 |
| - _unmap_key = lambda self, key: key.value |
2059 |
| - |
2060 |
| - |
2061 | 1957 | class SignalKey:
|
2062 | 1958 | def __init__(self, signal):
|
2063 | 1959 | self.signal = signal
|
|
0 commit comments