raise TypeError("Platform must be an instance of nmigen.build.Platform, not {!r}"
.format(platform))
- plan = builder.prepare(self, sim=sim, name_force=name_force)
+ plan = builder.prepare(self, platform, sim=sim, name_force=name_force)
if not do_build:
return plan
- products = plan.execute_local(f"{build_dir}/{__package__}")
+ products = plan.execute_local(f"{build_dir}/{__name__}")
self._populate_ctrl_map(products)
core_src = f"{self.name}/{self.name}.v"
# {{autogenerated}}
{
# General ------------------------------------------------------------------
+ {% if top.config.phy_name == "ECP5DDRPHY" %}
+ "device": "{{platform.device}}-{{platform.speed}}{{platform.package}}",
+ {% endif %}
"cpu": "None",
{% if top.config.phy_name == "A7DDRPHY" %}
"speedgrade": {{top.config.speedgrade}},
{% endif %}
"memtype": "{{top.config.memtype}}",
+ "uart": "rs232",
# PHY ----------------------------------------------------------------------
{% if top.config.phy_name == "A7DDRPHY" %}
def __init__(self):
self.namespace = set()
- def prepare(self, core, *, sim=False, name_force=False):
+ def prepare(self, core, platform, *, sim=False, name_force=False):
"""Prepare a build plan.
Arguments
---------
core : :class:`litedram.Core`
The LiteDRAM instance to be built.
+ platform : :class:`nmigen.build.plat.Platform`
+ Target platform.
sim : bool
Do the build in simulation mode (i.e. by replacing the PHY with a model).
name_force : bool
if not isinstance(core, Core):
raise TypeError("LiteDRAM core must be an instance of litedram.Core, not {!r}"
.format(core))
+ if not isinstance(platform, Platform):
+ raise TypeError("Target platform must be an instance of nmigen.build.plat.Platform, "
+ "not {!r}"
+ .format(platform))
if core.name in self.namespace and not name_force:
raise ValueError(
"emit_commands": emit_commands,
"sim": sim,
"top": core,
+ "platform": platform,
})
plan = BuildPlan(script=f"build_{core.name}")
import unittest
from nmigen_soc.memory import MemoryMap
+from nmigen_boards.ecpix5 import ECPIX585Platform
from litedram.modules import SDRAMModule
def test_prepare(self):
core = litedram.Core(self._cfg)
builder = litedram.Builder()
- builder.prepare(core)
+ builder.prepare(core, ECPIX585Platform())
self.assertEqual(list(builder.namespace), ["core"])
def test_prepare_name_conflict(self):
core = litedram.Core(self._cfg)
builder = litedram.Builder()
- builder.prepare(core)
+ builder.prepare(core, ECPIX585Platform())
with self.assertRaisesRegex(ValueError,
r"LiteDRAM core name 'core' has already been used for a previous build\. Building "
r"this instance may overwrite previous build products\. Passing `name_force=True` "
r"will disable this check"):
- builder.prepare(core)
+ builder.prepare(core, ECPIX585Platform())
def test_prepare_name_force(self):
core = litedram.Core(self._cfg)
builder = litedram.Builder()
- builder.prepare(core)
- builder.prepare(core, name_force=True)
+ builder.prepare(core, ECPIX585Platform())
+ builder.prepare(core, ECPIX585Platform(), name_force=True)
def test_prepare_wrong_core(self):
builder = litedram.Builder()
with self.assertRaisesRegex(TypeError,
r"LiteDRAM core must be an instance of litedram.Core, not 'foo'"):
- builder.prepare("foo")
+ builder.prepare("foo", ECPIX585Platform())
+
+ def test_prepare_wrong_platform(self):
+ core = litedram.Core(self._cfg)
+ builder = litedram.Builder()
+ with self.assertRaisesRegex(TypeError,
+ r"Target platform must be an instance of nmigen.build.plat.Platform, not 'foo'"):
+ builder.prepare(core, "foo")