migen/genlib/io: add DifferentialOutput and Xilinx implementation
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Thu, 12 Mar 2015 18:30:57 +0000 (19:30 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Thu, 12 Mar 2015 18:30:57 +0000 (19:30 +0100)
mibuild/xilinx/common.py
migen/genlib/io.py

index 45f8f206744d275316fadab44b41f55a570eaf8b..0966d223d9dc03efa537136275afd9345c7f2836 100644 (file)
@@ -92,6 +92,15 @@ class XilinxDifferentialInput:
        def lower(dr):
                return XilinxDifferentialInputImpl(dr.i_p, dr.i_n, dr.o)
 
+class XilinxDifferentialOutputImpl(Module):
+       def __init__(self, i, o_p, o_n):
+               self.specials += Instance("OBUFDS", i_I=i, o_O=o_p, o_OB=o_n)
+
+class XilinxDifferentialOutput:
+       @staticmethod
+       def lower(dr):
+               return XilinxDifferentialOutputImpl(dr.i, dr.o_p, dr.o_n)
+
 class XilinxGenericPlatform(GenericPlatform):
        bitstream_ext = ".bit"
 
@@ -101,6 +110,7 @@ class XilinxGenericPlatform(GenericPlatform):
                        MultiReg:                                       XilinxMultiReg,
                        AsyncResetSynchronizer:         XilinxAsyncResetSynchronizer,
                        DifferentialInput:                      XilinxDifferentialInput,
+                       DifferentialOutput:                     XilinxDifferentialOutput,
                }
                so.update(special_overrides)
                return GenericPlatform.get_verilog(self, *args, special_overrides=so, **kwargs)
index ab0c3beddbdefddd814f2fc7aa70668e3f7891cd..5e27eae35bf179818209c01b1f60b5dcca1a005e 100644 (file)
@@ -17,3 +17,19 @@ class DifferentialInput(Special):
        @staticmethod
        def lower(dr):
                raise NotImplementedError("Attempted to use a differential input, but platform does not support them")
+
+class DifferentialOutput(Special):
+       def __init__(self, i, o_p, o_n):
+               Special.__init__(self)
+               self.i = i
+               self.o_p = o_p
+               self.o_n = o_n
+
+       def iter_expressions(self):
+               yield self, "i", SPECIAL_INPUT
+               yield self, "o_p", SPECIAL_OUTPUT
+               yield self, "o_n", SPECIAL_OUTPUT
+
+       @staticmethod
+       def lower(dr):
+               raise NotImplementedError("Attempted to use a differential output, but platform does not support them")