2020-08-23 09:40:21 -04:00
|
|
|
#
|
|
|
|
# This file is part of LiteX.
|
|
|
|
#
|
|
|
|
# Copyright (c) 2017-2019 Florent Kermarrec <florent@enjoy-digital.fr>
|
|
|
|
# Copyright (c) 2019 Tim 'mithro' Ansell <me@mith.ro>
|
|
|
|
# SPDX-License-Identifier: BSD-2-Clause
|
2019-06-23 17:31:11 -04:00
|
|
|
|
2019-04-26 18:13:28 -04:00
|
|
|
import subprocess
|
2017-04-24 13:13:17 -04:00
|
|
|
import unittest
|
2017-04-24 13:25:58 -04:00
|
|
|
import os
|
2017-04-24 13:13:17 -04:00
|
|
|
|
2018-02-23 07:38:19 -05:00
|
|
|
from migen import *
|
2017-04-24 13:13:17 -04:00
|
|
|
|
|
|
|
from litex.soc.integration.builder import *
|
|
|
|
|
|
|
|
|
2019-04-26 18:13:28 -04:00
|
|
|
RUNNING_ON_TRAVIS = (os.getenv('TRAVIS', 'false').lower() == 'true')
|
|
|
|
|
|
|
|
|
2017-04-24 13:13:17 -04:00
|
|
|
def build_test(socs):
|
2017-04-24 13:25:58 -04:00
|
|
|
errors = 0
|
2017-04-24 13:13:17 -04:00
|
|
|
for soc in socs:
|
2017-04-24 13:25:58 -04:00
|
|
|
os.system("rm -rf build")
|
2020-05-22 02:42:02 -04:00
|
|
|
builder = Builder(soc, compile_software=False, compile_gateware=False)
|
2017-04-24 13:13:17 -04:00
|
|
|
builder.build()
|
2020-05-22 02:42:02 -04:00
|
|
|
errors += not os.path.isfile("build/{build_name}/gateware/{build_name}.v".format(build_name=soc.build_name))
|
2017-04-24 13:25:58 -04:00
|
|
|
os.system("rm -rf build")
|
|
|
|
return errors
|
2017-04-24 13:13:17 -04:00
|
|
|
|
2020-01-17 07:24:45 -05:00
|
|
|
test_kwargs = {
|
|
|
|
"integrated_rom_size": 0x8000,
|
|
|
|
"max_sdram_size": 0x4000000
|
|
|
|
}
|
2017-04-24 13:13:17 -04:00
|
|
|
|
|
|
|
class TestTargets(unittest.TestCase):
|
2019-04-23 05:38:08 -04:00
|
|
|
# Altera boards
|
2017-04-24 13:13:17 -04:00
|
|
|
def test_de0nano(self):
|
|
|
|
from litex.boards.targets.de0nano import BaseSoC
|
2020-01-15 07:09:03 -05:00
|
|
|
errors = build_test([BaseSoC(**test_kwargs)])
|
2017-04-24 13:25:58 -04:00
|
|
|
self.assertEqual(errors, 0)
|
2017-04-24 13:13:17 -04:00
|
|
|
|
2019-04-23 05:38:08 -04:00
|
|
|
# Xilinx boards
|
|
|
|
# Spartan-6
|
2017-04-24 13:13:17 -04:00
|
|
|
def test_minispartan6(self):
|
|
|
|
from litex.boards.targets.minispartan6 import BaseSoC
|
2020-01-15 07:09:03 -05:00
|
|
|
errors = build_test([BaseSoC(**test_kwargs)])
|
2017-04-24 13:25:58 -04:00
|
|
|
self.assertEqual(errors, 0)
|
2017-04-24 13:13:17 -04:00
|
|
|
|
2019-04-23 05:38:08 -04:00
|
|
|
# Artix-7
|
2018-09-23 19:15:33 -04:00
|
|
|
def test_arty(self):
|
2020-03-20 18:36:29 -04:00
|
|
|
from litex.boards.targets.arty import BaseSoC
|
|
|
|
errors = build_test([
|
|
|
|
BaseSoC(**test_kwargs),
|
|
|
|
BaseSoC(with_ethernet=True, **test_kwargs)
|
|
|
|
])
|
2018-09-23 19:15:33 -04:00
|
|
|
self.assertEqual(errors, 0)
|
|
|
|
|
2019-05-10 12:55:40 -04:00
|
|
|
def test_netv2(self):
|
2020-03-20 18:36:29 -04:00
|
|
|
from litex.boards.targets.netv2 import BaseSoC
|
|
|
|
errors = build_test([
|
|
|
|
BaseSoC(**test_kwargs),
|
|
|
|
BaseSoC(with_ethernet=True, **test_kwargs)
|
|
|
|
])
|
2019-05-10 12:55:40 -04:00
|
|
|
self.assertEqual(errors, 0)
|
|
|
|
|
2018-09-23 19:15:33 -04:00
|
|
|
def test_nexys4ddr(self):
|
|
|
|
from litex.boards.targets.nexys4ddr import BaseSoC
|
2020-01-15 07:09:03 -05:00
|
|
|
errors = build_test([BaseSoC(**test_kwargs)])
|
2018-09-23 19:15:33 -04:00
|
|
|
self.assertEqual(errors, 0)
|
|
|
|
|
2017-04-24 13:13:17 -04:00
|
|
|
def test_nexys_video(self):
|
2020-03-20 18:36:29 -04:00
|
|
|
from litex.boards.targets.nexys_video import BaseSoC
|
|
|
|
errors = build_test([
|
|
|
|
BaseSoC(**test_kwargs),
|
|
|
|
BaseSoC(with_ethernet=True, **test_kwargs)
|
|
|
|
])
|
2018-09-23 19:15:33 -04:00
|
|
|
self.assertEqual(errors, 0)
|
|
|
|
|
2020-06-01 07:58:44 -04:00
|
|
|
def test_arty_symbiflow(self):
|
2020-06-02 07:51:44 -04:00
|
|
|
from litex.boards.targets.arty import BaseSoC
|
2020-06-01 07:58:44 -04:00
|
|
|
errors = build_test([
|
2020-06-02 07:51:44 -04:00
|
|
|
BaseSoC(toolchain="symbiflow", **test_kwargs)
|
2020-06-01 07:58:44 -04:00
|
|
|
])
|
|
|
|
self.assertEqual(errors, 0)
|
|
|
|
|
2019-04-23 05:38:08 -04:00
|
|
|
# Kintex-7
|
2018-09-23 19:15:33 -04:00
|
|
|
def test_genesys2(self):
|
2020-03-20 18:36:29 -04:00
|
|
|
from litex.boards.targets.genesys2 import BaseSoC
|
|
|
|
errors = build_test([
|
|
|
|
BaseSoC(**test_kwargs),
|
|
|
|
BaseSoC(with_ethernet=True, **test_kwargs)
|
|
|
|
])
|
2018-09-23 19:15:33 -04:00
|
|
|
self.assertEqual(errors, 0)
|
|
|
|
|
|
|
|
def test_kc705(self):
|
2020-03-20 18:36:29 -04:00
|
|
|
from litex.boards.targets.kc705 import BaseSoC
|
|
|
|
errors = build_test([
|
|
|
|
BaseSoC(**test_kwargs),
|
|
|
|
BaseSoC(with_ethernet=True, **test_kwargs)
|
|
|
|
])
|
2018-09-23 19:15:33 -04:00
|
|
|
self.assertEqual(errors, 0)
|
|
|
|
|
2019-04-23 05:38:08 -04:00
|
|
|
# Kintex-Ultrascale
|
|
|
|
def test_kcu105(self):
|
|
|
|
from litex.boards.targets.kcu105 import BaseSoC
|
2020-01-15 07:09:03 -05:00
|
|
|
errors = build_test([BaseSoC(**test_kwargs)])
|
2019-04-23 05:38:08 -04:00
|
|
|
self.assertEqual(errors, 0)
|
|
|
|
|
|
|
|
# Lattice boards
|
|
|
|
# ECP5
|
2018-11-17 11:36:57 -05:00
|
|
|
def test_versa_ecp5(self):
|
|
|
|
from litex.boards.targets.versa_ecp5 import BaseSoC
|
2020-01-15 07:09:03 -05:00
|
|
|
errors = build_test([BaseSoC(**test_kwargs)])
|
2018-11-17 11:36:57 -05:00
|
|
|
self.assertEqual(errors, 0)
|
|
|
|
|
2019-05-09 05:48:57 -04:00
|
|
|
def test_ulx3s(self):
|
2018-11-17 11:36:57 -05:00
|
|
|
from litex.boards.targets.ulx3s import BaseSoC
|
2020-01-15 07:09:03 -05:00
|
|
|
errors = build_test([BaseSoC(**test_kwargs)])
|
2018-11-17 11:36:57 -05:00
|
|
|
self.assertEqual(errors, 0)
|
|
|
|
|
2019-04-23 05:38:08 -04:00
|
|
|
# Build simple design for all platforms
|
2018-09-23 20:01:47 -04:00
|
|
|
def test_simple(self):
|
2019-04-23 05:38:08 -04:00
|
|
|
platforms = []
|
|
|
|
# Xilinx
|
2020-06-02 06:18:12 -04:00
|
|
|
platforms += ["minispartan6"] # Spartan6
|
|
|
|
platforms += ["arty", "netv2", "nexys4ddr", "nexys_video"] # Artix7
|
|
|
|
platforms += ["kc705", "genesys2"] # Kintex7
|
|
|
|
platforms += ["kcu105"] # Kintex Ultrascale
|
2019-04-23 05:38:08 -04:00
|
|
|
|
2019-06-02 13:22:09 -04:00
|
|
|
# Altera/Intel
|
2020-06-02 06:18:12 -04:00
|
|
|
platforms += ["de0nano"] # Cyclone4
|
2019-04-23 05:38:08 -04:00
|
|
|
|
|
|
|
# Lattice
|
2020-06-02 06:18:12 -04:00
|
|
|
platforms += ["tinyfpga_bx"] # iCE40
|
|
|
|
platforms += ["machxo3"] # MachXO3
|
|
|
|
platforms += ["versa_ecp5", "ulx3s"] # ECP5
|
2019-04-23 05:38:08 -04:00
|
|
|
|
|
|
|
# Microsemi
|
2020-06-02 06:18:12 -04:00
|
|
|
platforms += ["avalanche"] # PolarFire
|
2019-04-23 05:38:08 -04:00
|
|
|
|
2018-09-23 20:01:47 -04:00
|
|
|
for p in platforms:
|
2019-04-26 18:13:28 -04:00
|
|
|
with self.subTest(platform=p):
|
|
|
|
cmd = """\
|
|
|
|
litex/boards/targets/simple.py litex.boards.platforms.{p} \
|
|
|
|
--cpu-type=vexriscv \
|
|
|
|
--no-compile-software \
|
2020-02-29 05:07:06 -05:00
|
|
|
--uart-name=stub \
|
2019-04-26 18:13:28 -04:00
|
|
|
""".format(p=p)
|
|
|
|
subprocess.check_call(cmd, shell=True)
|
|
|
|
|
2020-05-13 05:04:40 -04:00
|
|
|
def test_z_cpu_none(self): # FIXME: workaround to execute it last.
|
2019-09-30 02:26:38 -04:00
|
|
|
from litex.boards.targets.arty import BaseSoC
|
|
|
|
errors = build_test([BaseSoC(cpu_type=None)])
|
|
|
|
self.assertEqual(errors, 0)
|
|
|
|
|
2019-04-26 18:13:28 -04:00
|
|
|
def run_variants(self, cpu, variants):
|
|
|
|
for v in variants:
|
|
|
|
with self.subTest(cpu=cpu, variant=v):
|
|
|
|
self.run_variant(cpu, v)
|
|
|
|
|
|
|
|
def run_variant(self, cpu, variant):
|
|
|
|
cmd = """\
|
|
|
|
litex/boards/targets/simple.py litex.boards.platforms.arty \
|
|
|
|
--cpu-type={c} \
|
|
|
|
--cpu-variant={v} \
|
|
|
|
--no-compile-software \
|
2020-02-29 05:07:06 -05:00
|
|
|
--uart-name=stub \
|
2019-04-26 18:13:28 -04:00
|
|
|
""".format(c=cpu, v=variant)
|
|
|
|
subprocess.check_output(cmd, shell=True)
|
|
|
|
|
|
|
|
# Build some variants for the arty platform to make sure they work.
|
2019-10-28 05:59:43 -04:00
|
|
|
def test_variants_picorv32(self):
|
|
|
|
self.run_variants("picorv32", ('standard', 'minimal'))
|
|
|
|
|
|
|
|
def test_variants_vexriscv(self):
|
|
|
|
self.run_variants("vexriscv", ('standard', 'minimal', 'lite', 'lite+debug', 'full+debug'))
|
|
|
|
|
|
|
|
@unittest.skipIf(RUNNING_ON_TRAVIS, "No nMigen/Yosys on Travis-CI")
|
|
|
|
def test_variants_minerva(self):
|
|
|
|
self.run_variants("minerva", ('standard',))
|
|
|
|
|
|
|
|
def test_variants_vexriscv(self):
|
2019-04-26 18:13:28 -04:00
|
|
|
cpu_variants = {
|
|
|
|
'vexriscv': ('standard', 'minimal', 'lite', 'lite+debug', 'full+debug'),
|
|
|
|
}
|
|
|
|
for cpu, variants in cpu_variants.items():
|
|
|
|
self.run_variants(cpu, variants)
|
|
|
|
|
|
|
|
@unittest.skipIf(RUNNING_ON_TRAVIS, "No lm32 toolchain on Travis-CI")
|
|
|
|
def test_variants_lm32(self):
|
|
|
|
self.run_variants('lm32', ('standard', 'minimal', 'lite'))
|
|
|
|
|
|
|
|
@unittest.skipIf(RUNNING_ON_TRAVIS, "No or1k toolchain on Travis-CI")
|
2019-09-29 11:12:15 -04:00
|
|
|
def test_variants_mor1kx(self):
|
|
|
|
self.run_variants('mor1kx', ('standard', 'linux'))
|