instances: signal override
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Thu, 8 Dec 2011 17:56:14 +0000 (18:56 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Thu, 8 Dec 2011 17:56:14 +0000 (18:56 +0100)
migen/fhdl/structure.py

index 254667aa7735aed2d05d6b90afb241b43fa84ec8..802e1cd2dff571ffeae2e9b87e9b9190b708c23c 100644 (file)
@@ -157,8 +157,15 @@ class Instance:
                        self.name = name
                else:
                        self.name = of
-               self.outs = dict([(x[0], Signal(x[1], self.name + "_" + x[0])) for x in outs])
-               self.ins = dict([(x[0], Signal(x[1], self.name + "_" + x[0])) for x in ins])
+               def process_io(x):
+                       if isinstance(x[1], Signal):
+                               return x # override
+                       elif isinstance(x[1], BV):
+                               return (x[0], Signal(x[1], self.name + "_" + x[0]))
+                       else:
+                               raise TypeError
+               self.outs = dict(map(process_io, outs))
+               self.ins = dict(map(process_io, ins))
                self.parameters = parameters
                self.clkport = clkport
                self.rstport = rstport