Commit ca8d681b authored by William D. Jones's avatar William D. Jones Committed by Sébastien Bourdeauducq
Browse files

lattice/platform: Refactor common code out of get_verilog().

parent 7c95ac34
......@@ -7,6 +7,7 @@ import subprocess
import shutil
from migen.fhdl.structure import _Fragment
from migen.fhdl.verilog import DummyAttrTranslate
from migen.build.generic_platform import *
from migen.build import tools
......@@ -77,6 +78,8 @@ def _run_diamond(build_name, source, ver=None):
class LatticeDiamondToolchain:
attr_translate = DummyAttrTranslate()
def build(self, platform, fragment, build_dir="build", build_name="top",
toolchain_path="/opt/Diamond", run=True):
os.makedirs(build_dir, exist_ok=True)
......
......@@ -16,21 +16,16 @@ class LatticePlatform(GenericPlatform):
raise ValueError("Unknown toolchain")
def get_verilog(self, *args, special_overrides=dict(), **kwargs):
so = dict() # No common overrides between ECP and ice40.
if isinstance(self.toolchain, diamond.LatticeDiamondToolchain):
diamond_so = dict(common.diamond_special_overrides)
diamond_so.update(special_overrides)
return GenericPlatform.get_verilog(self, *args,
special_overrides=diamond_so,
**kwargs)
so.update(common.diamond_special_overrides)
elif isinstance(self.toolchain, icestorm.LatticeIceStormToolchain):
icestorm_so = dict(common.icestorm_special_overrides)
icestorm_so.update(special_overrides)
return GenericPlatform.get_verilog(self, *args,
special_overrides=icestorm_so,
attr_translate=self.toolchain.attr_translate,
**kwargs)
so.update(common.icestorm_special_overrides)
else:
raise ValueError("Unknown toolchain")
return GenericPlatform.get_verilog(self, *args, special_overrides=so,
attr_translate=self.toolchain.attr_translate,
**kwargs)
def build(self, *args, **kwargs):
return self.toolchain.build(self, *args, **kwargs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment