1 # This file is Copyright (c) 2017-2019 Florent Kermarrec <florent@enjoy-digital.fr>
2 # This file is Copyright (c) 2019 Tim 'mithro' Ansell <me@mith.ro>
11 from litex
.soc
.integration
.builder
import *
14 RUNNING_ON_TRAVIS
= (os
.getenv('TRAVIS', 'false').lower() == 'true')
20 os
.system("rm -rf build")
21 builder
= Builder(soc
, compile_software
=False, compile_gateware
=False)
23 errors
+= not os
.path
.isfile("build/{build_name}/gateware/{build_name}.v".format(build_name
=soc
.build_name
))
24 os
.system("rm -rf build")
28 "integrated_rom_size": 0x8000,
29 "max_sdram_size": 0x4000000
32 class TestTargets(unittest
.TestCase
):
34 def test_de0nano(self
):
35 from litex
.boards
.targets
.de0nano
import BaseSoC
36 errors
= build_test([BaseSoC(**test_kwargs
)])
37 self
.assertEqual(errors
, 0)
41 def test_minispartan6(self
):
42 from litex
.boards
.targets
.minispartan6
import BaseSoC
43 errors
= build_test([BaseSoC(**test_kwargs
)])
44 self
.assertEqual(errors
, 0)
48 from litex
.boards
.targets
.arty
import BaseSoC
50 BaseSoC(**test_kwargs
),
51 BaseSoC(with_ethernet
=True, **test_kwargs
)
53 self
.assertEqual(errors
, 0)
56 from litex
.boards
.targets
.netv2
import BaseSoC
58 BaseSoC(**test_kwargs
),
59 BaseSoC(with_ethernet
=True, **test_kwargs
)
61 self
.assertEqual(errors
, 0)
63 def test_nexys4ddr(self
):
64 from litex
.boards
.targets
.nexys4ddr
import BaseSoC
65 errors
= build_test([BaseSoC(**test_kwargs
)])
66 self
.assertEqual(errors
, 0)
68 def test_nexys_video(self
):
69 from litex
.boards
.targets
.nexys_video
import BaseSoC
71 BaseSoC(**test_kwargs
),
72 BaseSoC(with_ethernet
=True, **test_kwargs
)
74 self
.assertEqual(errors
, 0)
76 def test_arty_symbiflow(self
):
77 from litex
.boards
.targets
.arty
import BaseSoC
79 BaseSoC(toolchain
="symbiflow", **test_kwargs
)
81 self
.assertEqual(errors
, 0)
84 def test_genesys2(self
):
85 from litex
.boards
.targets
.genesys2
import BaseSoC
87 BaseSoC(**test_kwargs
),
88 BaseSoC(with_ethernet
=True, **test_kwargs
)
90 self
.assertEqual(errors
, 0)
93 from litex
.boards
.targets
.kc705
import BaseSoC
95 BaseSoC(**test_kwargs
),
96 BaseSoC(with_ethernet
=True, **test_kwargs
)
98 self
.assertEqual(errors
, 0)
101 def test_kcu105(self
):
102 from litex
.boards
.targets
.kcu105
import BaseSoC
103 errors
= build_test([BaseSoC(**test_kwargs
)])
104 self
.assertEqual(errors
, 0)
108 def test_versa_ecp5(self
):
109 from litex
.boards
.targets
.versa_ecp5
import BaseSoC
110 errors
= build_test([BaseSoC(**test_kwargs
)])
111 self
.assertEqual(errors
, 0)
113 def test_ulx3s(self
):
114 from litex
.boards
.targets
.ulx3s
import BaseSoC
115 errors
= build_test([BaseSoC(**test_kwargs
)])
116 self
.assertEqual(errors
, 0)
118 # Build simple design for all platforms
119 def test_simple(self
):
122 platforms
+= ["minispartan6"] # Spartan6
123 platforms
+= ["arty", "netv2", "nexys4ddr", "nexys_video"] # Artix7
124 platforms
+= ["kc705", "genesys2"] # Kintex7
125 platforms
+= ["kcu105"] # Kintex Ultrascale
128 platforms
+= ["de0nano"] # Cyclone4
131 platforms
+= ["tinyfpga_bx"] # iCE40
132 platforms
+= ["machxo3"] # MachXO3
133 platforms
+= ["versa_ecp5", "ulx3s"] # ECP5
136 platforms
+= ["avalanche"] # PolarFire
139 with self
.subTest(platform
=p
):
141 litex/boards/targets/simple.py litex.boards.platforms.{p} \
142 --cpu-type=vexriscv \
143 --no-compile-software \
146 subprocess
.check_call(cmd
, shell
=True)
148 def test_z_cpu_none(self
): # FIXME: workaround to execute it last.
149 from litex
.boards
.targets
.arty
import BaseSoC
150 errors
= build_test([BaseSoC(cpu_type
=None)])
151 self
.assertEqual(errors
, 0)
153 def run_variants(self
, cpu
, variants
):
155 with self
.subTest(cpu
=cpu
, variant
=v
):
156 self
.run_variant(cpu
, v
)
158 def run_variant(self
, cpu
, variant
):
160 litex/boards/targets/simple.py litex.boards.platforms.arty \
163 --no-compile-software \
165 """.format(c
=cpu
, v
=variant
)
166 subprocess
.check_output(cmd
, shell
=True)
168 # Build some variants for the arty platform to make sure they work.
169 def test_variants_picorv32(self
):
170 self
.run_variants("picorv32", ('standard', 'minimal'))
172 def test_variants_vexriscv(self
):
173 self
.run_variants("vexriscv", ('standard', 'minimal', 'lite', 'lite+debug', 'full+debug'))
175 @unittest.skipIf(RUNNING_ON_TRAVIS
, "No nMigen/Yosys on Travis-CI")
176 def test_variants_minerva(self
):
177 self
.run_variants("minerva", ('standard',))
179 def test_variants_vexriscv(self
):
181 'vexriscv': ('standard', 'minimal', 'lite', 'lite+debug', 'full+debug'),
183 for cpu
, variants
in cpu_variants
.items():
184 self
.run_variants(cpu
, variants
)
186 @unittest.skipIf(RUNNING_ON_TRAVIS
, "No lm32 toolchain on Travis-CI")
187 def test_variants_lm32(self
):
188 self
.run_variants('lm32', ('standard', 'minimal', 'lite'))
190 @unittest.skipIf(RUNNING_ON_TRAVIS
, "No or1k toolchain on Travis-CI")
191 def test_variants_mor1kx(self
):
192 self
.run_variants('mor1kx', ('standard', 'linux'))