From: Sebastien Bourdeauducq Date: Fri, 6 Jan 2012 22:00:23 +0000 (+0100) Subject: record: compatibility check X-Git-Tag: 24jan2021_ls180~2099^2~1099 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3c1dada9cfbb6e3a7eca9123762154a308e15f17;p=litex.git record: compatibility check --- diff --git a/migen/corelogic/record.py b/migen/corelogic/record.py index 5b3e4049..15f3effc 100644 --- a/migen/corelogic/record.py +++ b/migen/corelogic/record.py @@ -19,7 +19,7 @@ class Record: def template(self): l = [] - for key in self.__dict__: + for key in sorted(self.__dict__): e = self.__dict__[key] if isinstance(e, Signal): l.append((key, e.bv)) @@ -59,6 +59,11 @@ class Record: return l return Record(dict_to_list(fields), "subrecord") + def compatible(self, other): + tpl1 = self.template() + tpl2 = other.template() + return tpl1 == tpl2 + def flatten(self): l = [] for key in sorted(self.__dict__): diff --git a/migen/fhdl/structure.py b/migen/fhdl/structure.py index 80956d49..a80d5923 100644 --- a/migen/fhdl/structure.py +++ b/migen/fhdl/structure.py @@ -22,6 +22,9 @@ class BV: r += "s" r += "d" return r + + def __eq__(self, other): + return self.width == other.width and self.signed == other.signed class Value: def __invert__(self):