record: compatibility check
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 6 Jan 2012 22:00:23 +0000 (23:00 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 6 Jan 2012 22:00:23 +0000 (23:00 +0100)
migen/corelogic/record.py
migen/fhdl/structure.py

index 5b3e4049778c3dd4a57240f523de4282a10381ac..15f3effcf4a090fc2c9e1f9d8b9c3bf9efb0b8e9 100644 (file)
@@ -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__):
index 80956d490761804ad1caaf4a50aed9a2a6891d08..a80d592312cb626079b6a3f97ca067fabb11406a 100644 (file)
@@ -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):