+import os
+from distutils.version import StrictVersion
+
from migen.fhdl.std import *
+from migen.fhdl.specials import SynthesisDirective
+from migen.genlib.cdc import *
+from mibuild.generic_platform import GenericPlatform
+from mibuild import tools
+
+def settings(path, ver=None, sub=None):
+ vers = list(tools.versions(path))
+ if ver is None:
+ ver = max(vers)
+ else:
+ ver = StrictVersion(ver)
+ assert ver in vers
+
+ full = os.path.join(path, str(ver))
+ if sub:
+ full = os.path.join(full, sub)
+
+ search = [64, 32]
+ if tools.arch_bits() == 32:
+ search.reverse()
+
+ for b in search:
+ settings = os.path.join(full, "settings{0}.sh".format(b))
+ if os.path.exists(settings):
+ return settings
+
+ raise ValueError("no settings file found")
class CRG_DS(Module):
def __init__(self, platform, clk_name, rst_name, rst_invert=False):
else:
self.comb += self.cd_sys.rst.eq(platform.request(rst_name))
+class XilinxNoRetimingImpl(Module):
+ def __init__(self, reg):
+ self.specials += SynthesisDirective("attribute register_balancing of {r} is no", r=reg)
+
+class XilinxNoRetiming:
+ @staticmethod
+ def lower(dr):
+ return XilinxNoRetimingImpl(dr.reg)
+
+class XilinxMultiRegImpl(MultiRegImpl):
+ def __init__(self, *args, **kwargs):
+ MultiRegImpl.__init__(self, *args, **kwargs)
+ self.specials += [SynthesisDirective("attribute shreg_extract of {r} is no", r=r)
+ for r in self.regs]
+
+class XilinxMultiReg:
+ @staticmethod
+ def lower(dr):
+ return XilinxMultiRegImpl(dr.i, dr.o, dr.odomain, dr.n)
+
+class XilinxGenericPlatform(GenericPlatform):
+ bitstream_ext = ".bit"
+
+ def get_verilog(self, *args, special_overrides=dict(), **kwargs):
+ so = {
+ NoRetiming: XilinxNoRetiming,
+ MultiReg: XilinxMultiReg
+ }
+ so.update(special_overrides)
+ return GenericPlatform.get_verilog(self, *args, special_overrides=so, **kwargs)
+
+ def get_edif(self, fragment, **kwargs):
+ return GenericPlatform.get_edif(self, fragment, "UNISIMS", "Xilinx", self.device, **kwargs)
import os, subprocess, sys
from migen.fhdl.std import *
-from migen.fhdl.specials import SynthesisDirective
-from migen.genlib.cdc import *
from migen.fhdl.structure import _Fragment
from mibuild.generic_platform import *
-from mibuild import tools, xilinx_tools
+from mibuild import tools, xilinx_common
def _format_constraint(c):
if isinstance(c, Pins):
source = False
build_script_contents = "# Autogenerated by mibuild\nset -e\n"
if source:
- settings = xilinx_tools.settings(ise_path, ver, "ISE_DS")
+ settings = xilinx_common.settings(ise_path, ver, "ISE_DS")
build_script_contents += "source " + settings + "\n"
if mode == "edif":
ext = "edif"
if r != 0:
raise OSError("Subprocess failed")
-class XilinxNoRetimingImpl(Module):
- def __init__(self, reg):
- self.specials += SynthesisDirective("attribute register_balancing of {r} is no", r=reg)
-
-class XilinxNoRetiming:
- @staticmethod
- def lower(dr):
- return XilinxNoRetimingImpl(dr.reg)
-
-class XilinxMultiRegImpl(MultiRegImpl):
- def __init__(self, *args, **kwargs):
- MultiRegImpl.__init__(self, *args, **kwargs)
- self.specials += [SynthesisDirective("attribute shreg_extract of {r} is no", r=r)
- for r in self.regs]
-
-class XilinxMultiReg:
- @staticmethod
- def lower(dr):
- return XilinxMultiRegImpl(dr.i, dr.o, dr.odomain, dr.n)
-
-class XilinxISEPlatform(GenericPlatform):
- bitstream_ext = ".bit"
+class XilinxISEPlatform(xilinx_common.XilinxGenericPlatform):
xst_opt = """-ifmt MIXED
-opt_mode SPEED
-register_balancing yes"""
ngdbuild_opt = ""
bitgen_opt = "-g LCK_cycle:6 -g Binary:Yes -w"
ise_commands = ""
- def get_verilog(self, *args, special_overrides=dict(), **kwargs):
- so = {
- NoRetiming: XilinxNoRetiming,
- MultiReg: XilinxMultiReg
- }
- so.update(special_overrides)
- return GenericPlatform.get_verilog(self, *args, special_overrides=so, **kwargs)
-
- def get_edif(self, fragment, **kwargs):
- return GenericPlatform.get_edif(self, fragment, "UNISIMS", "Xilinx", self.device, **kwargs)
def build(self, fragment, build_dir="build", build_name="top",
ise_path="/opt/Xilinx", source=True, run=True, mode="xst"):
+++ /dev/null
-import os
-from distutils.version import StrictVersion
-
-from mibuild import tools
-
-def settings(path, ver=None, sub=None):
- vers = list(tools.versions(path))
- if ver is None:
- ver = max(vers)
- else:
- ver = StrictVersion(ver)
- assert ver in vers
-
- full = os.path.join(path, str(ver))
- if sub:
- full = os.path.join(full, sub)
-
- search = [64, 32]
- if tools.arch_bits() == 32:
- search.reverse()
-
- for b in search:
- settings = os.path.join(full, "settings{0}.sh".format(b))
- if os.path.exists(settings):
- return settings
-
- raise ValueError("no settings file found")
from migen.fhdl.std import *
from migen.fhdl.structure import _Fragment
-
from mibuild.generic_platform import *
-from mibuild import tools, xilinx_tools
+
+from mibuild import tools, xilinx_common
def _format_constraint(c):
if isinstance(c, Pins):
source = False
build_script_contents = "# Autogenerated by mibuild\nset -e\n"
if source:
- settings = xilinx_tools.settings(vivado_path, ver)
+ settings = xilinx_common.settings(vivado_path, ver)
build_script_contents += "source " + settings + "\n"
build_script_contents += "vivado -mode tcl -source " + build_name + ".tcl\n"
build_script_file = "build_" + build_name + ".sh"
if r != 0:
raise OSError("Subprocess failed")
-class XilinxVivadoPlatform(GenericPlatform):
- bitstream_ext = ".bit"
- def get_verilog(self, *args, special_overrides=dict(), **kwargs):
- so = {}
- so.update(special_overrides)
- return GenericPlatform.get_verilog(self, *args, special_overrides=so, **kwargs)
-
+class XilinxVivadoPlatform(xilinx_common.XilinxGenericPlatform):
def build(self, fragment, build_dir="build", build_name="top",
vivado_path="/opt/Xilinx/Vivado", source=True, run=True):
tools.mkdir_noerror(build_dir)