From 3c1dada9cfbb6e3a7eca9123762154a308e15f17 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 6 Jan 2012 23:00:23 +0100 Subject: [PATCH] record: compatibility check --- migen/corelogic/record.py | 7 ++++++- migen/fhdl/structure.py | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) 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): -- 2.30.2