diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index a4760147d..8014945e4 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -6,7 +6,7 @@ name: build-docker on: push: - branches: [main] + branches: [occamy] workflow_dispatch: jobs: build-docker: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 816a9838b..757db8bc6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,8 +43,7 @@ jobs: - name: Run Tests working-directory: target/snitch_cluster run: |- - ./sw/tests/run.py sw/tests/run.yaml --simulator verilator - ./sw/apps/run.py sw/apps/run.yaml --simulator verilator + ../../util/sim/simulate.py sw/run.yaml --simulator verilator ############################################ # Build SW on Snitch Cluster w/ Banshee # @@ -67,5 +66,4 @@ jobs: SNITCH_LOG: info working-directory: target/snitch_cluster run: |- - ./sw/tests/run.py sw/tests/run.yaml --simulator banshee - ./sw/apps/run.py sw/apps/run.yaml --simulator banshee + ../../util/sim/simulate.py sw/run.yaml --simulator banshee diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7847d0a44..7f7040fd1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -93,8 +93,7 @@ snitch-cluster-vlt: script: - cd target/snitch_cluster - $VERILATOR make bin/snitch_cluster.vlt - - $VERILATOR ./sw/tests/run.py sw/tests/run.yaml --simulator verilator - - $VERILATOR ./sw/apps/run.py sw/apps/run.yaml --simulator verilator + - $VERILATOR ../../util/sim/simulate.py sw/run.yaml --simulator verilator # yamllint enable rule:line-length # VCS @@ -103,8 +102,7 @@ snitch-cluster-vcs: script: - cd target/snitch_cluster - $VCS make bin/snitch_cluster.vcs - - $VCS ./sw/tests/run.py sw/tests/run.yaml --simulator vcs - - $VCS ./sw/apps/run.py sw/apps/run.yaml --simulator vcs + - $VCS ../../util/sim/simulate.py sw/run.yaml --simulator vcs # Questa snitch-cluster-vsim: @@ -112,8 +110,7 @@ snitch-cluster-vsim: script: - cd target/snitch_cluster - $QUESTA make bin/snitch_cluster.vsim - - $QUESTA ./sw/tests/run.py sw/tests/run.yaml --simulator vsim - - $QUESTA ./sw/apps/run.py sw/apps/run.yaml --simulator vsim + - $QUESTA ../../util/sim/simulate.py sw/run.yaml --simulator vsim # Banshee snitch-cluster-banshee: @@ -129,5 +126,4 @@ snitch-cluster-banshee: - cd banshee - cargo install --debug --path . - cd ../target/snitch_cluster - - ./sw/tests/run.py sw/tests/run.yaml --simulator banshee - - ./sw/apps/run.py sw/apps/run.yaml --simulator banshee + - ../../util/sim/simulate.py sw/run.yaml --simulator banshee diff --git a/sw/blas/axpy/verify.py b/sw/blas/axpy/verify.py index 5838c68df..02cb15975 100755 --- a/sw/blas/axpy/verify.py +++ b/sw/blas/axpy/verify.py @@ -24,12 +24,16 @@ def main(): args = verification.parse_args() raw_results = verification.simulate(sim_bin=args.sim_bin, snitch_bin=args.snitch_bin, + symbols_bin=args.symbols_bin, log=args.log, output_uids=['z']) z_actual = np.array(bytes_to_doubles(raw_results['z'])) # Extract input operands from ELF file - elf = Elf(args.snitch_bin) + if args.symbols_bin: + elf = Elf(args.symbols_bin) + else: + elf = Elf(args.snitch_bin) a = np.array(bytes_to_doubles(elf.get_symbol_contents('a'))) x = np.array(bytes_to_doubles(elf.get_symbol_contents('x'))) y = np.array(bytes_to_doubles(elf.get_symbol_contents('y'))) diff --git a/sw/blas/gemm/Makefile b/sw/blas/gemm/Makefile index c390c3667..604556ed1 100644 --- a/sw/blas/gemm/Makefile +++ b/sw/blas/gemm/Makefile @@ -9,18 +9,20 @@ MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) DATA_DIR := $(realpath $(MK_DIR)/data) SRC_DIR := $(realpath $(MK_DIR)/src) -DATA_CFG ?= $(DATA_DIR)/params.hjson - APP ?= gemm SRCS ?= $(realpath $(SRC_DIR)/main.c) INCDIRS ?= $(DATA_DIR) $(SRC_DIR) -$(DATA_DIR)/data.h: $(DATA_DIR)/datagen.py $(DATA_CFG) +DATA_CFG ?= $(DATA_DIR)/params.hjson +DATAGEN_PY = $(DATA_DIR)/datagen.py +DATA_H = $(DATA_DIR)/data.h + +$(DATA_H): $(DATAGEN_PY) $(DATA_CFG) $< -c $(DATA_CFG) > $@ .PHONY: clean-data clean clean-data: - rm -f $(DATA_DIR)/data.h + rm -f $(DATA_H) clean: clean-data diff --git a/sw/tests/interrupt-local.c b/sw/tests/interrupt_local.c similarity index 100% rename from sw/tests/interrupt-local.c rename to sw/tests/interrupt_local.c diff --git a/target/snitch_cluster/sw/apps/run.py b/target/snitch_cluster/sw/apps/run.py deleted file mode 100755 index 86b9422eb..000000000 --- a/target/snitch_cluster/sw/apps/run.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/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 / '../../../../util/sim')) -import sim_utils # noqa: E402,E261 - - -def main(): - sim_utils.main(lambda test: Path(__file__).parent / f'{test}/build/{Path(test).name}.elf') - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/target/snitch_cluster/sw/apps/run.yaml b/target/snitch_cluster/sw/apps/run.yaml deleted file mode 100644 index 93bd32d8b..000000000 --- a/target/snitch_cluster/sw/apps/run.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# 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 - -runs: - - app: blas/axpy - cmd: ../../sw/blas/axpy/verify.py {sim_bin} {elf} - - app: blas/gemm - - app: dnn/batchnorm - - app: dnn/linear - - app: dnn/maxpool - - app: dnn/gemm -# dnn/gelu # seems like it stalls -# dnn/conv2d # fails with exit code 32 -# dnn/fusedconv # fails newly -# dnn/layernorm # throws illegal instruction on FDIV in simulation -# dnn/softmax # throws illegal instruction on FDIV in simulation diff --git a/target/snitch_cluster/sw/run.yaml b/target/snitch_cluster/sw/run.yaml new file mode 100644 index 000000000..4c7ff7b1e --- /dev/null +++ b/target/snitch_cluster/sw/run.yaml @@ -0,0 +1,85 @@ +# 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 + +runs: + - elf: tests/build/atomics.elf + simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x4 + - elf: tests/build/barrier.elf + - elf: tests/build/data_mover.elf + - elf: tests/build/dma_simple.elf + - elf: tests/build/event_unit.elf + - elf: tests/build/fence_i.elf + - elf: tests/build/fp8_comparison_scalar.elf + simulators: [vsim, vcs, verilator] # banshee fails with segfault + - elf: tests/build/fp8_comparison_vector.elf + simulators: [vsim, vcs, verilator] # banshee fails with segfault + - elf: tests/build/fp8_computation_scalar.elf + simulators: [vsim, vcs, verilator] # banshee fails with JIT issue + - elf: tests/build/fp8_computation_vector.elf + simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x6 + - elf: tests/build/fp8alt_comparison_scalar.elf + simulators: [vsim, vcs, verilator] # banshee fails with segfault + - elf: tests/build/fp8alt_comparison_vector.elf + simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10 + - elf: tests/build/fp8alt_computation_scalar.elf + simulators: [vsim, vcs, verilator] # banshee fails with JIT issue + - elf: tests/build/fp8alt_computation_vector.elf + simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x12 + - elf: tests/build/fp16_comparison_scalar.elf + simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10 + - elf: tests/build/fp16_comparison_vector.elf + simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10 + - elf: tests/build/fp16_computation_scalar.elf + simulators: [vsim, vcs, verilator] # banshee fails with JIT issue + - elf: tests/build/fp16_computation_vector.elf + simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x6 + - elf: tests/build/fp16alt_comparison_scalar.elf + simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10 + - elf: tests/build/fp16alt_comparison_vector.elf + simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10 + - elf: tests/build/fp16alt_computation_scalar.elf + simulators: [vsim, vcs, verilator] # banshee fails with JIT issue + - elf: tests/build/fp16alt_computation_vector.elf + simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x16 + - elf: tests/build/fp32_comparison_scalar.elf + - elf: tests/build/fp32_comparison_vector.elf + - elf: tests/build/fp32_computation_scalar.elf + simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x2 + - elf: tests/build/fp32_computation_vector.elf + simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x2 + - elf: tests/build/fp32_conversions_scalar.elf + simulators: [vsim, vcs, verilator] # banshee fails with illegal instruction + - elf: tests/build/fp64_conversions_scalar.elf + simulators: [vsim, vcs, verilator] + # - elf: tests/build/interrupt.elf + - elf: tests/build/interrupt_local.elf + - elf: tests/build/multi_cluster.elf + - elf: tests/build/openmp_parallel.elf + - elf: tests/build/openmp_for_static_schedule.elf + - elf: tests/build/openmp_double_buffering.elf + - elf: tests/build/perf_cnt.elf + - elf: tests/build/printf_simple.elf + - elf: tests/build/printf_fmtint.elf + - elf: tests/build/simple.elf + - elf: tests/build/team_global.elf + - elf: tests/build/tls.elf + - elf: tests/build/varargs_1.elf + - elf: tests/build/varargs_2.elf + - elf: tests/build/zero_mem.elf + - elf: tests/build/non_null_exitcode.elf + exit_code: 14 + - elf: apps/blas/axpy/build/axpy.elf + cmd: ../../sw/blas/axpy/verify.py {sim_bin} {elf} + - elf: apps/blas/gemm/build/gemm.elf + - elf: apps/dnn/batchnorm/build/batchnorm.elf + - elf: apps/dnn/linear/build/linear.elf + - elf: apps/dnn/maxpool/build/maxpool.elf + - elf: apps/dnn/gemm/build/gemm.elf + # - elf: apps/dnn/gelu/build/gelu.elf # seems like it stalls + # - elf: apps/dnn/conv2d/build/conv2d.elf # fails with exit code 32 + # - elf: apps/dnn/fusedconv/build/fusedconv.elf # fails newly + # - elf: apps/dnn/layernorm/build/layernorm.elf + # throws illegal instruction on FDIV in simulation + # - elf: apps/dnn/softmax/build/softmax.elf + # throws illegal instruction on FDIV in simulation diff --git a/target/snitch_cluster/sw/tests/Makefile b/target/snitch_cluster/sw/tests/Makefile index c3b204b55..57b26d9a0 100644 --- a/target/snitch_cluster/sw/tests/Makefile +++ b/target/snitch_cluster/sw/tests/Makefile @@ -44,7 +44,7 @@ RISCV_LDFLAGS += -lsnRuntime # Outputs # ########### -APPS = $(shell $(MK_DIR)/../../../../util/sim/list_apps.py run.yaml) +APPS = $(shell $(MK_DIR)/../../../../util/sim/list_apps.py --in-dir tests/ ../run.yaml) ELFS = $(abspath $(addprefix $(BUILDDIR)/,$(addsuffix .elf,$(APPS)))) DEPS = $(abspath $(addprefix $(BUILDDIR)/,$(addsuffix .d,$(APPS)))) DUMPS = $(abspath $(addprefix $(BUILDDIR)/,$(addsuffix .dump,$(APPS)))) diff --git a/target/snitch_cluster/sw/tests/run.py b/target/snitch_cluster/sw/tests/run.py deleted file mode 100755 index 3fe6a6e51..000000000 --- a/target/snitch_cluster/sw/tests/run.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/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 / '../../../../util/sim')) -import sim_utils # noqa: E402,E261 - - -def main(): - sim_utils.main(lambda test: Path(__file__).parent / f'build/{test}.elf') - - -if __name__ == '__main__': - main() diff --git a/target/snitch_cluster/sw/tests/run.yaml b/target/snitch_cluster/sw/tests/run.yaml deleted file mode 100644 index 2f86d1a70..000000000 --- a/target/snitch_cluster/sw/tests/run.yaml +++ /dev/null @@ -1,71 +0,0 @@ -# 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 - -runs: - - app: atomics - simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x4 - - app: barrier - - app: data_mover - - app: dma_simple - - app: event_unit - - app: fence_i - - app: fp8_comparison_scalar - simulators: [vsim, vcs, verilator] # banshee fails with segfault - - app: fp8_comparison_vector - simulators: [vsim, vcs, verilator] # banshee fails with segfault - - app: fp8_computation_scalar - simulators: [vsim, vcs, verilator] # banshee fails with JIT issue - - app: fp8_computation_vector - simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x6 - - app: fp8alt_comparison_scalar - simulators: [vsim, vcs, verilator] # banshee fails with segfault - - app: fp8alt_comparison_vector - simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10 - - app: fp8alt_computation_scalar - simulators: [vsim, vcs, verilator] # banshee fails with JIT issue - - app: fp8alt_computation_vector - simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x12 - - app: fp16_comparison_scalar - simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10 - - app: fp16_comparison_vector - simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10 - - app: fp16_computation_scalar - simulators: [vsim, vcs, verilator] # banshee fails with JIT issue - - app: fp16_computation_vector - simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x6 - - app: fp16alt_comparison_scalar - simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10 - - app: fp16alt_comparison_vector - simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x10 - - app: fp16alt_computation_scalar - simulators: [vsim, vcs, verilator] # banshee fails with JIT issue - - app: fp16alt_computation_vector - simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x16 - - app: fp32_comparison_scalar - - app: fp32_comparison_vector - - app: fp32_computation_scalar - simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x2 - - app: fp32_computation_vector - simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x2 - - app: fp32_conversions_scalar - simulators: [vsim, vcs, verilator] # banshee fails with illegal instruction - - app: fp64_conversions_scalar - simulators: [vsim, vcs, verilator] - # - app: interrupt - - app: interrupt-local - - app: multi_cluster - - app: openmp_parallel - - app: openmp_for_static_schedule - - app: openmp_double_buffering - - app: perf_cnt - - app: printf_simple - - app: printf_fmtint - - app: simple - - app: team_global - - app: tls - - app: varargs_1 - - app: varargs_2 - - app: zero_mem - - app: non_null_exitcode - exit_code: 14 diff --git a/util/sim/elf.py b/util/sim/elf.py index db1721160..a46a6764d 100644 --- a/util/sim/elf.py +++ b/util/sim/elf.py @@ -1,7 +1,6 @@ -#!/usr/bin/env python3 -# Copyright 2020 ETH Zurich and University of Bologna. -# Solderpad Hardware License, Version 0.51, see LICENSE for details. -# SPDX-License-Identifier: SHL-0.51 +# 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 # diff --git a/util/sim/list_apps.py b/util/sim/list_apps.py index 608f8e335..baefdf7eb 100755 --- a/util/sim/list_apps.py +++ b/util/sim/list_apps.py @@ -7,22 +7,29 @@ import argparse import yaml +from pathlib import Path def main(): # Argument parsing parser = argparse.ArgumentParser() + parser.add_argument( + '--in-dir', + type=Path, + help='Only apps below this directory (at any level) will be listed') parser.add_argument( 'input', - help='The YAML file containing run information', - ) + help='The YAML file containing run information') args = parser.parse_args() with open(args.input, 'r') as file: tests = yaml.safe_load(file)['runs'] for test in tests: - print(test['app']) + elf = Path(test['elf']) + match_parts = args.in_dir.parts + if elf.parts[:len(match_parts)] == match_parts: + print(elf.stem) if __name__ == '__main__': diff --git a/util/sim/sim_utils.py b/util/sim/simulate.py similarity index 53% rename from util/sim/sim_utils.py rename to util/sim/simulate.py index bdd01615a..a1466dc16 100755 --- a/util/sim/sim_utils.py +++ b/util/sim/simulate.py @@ -1,3 +1,4 @@ +#!/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 @@ -18,7 +19,7 @@ BANSHEE_CFG = 'src/banshee.yaml' # Tool settings -SIMULATORS = ['vsim', 'banshee', 'verilator', 'vcs'] +SIMULATORS = ['vsim', 'banshee', 'verilator', 'vcs', 'other'] DEFAULT_SIMULATOR = SIMULATORS[0] SIMULATOR_BINS = { 'vsim': 'bin/snitch_cluster.vsim', @@ -48,6 +49,11 @@ def parse_args(): default=DEFAULT_SIMULATOR, choices=SIMULATORS, help='Choose a simulator to run the test with') + parser.add_argument( + '--sim-bin', + action='store', + nargs='?', + help='Override default path to simulator binary') parser.add_argument( '--dry-run', action='store_true', @@ -75,73 +81,95 @@ def check_exit_code(test, exit_code): return exit_code -def run_test(test, format_elf_path, simulator, dry_run=False): - # Get test parameters - app = test['app'] +def run_simulation(cmd, simulator, test): + # Defaults + result = 1 + + # Spawn simulation subprocess + p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, universal_newlines=True) + + # Poll simulation subprocess and log its output + while p.poll() is None: + line = p.stdout.readline() + print(line, end='', flush=True) + + # When simulating with vsim or vcs, we need to parse the simulation + # log to catch the application's return code + if simulator in ['vsim', 'vcs']: + # Capture success + regex_success = r'\[SUCCESS\] Program finished successfully' + match_success = re.search(regex_success, line) + if match_success: + result = 0 + else: + regex_fail = r'\[FAILURE\] Finished with exit code\s+(\d+)' + match = re.search(regex_fail, line) + if match: + exit_code = match.group(1) + result = check_exit_code(test, exit_code) + + # Check if the subprocess terminated correctly + exit_code = p.poll() + # In Banshee and Verilator the exit code of the Snitch binary is returned + # through the exit code of the simulation command + if simulator in ['banshee', 'verilator']: + result = check_exit_code(test, exit_code) + # For custom commands the return code is that of the command + elif simulator == 'other': + result = exit_code + # For standard simulation commands the simulated Snitch binary exit + # code is overriden only if the simulator failed + else: + if exit_code != 0: + result = exit_code + + return result + + +def run_test(test, args): + # Extract args + simulator = args.simulator + sim_bin = args.sim_bin if args.sim_bin else SIMULATOR_BINS[simulator] + dry_run = args.dry_run + testlist = args.testlist + + # Check if simulator is supported for this test if 'simulators' in test: if simulator not in test['simulators']: return 0 # Construct path to executable - elf = format_elf_path(app) + elf = Path(test['elf']) + if testlist: + elf = Path(testlist).absolute().parent / elf cprint(f'Run test {colored(elf, "cyan")}', attrs=["bold"]) # Construct simulation command (override only supported for RTL) if 'cmd' in test and simulator != 'banshee': cmd = test['cmd'] + cmd = cmd.format(sim_bin=sim_bin, elf=elf, simulator=simulator) + simulator = 'other' else: cmd = SIMULATOR_CMDS[simulator] - cmd = cmd.format(sim_bin=SIMULATOR_BINS[simulator], elf=elf) + cmd = cmd.format(sim_bin=sim_bin, elf=elf) print(f'$ {cmd}', flush=True) - # Run test + # Run simulation result = 0 if not dry_run: - result = 1 - - # When simulating with vsim or vcs, we need to parse the simulation - # log to catch the application's return code - if simulator in ['vsim', 'vcs']: - p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, - text=True) - - while p.poll() is None: - line = p.stdout.readline() - print(line, end='', flush=True) - - # Capture success - regex_success = r'\[SUCCESS\] Program finished successfully' - match_success = re.search(regex_success, line) - if match_success: - result = 0 - else: - regex_fail = r'\[FAILURE\] Finished with exit code\s+(\d+)' - match = re.search(regex_fail, line) - if match: - exit_code = match.group(1) - result = check_exit_code(test, exit_code) - - # Check if the subprocess terminated correctly - if p.poll() != 0: - result = p.poll() - - else: - p = subprocess.Popen(cmd, shell=True) - p.wait() - exit_code = p.returncode - result = check_exit_code(test, exit_code) + result = run_simulation(cmd, simulator, test) - # Report failure or success - if result != 0: - cprint(f'{app} test failed', 'red', attrs=['bold'], flush=True) - else: - cprint(f'{app} test passed', 'green', attrs=['bold'], flush=True) + # Report failure or success + if result != 0: + cprint(f'{elf} test failed', 'red', attrs=['bold'], flush=True) + else: + cprint(f'{elf} test passed', 'green', attrs=['bold'], flush=True) return result def print_failed_test(test): - print(f'{colored(test["app"], "cyan")} test {colored("failed", "red")}') + print(f'{colored(test["elf"], "cyan")} test {colored("failed", "red")}') def print_test_summary(failed_tests, dry_run=False): @@ -157,28 +185,25 @@ def print_test_summary(failed_tests, dry_run=False): return 0 -def run_tests(testlist, format_elf_path, simulator, dry_run=False, early_exit=False): +def run_tests(args): # Iterate tests - tests = get_tests(testlist) + tests = get_tests(args.testlist) failed_tests = [] for test in tests: # Run test - result = run_test(test, format_elf_path, simulator, dry_run) + result = run_test(test, args) if result != 0: failed_tests.append(test) # End program if requested on first test failure - if early_exit: + if args.early_exit: break + return print_test_summary(failed_tests, args.dry_run) - return print_test_summary(failed_tests, dry_run) - -# format_elf_path: function which constructs the path to an ELF binary -# from a test name as listed in the test list file -def main(format_elf_path): +def main(): args = parse_args() - sys.exit(run_tests(args.testlist, - format_elf_path, - args.simulator, - args.dry_run, - args.early_exit)) + sys.exit(run_tests(args)) + + +if __name__ == '__main__': + main() diff --git a/util/sim/verification.py b/util/sim/verification.py index ed3f0f670..9878ef62a 100644 --- a/util/sim/verification.py +++ b/util/sim/verification.py @@ -24,13 +24,18 @@ def parse_args(): parser.add_argument( 'snitch_bin', help='The Snitch binary to be executed by the simulated Snitch hardware') + parser.add_argument( + '--symbols-bin', + help='An optional binary containing the I/O symbols. By default,' + 'these are searched for in snitch_bin. This argument serves as an' + 'alternative.') parser.add_argument( '--log', help='Redirect simulation output to this log file') return parser.parse_args() -def simulate(sim_bin, snitch_bin, log, output_uids): +def simulate(sim_bin, snitch_bin, log, output_uids, symbols_bin=None): # Open ELF file for processing elf = Elf(snitch_bin) @@ -43,6 +48,8 @@ def simulate(sim_bin, snitch_bin, log, output_uids): sim.poll(tohost, 1, 0) # Read out results from memory + if symbols_bin: + elf = Elf(symbols_bin) raw_outputs = {} for uid in output_uids: address = elf.get_symbol_address(uid)