diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 335a5ea0d..96cd46719 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -51,9 +51,7 @@ occamy-single-cluster-vsim: - make CFG_OVERRIDE=cfg/single-cluster.hjson rtl - make sw - make bin/occamy_top.vsim - - ../../deps/snitch_cluster/util/sim/simulate.py - sw/run-single-cluster.yaml --simulator vsim - --sim-bin bin/occamy_top.vsim + - ./run.py sw/run-single-cluster.yaml --simulator vsim ##################### # Full Occamy tests # @@ -66,6 +64,4 @@ occamy-full-vsim: - make CFG_OVERRIDE=cfg/full.hjson rtl - make LENGTH=384 sw - make bin/occamy_top.vsim - - ../../deps/snitch_cluster/util/sim/simulate.py - sw/run-full-occamy.yaml --simulator vsim - --sim-bin bin/occamy_top.vsim + - ./run.py sw/run-full-occamy.yaml --simulator vsim diff --git a/target/sim/.gitignore b/target/sim/.gitignore index 60c6d1450..4a1399ef3 100644 --- a/target/sim/.gitignore +++ b/target/sim/.gitignore @@ -6,6 +6,7 @@ /*.log /.*_targets_group /sw/**/build/ +/runs/ # Auto-generated sources /src/ \ No newline at end of file diff --git a/target/sim/run.py b/target/sim/run.py new file mode 100755 index 000000000..fd263be3a --- /dev/null +++ b/target/sim/run.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# Copyright 2023 ETH Zurich and University of Bologna. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 +# +# Luca Colagrande + +import sys +from pathlib import Path + +sys.path.append(str(Path(__file__).parent / '../../deps/snitch_cluster/util/sim')) +from sim_utils import parser, get_simulations, run_simulations # noqa: E402 +from Simulator import QuestaSimulator # noqa: E402 + + +SIMULATORS = { + 'vsim': QuestaSimulator(Path(__file__).parent.resolve() / 'bin/occamy_top.vsim') +} + + +def main(): + args = parser('vsim', SIMULATORS.keys()).parse_args() + simulations = get_simulations(args.testlist, SIMULATORS[args.simulator]) + return run_simulations(simulations, + n_procs=args.n_procs, + run_dir=Path(args.run_dir), + dry_run=args.dry_run, + early_exit=args.early_exit) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/target/sim/sw/host/apps/hello_world/verify.py b/target/sim/sw/host/apps/hello_world/verify.py index 3fe471deb..2b15cf680 100755 --- a/target/sim/sw/host/apps/hello_world/verify.py +++ b/target/sim/sw/host/apps/hello_world/verify.py @@ -10,19 +10,16 @@ import sys sys.path.append(str(Path(__file__).parent / '../../../../../../deps/snitch_cluster/util/sim/')) -from simulate import run_simulation # noqa: E402 +from sim_utils import run_simulations # noqa: E402 +from Simulator import QuestaSimulator # noqa: E402 -UART_LOG = str(Path(__file__).parent / '../../../../uart0.log') +UART_LOG = 'uart0.log' EXPECTED_OUTPUT = "Hello world!\r\n" def parse_args(): # Argument parsing parser = argparse.ArgumentParser(allow_abbrev=True) - parser.add_argument( - 'simulator', - help='The simulator to be used', - ) parser.add_argument( 'sim_bin', help='The simulator binary to be used to start the simulation', @@ -35,8 +32,10 @@ def parse_args(): def main(): args = parse_args() - cmd = f"{args.sim_bin} {args.snitch_bin}" - result, _ = run_simulation(cmd, args.simulator, {}) + simulator = QuestaSimulator(args.sim_bin) + simulation = simulator.get_simulation({'elf': args.snitch_bin}) + result = run_simulations([simulation]) + actual_output = '' with open(UART_LOG, 'rb') as file: actual_output = file.read().decode('ascii') diff --git a/target/sim/sw/run-full-occamy.yaml b/target/sim/sw/run-full-occamy.yaml index def88c5c6..0221ed562 100644 --- a/target/sim/sw/run-full-occamy.yaml +++ b/target/sim/sw/run-full-occamy.yaml @@ -4,8 +4,8 @@ runs: - elf: host/apps/offload/build/offload-axpy.elf - cmd: ../../deps/snitch_cluster/sw/blas/axpy/verify.py {sim_bin} {elf} - --symbols-bin ./sw/device/apps/blas/axpy/build/axpy.elf + cmd: [../../../deps/snitch_cluster/sw/blas/axpy/verify.py, --symbols-bin, + ./device/apps/blas/axpy/build/axpy.elf, "${sim_bin}", "${elf}"] - elf: host/apps/offload/build/offload-gemm.elf - cmd: ../../deps/snitch_cluster/sw/blas/gemm/verify.py {sim_bin} {elf} - --symbols-bin ./sw/device/apps/blas/gemm/build/gemm.elf + cmd: [../../../deps/snitch_cluster/sw/blas/gemm/verify.py, --symbols-bin, + ./device/apps/blas/gemm/build/gemm.elf, "${sim_bin}", "${elf}"] diff --git a/target/sim/sw/run-single-cluster.yaml b/target/sim/sw/run-single-cluster.yaml index d22cf80a6..8ec1d07b3 100644 --- a/target/sim/sw/run-single-cluster.yaml +++ b/target/sim/sw/run-single-cluster.yaml @@ -4,10 +4,10 @@ runs: - elf: host/apps/offload/build/offload-axpy.elf - cmd: ../../deps/snitch_cluster/sw/blas/axpy/verify.py {sim_bin} {elf} - --symbols-bin ./sw/device/apps/blas/axpy/build/axpy.elf + cmd: [../../../deps/snitch_cluster/sw/blas/axpy/verify.py, --symbols-bin, + ./device/apps/blas/axpy/build/axpy.elf, "${sim_bin}", "${elf}"] - elf: host/apps/offload/build/offload-gemm.elf - cmd: ../../deps/snitch_cluster/sw/blas/gemm/verify.py {sim_bin} {elf} - --symbols-bin ./sw/device/apps/blas/gemm/build/gemm.elf + cmd: [../../../deps/snitch_cluster/sw/blas/gemm/verify.py, --symbols-bin, + ./device/apps/blas/gemm/build/gemm.elf, "${sim_bin}", "${elf}"] - elf: host/apps/hello_world/build/hello_world.elf - cmd: sw/host/apps/hello_world/verify.py {simulator} {sim_bin} {elf} + cmd: [./host/apps/hello_world/verify.py, "${sim_bin}", "${elf}"]