2021-10-24 06:08:58 -04:00
|
|
|
#
|
|
|
|
# This file is part of LiteX.
|
|
|
|
#
|
|
|
|
# Copyright (c) 2021 Navaneeth Bhardwaj <navan93@gmail.com>
|
|
|
|
# SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import pexpect
|
|
|
|
import sys
|
2022-11-14 06:31:25 -05:00
|
|
|
import os
|
2021-10-24 06:08:58 -04:00
|
|
|
|
|
|
|
class TestCPU(unittest.TestCase):
|
2022-11-14 06:31:25 -05:00
|
|
|
def boot_test(self, cpu_type, jobs, cpu_variant="standard"):
|
|
|
|
cmd = f'litex_sim --cpu-type={cpu_type} --cpu-variant={cpu_variant} --opt-level=O0 --jobs {jobs}'
|
2021-10-24 06:08:58 -04:00
|
|
|
litex_prompt = [b'\033\[[0-9;]+mlitex\033\[[0-9;]+m>']
|
|
|
|
is_success = True
|
|
|
|
with open("/tmp/test_boot_log", "wb") as result_file:
|
|
|
|
p = pexpect.spawn(cmd, timeout=None, logfile=result_file)
|
|
|
|
try:
|
|
|
|
match_id = p.expect(litex_prompt, timeout=1200)
|
|
|
|
except pexpect.EOF:
|
|
|
|
print('\n*** Premature termination')
|
|
|
|
is_success = False
|
|
|
|
except pexpect.TIMEOUT:
|
|
|
|
print('\n*** Timeout ')
|
|
|
|
is_success = False
|
|
|
|
|
|
|
|
if not is_success:
|
|
|
|
print(f'*** {cpu_type} Boot Failure')
|
|
|
|
with open("/tmp/test_boot_log", "r") as result_file:
|
|
|
|
print(result_file.read())
|
|
|
|
else:
|
|
|
|
p.terminate(force=True)
|
|
|
|
print(f'*** {cpu_type} Boot Success')
|
|
|
|
|
|
|
|
return is_success
|
|
|
|
|
2022-06-03 10:16:21 -04:00
|
|
|
def test_cpu(self):
|
|
|
|
tested_cpus = [
|
2022-06-29 05:15:48 -04:00
|
|
|
"cv32e40p", # (riscv / softcore)
|
2022-06-03 10:16:21 -04:00
|
|
|
"femtorv", # (riscv / softcore)
|
|
|
|
"firev", # (riscv / softcore)
|
2022-06-29 05:15:48 -04:00
|
|
|
"marocchino", # (or1k / softcore)
|
2022-06-03 10:16:21 -04:00
|
|
|
"naxriscv", # (riscv / softcore)
|
|
|
|
"serv", # (riscv / softcore)
|
|
|
|
"vexriscv", # (riscv / softcore)
|
|
|
|
"vexriscv_smp", # (riscv / softcore)
|
2023-02-26 21:25:50 -05:00
|
|
|
"microwatt", # (ppc64 / softcore)
|
|
|
|
"neorv32", # (riscv / softcore)
|
2022-06-03 10:16:21 -04:00
|
|
|
]
|
|
|
|
untested_cpus = [
|
|
|
|
"blackparrot", # (riscv / softcore) -> Broken install?
|
|
|
|
"cortex_m1", # (arm / softcore) -> Proprietary code.
|
|
|
|
"cortex_m3", # (arm / softcore) -> Proprieraty code.
|
|
|
|
"cv32e41p", # (riscv / softcore) -> Broken?
|
2022-06-03 11:14:52 -04:00
|
|
|
"cva5", # (riscv / softcore) -> Needs to be tested.
|
2022-06-03 10:16:21 -04:00
|
|
|
"cva6", # (riscv / softcore) -> Needs to be tested.
|
|
|
|
"eos_s3", # (arm / hardcore) -> Hardcore.
|
|
|
|
"gowin_emcu", # (arm / hardcore) -> Hardcore.
|
2022-11-14 03:51:37 -05:00
|
|
|
"ibex", # (riscv / softcore) -> Broken since 2022.11.12.
|
2022-06-03 10:16:21 -04:00
|
|
|
"lm32", # (lm32 / softcore) -> Requires LM32 toolchain.
|
|
|
|
"minerva", # (riscv / softcore) -> Broken install? (Amaranth?)
|
2022-06-27 13:54:50 -04:00
|
|
|
"mor1kx", # (or1k / softcore) -> Verilator compilation issue.
|
|
|
|
"picorv32", # (riscv / softcore) -> Verilator compilation issue.
|
2022-06-29 05:15:48 -04:00
|
|
|
"rocket", # (riscv / softcore) -> Not enough RAM in CI.
|
2022-06-03 10:16:21 -04:00
|
|
|
"zynq7000", # (arm / hardcore) -> Hardcore.
|
|
|
|
"zynqmp", # (aarch64 / hardcore) -> Hardcore.
|
|
|
|
]
|
2022-11-14 06:31:25 -05:00
|
|
|
jobs = os.cpu_count()
|
2022-06-03 10:16:21 -04:00
|
|
|
for cpu in tested_cpus:
|
|
|
|
with self.subTest(target=cpu):
|
2022-11-14 06:31:25 -05:00
|
|
|
self.assertTrue(self.boot_test(cpu, jobs))
|