From 1b050d98ea6a23061a19d2c24e32e9369ca64ed8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alain=20P=C3=A9teut?= Date: Mon, 20 Apr 2015 10:06:24 +0200 Subject: [PATCH] add differential in/out support to mibuild/altera --- mibuild/altera/common.py | 41 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/mibuild/altera/common.py b/mibuild/altera/common.py index 3303e180..86c0cd2b 100644 --- a/mibuild/altera/common.py +++ b/mibuild/altera/common.py @@ -1 +1,40 @@ -altera_special_overrides = {} +from migen.fhdl.std import (Instance, Module) +from migen.genlib.io import (DifferentialInput, DifferentialOutput) + + +__all__ = ['altera_special_overrides'] + + +class QuartusDifferentialInputImpl(Module): + def __init__(self, i_p, i_n, o): + self.specials += Instance("ALT_INBUF_DIFF", + name='ibuf_diff', + i_i=i_p, + i_ibar=i_n, + o_o=o) + + +class QuartusDifferentialInput: + @staticmethod + def lower(dr): + return QuartusDifferentialInputImpl(dr.i_p, dr.i_n, dr.o) + + +class QuartusDifferentialOutputImpl(Module): + def __init__(self, i, o_p, o_n): + self.specials += Instance("ALT_OUTBUF_DIFF", + name='obuf_diff', + i_i=i, + o_o=o_p, + o_obar=o_n) + + +class QuartusDifferentialOutput: + @staticmethod + def lower(dr): + return QuartusDifferentialOutputImpl(dr.i, dr.o_p, dr.o_n) + +altera_special_overrides = { + DifferentialInput: QuartusDifferentialInput, + DifferentialOutput: QuartusDifferentialOutput +} -- 2.30.2