Merge pull request #101 from cr1901/icestorm-migen-pull
Icestorm Improvements
This commit is contained in:
commit
537b0e9058
|
@ -33,16 +33,14 @@ def _build_pcf(named_sc, named_pc):
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def _run_icestorm(source, build_template, build_name, pnr_pkg_opts,
|
def _build_script(source, build_template, build_name, pnr_pkg_opts,
|
||||||
icetime_pkg_opts, freq_constraint):
|
icetime_pkg_opts, freq_constraint):
|
||||||
if sys.platform == "win32" or sys.platform == "cygwin":
|
if sys.platform in ("win32", "cygwin"):
|
||||||
script_ext = ".bat"
|
script_ext = ".bat"
|
||||||
shell = ["cmd", "/c"]
|
|
||||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX\n"
|
build_script_contents = "@echo off\nrem Autogenerated by LiteX\n"
|
||||||
fail_stmt = " || exit /b"
|
fail_stmt = " || exit /b"
|
||||||
else:
|
else:
|
||||||
script_ext = ".sh"
|
script_ext = ".sh"
|
||||||
shell = ["bash"]
|
|
||||||
build_script_contents = "# Autogenerated by LiteX\nset -e\n"
|
build_script_contents = "# Autogenerated by LiteX\nset -e\n"
|
||||||
fail_stmt = ""
|
fail_stmt = ""
|
||||||
|
|
||||||
|
@ -57,9 +55,16 @@ def _run_icestorm(source, build_template, build_name, pnr_pkg_opts,
|
||||||
build_script_file = "build_" + build_name + script_ext
|
build_script_file = "build_" + build_name + script_ext
|
||||||
tools.write_to_file(build_script_file, build_script_contents,
|
tools.write_to_file(build_script_file, build_script_contents,
|
||||||
force_unix=False)
|
force_unix=False)
|
||||||
command = shell + [build_script_file]
|
return build_script_file
|
||||||
r = subprocess.call(command)
|
|
||||||
if r != 0:
|
|
||||||
|
def _run_script(script):
|
||||||
|
if sys.platform in ("win32", "cygwin"):
|
||||||
|
shell = ["cmd", "/c"]
|
||||||
|
else:
|
||||||
|
shell = ["bash"]
|
||||||
|
|
||||||
|
if subprocess.call(shell + [script]) != 0:
|
||||||
raise OSError("Subprocess failed")
|
raise OSError("Subprocess failed")
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,7 +93,7 @@ class LatticeIceStormToolchain:
|
||||||
|
|
||||||
special_overrides = common.icestorm_special_overrides
|
special_overrides = common.icestorm_special_overrides
|
||||||
|
|
||||||
def __init__(self, use_nextpnr=False):
|
def __init__(self):
|
||||||
# Variables within replacement fields should be backend-aware and
|
# Variables within replacement fields should be backend-aware and
|
||||||
# update their syntax accordingly. Currently, only {pnr_pkg_opts}
|
# update their syntax accordingly. Currently, only {pnr_pkg_opts}
|
||||||
# needs this functionality.
|
# needs this functionality.
|
||||||
|
@ -122,7 +127,7 @@ class LatticeIceStormToolchain:
|
||||||
|
|
||||||
# platform.device should be of the form "ice40-{lp384, hx1k, etc}-{tq144, etc}"
|
# platform.device should be of the form "ice40-{lp384, hx1k, etc}-{tq144, etc}"
|
||||||
def build(self, platform, fragment, build_dir="build", build_name="top",
|
def build(self, platform, fragment, build_dir="build", build_name="top",
|
||||||
toolchain_path=None, use_nextpnr=False, run=True):
|
toolchain_path=None, use_nextpnr=True, run=True):
|
||||||
os.makedirs(build_dir, exist_ok=True)
|
os.makedirs(build_dir, exist_ok=True)
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
os.chdir(build_dir)
|
os.chdir(build_dir)
|
||||||
|
@ -149,23 +154,25 @@ class LatticeIceStormToolchain:
|
||||||
|
|
||||||
tools.write_to_file(build_name + ".pcf",
|
tools.write_to_file(build_name + ".pcf",
|
||||||
_build_pcf(named_sc, named_pc))
|
_build_pcf(named_sc, named_pc))
|
||||||
if run:
|
(family, series_size, package) = self.parse_device_string(platform.device)
|
||||||
(family, series_size, package) = self.parse_device_string(platform.device)
|
if use_nextpnr:
|
||||||
if use_nextpnr:
|
pnr_pkg_opts = "--" + series_size + " --package " + package
|
||||||
pnr_pkg_opts = "--" + series_size + " --package " + package
|
else:
|
||||||
else:
|
pnr_pkg_opts = "-d " + self.get_size_string(series_size) + \
|
||||||
pnr_pkg_opts = "-d " + self.get_size_string(series_size) + \
|
" -P " + package
|
||||||
" -P " + package
|
icetime_pkg_opts = "-P " + package + " -d " + series_size
|
||||||
icetime_pkg_opts = "-P " + package + " -d " + series_size
|
freq_constraint = str(max(self.freq_constraints.values(),
|
||||||
freq_constraint = str(max(self.freq_constraints.values(),
|
default=0.0))
|
||||||
default=0.0))
|
|
||||||
|
|
||||||
if use_nextpnr:
|
if use_nextpnr:
|
||||||
chosen_build_template = self.nextpnr_build_template
|
chosen_build_template = self.nextpnr_build_template
|
||||||
else:
|
else:
|
||||||
chosen_build_template = self.build_template
|
chosen_build_template = self.build_template
|
||||||
_run_icestorm(False, chosen_build_template, build_name,
|
script = _build_script(False, chosen_build_template, build_name,
|
||||||
pnr_pkg_opts, icetime_pkg_opts, freq_constraint)
|
pnr_pkg_opts, icetime_pkg_opts, freq_constraint)
|
||||||
|
|
||||||
|
if run:
|
||||||
|
_run_script(script)
|
||||||
|
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue