mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
record: compatibility check
This commit is contained in:
parent
588f1a259e
commit
3c1dada9cf
2 changed files with 9 additions and 1 deletions
|
@ -19,7 +19,7 @@ class Record:
|
||||||
|
|
||||||
def template(self):
|
def template(self):
|
||||||
l = []
|
l = []
|
||||||
for key in self.__dict__:
|
for key in sorted(self.__dict__):
|
||||||
e = self.__dict__[key]
|
e = self.__dict__[key]
|
||||||
if isinstance(e, Signal):
|
if isinstance(e, Signal):
|
||||||
l.append((key, e.bv))
|
l.append((key, e.bv))
|
||||||
|
@ -59,6 +59,11 @@ class Record:
|
||||||
return l
|
return l
|
||||||
return Record(dict_to_list(fields), "subrecord")
|
return Record(dict_to_list(fields), "subrecord")
|
||||||
|
|
||||||
|
def compatible(self, other):
|
||||||
|
tpl1 = self.template()
|
||||||
|
tpl2 = other.template()
|
||||||
|
return tpl1 == tpl2
|
||||||
|
|
||||||
def flatten(self):
|
def flatten(self):
|
||||||
l = []
|
l = []
|
||||||
for key in sorted(self.__dict__):
|
for key in sorted(self.__dict__):
|
||||||
|
|
|
@ -23,6 +23,9 @@ class BV:
|
||||||
r += "d"
|
r += "d"
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return self.width == other.width and self.signed == other.signed
|
||||||
|
|
||||||
class Value:
|
class Value:
|
||||||
def __invert__(self):
|
def __invert__(self):
|
||||||
return _Operator("~", [self])
|
return _Operator("~", [self])
|
||||||
|
|
Loading…
Reference in a new issue