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
|
||||
|
||||
|
||||
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):
|
||||
if sys.platform == "win32" or sys.platform == "cygwin":
|
||||
if sys.platform in ("win32", "cygwin"):
|
||||
script_ext = ".bat"
|
||||
shell = ["cmd", "/c"]
|
||||
build_script_contents = "@echo off\nrem Autogenerated by LiteX\n"
|
||||
fail_stmt = " || exit /b"
|
||||
else:
|
||||
script_ext = ".sh"
|
||||
shell = ["bash"]
|
||||
build_script_contents = "# Autogenerated by LiteX\nset -e\n"
|
||||
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
|
||||
tools.write_to_file(build_script_file, build_script_contents,
|
||||
force_unix=False)
|
||||
command = shell + [build_script_file]
|
||||
r = subprocess.call(command)
|
||||
if r != 0:
|
||||
return build_script_file
|
||||
|
||||
|
||||
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")
|
||||
|
||||
|
||||
|
@ -88,7 +93,7 @@ class LatticeIceStormToolchain:
|
|||
|
||||
special_overrides = common.icestorm_special_overrides
|
||||
|
||||
def __init__(self, use_nextpnr=False):
|
||||
def __init__(self):
|
||||
# Variables within replacement fields should be backend-aware and
|
||||
# update their syntax accordingly. Currently, only {pnr_pkg_opts}
|
||||
# needs this functionality.
|
||||
|
@ -122,7 +127,7 @@ class LatticeIceStormToolchain:
|
|||
|
||||
# platform.device should be of the form "ice40-{lp384, hx1k, etc}-{tq144, etc}"
|
||||
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)
|
||||
cwd = os.getcwd()
|
||||
os.chdir(build_dir)
|
||||
|
@ -149,7 +154,6 @@ class LatticeIceStormToolchain:
|
|||
|
||||
tools.write_to_file(build_name + ".pcf",
|
||||
_build_pcf(named_sc, named_pc))
|
||||
if run:
|
||||
(family, series_size, package) = self.parse_device_string(platform.device)
|
||||
if use_nextpnr:
|
||||
pnr_pkg_opts = "--" + series_size + " --package " + package
|
||||
|
@ -164,9 +168,12 @@ class LatticeIceStormToolchain:
|
|||
chosen_build_template = self.nextpnr_build_template
|
||||
else:
|
||||
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)
|
||||
|
||||
if run:
|
||||
_run_script(script)
|
||||
|
||||
os.chdir(cwd)
|
||||
|
||||
return v_output.ns
|
||||
|
|
Loading…
Reference in New Issue