Skip to content

Commit

Permalink
migen/genlib: add io.py to define generic I/O specials to be lowered …
Browse files Browse the repository at this point in the history
…by mibuild
  • Loading branch information
enjoy-digital committed Mar 12, 2015
1 parent 00e8616 commit c8ba8cd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
13 changes: 12 additions & 1 deletion mibuild/xilinx/common.py
Expand Up @@ -5,6 +5,7 @@
from migen.fhdl.specials import SynthesisDirective
from migen.genlib.cdc import *
from migen.genlib.resetsync import AsyncResetSynchronizer
from migen.genlib.io import *
from mibuild.generic_platform import GenericPlatform
from mibuild import tools

Expand Down Expand Up @@ -82,14 +83,24 @@ class XilinxAsyncResetSynchronizer:
def lower(dr):
return XilinxAsyncResetSynchronizerImpl(dr.cd, dr.async_reset)

class XilinxDifferentialInputImpl(Module):
def __init__(self, i_p, i_n, o):
self.specials += Instance("IBUFDS", i_I=i_p, i_IB=i_n, o_O=o)

class XilinxDifferentialInput:
@staticmethod
def lower(dr):
return XilinxDifferentialInputImpl(dr.i_p, dr.i_n, dr.o)

class XilinxGenericPlatform(GenericPlatform):
bitstream_ext = ".bit"

def get_verilog(self, *args, special_overrides=dict(), **kwargs):
so = {
NoRetiming: XilinxNoRetiming,
MultiReg: XilinxMultiReg,
AsyncResetSynchronizer: XilinxAsyncResetSynchronizer
AsyncResetSynchronizer: XilinxAsyncResetSynchronizer,
DifferentialInput: XilinxDifferentialInput,
}
so.update(special_overrides)
return GenericPlatform.get_verilog(self, *args, special_overrides=so, **kwargs)
Expand Down
19 changes: 19 additions & 0 deletions migen/genlib/io.py
@@ -0,0 +1,19 @@
from migen.fhdl.std import *
from migen.fhdl.specials import Special
from migen.fhdl.tools import list_signals

class DifferentialInput(Special):
def __init__(self, i_p, i_n, o):
Special.__init__(self)
self.i_p = i_p
self.i_n = i_n
self.o = o

def iter_expressions(self):
yield self, "i_p", SPECIAL_INPUT
yield self, "i_n", SPECIAL_INPUT
yield self, "o", SPECIAL_OUTPUT

@staticmethod
def lower(dr):
raise NotImplementedError("Attempted to use a reset synchronizer, but platform does not support them")

This comment has been minimized.

Copy link
@jordens

jordens Mar 12, 2015

Member

copy paste error

1 comment on commit c8ba8cd

@enjoy-digital
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! fixed.

Please sign in to comment.