Browse files

record: compatibility check

  • Loading branch information...
1 parent 588f1a2 commit 3c1dada9cfbb6e3a7eca9123762154a308e15f17 @sbourdeauducq sbourdeauducq committed Jan 6, 2012
Showing with 9 additions and 1 deletion.
  1. +6 −1 migen/corelogic/record.py
  2. +3 −0 migen/fhdl/structure.py
View
7 migen/corelogic/record.py
@@ -19,7 +19,7 @@ def __init__(self, template, name=None):
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 @@ def dict_to_list(d):
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__):
View
3 migen/fhdl/structure.py
@@ -22,6 +22,9 @@ def __repr__(self):
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):

0 comments on commit 3c1dada

Please sign in to comment.