Skip to content

Commit

Permalink
target: Align with Snitch cluster simulation framework refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
colluca committed Jan 16, 2024
1 parent 3ab32bd commit eb48d1a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 23 deletions.
8 changes: 2 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand All @@ -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
1 change: 1 addition & 0 deletions target/sim/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/*.log
/.*_targets_group
/sw/**/build/
/runs/

# Auto-generated sources
/src/
32 changes: 32 additions & 0 deletions target/sim/run.py
Original file line number Diff line number Diff line change
@@ -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 <colluca@iis.ee.ethz.ch>

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())
15 changes: 7 additions & 8 deletions target/sim/sw/host/apps/hello_world/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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')
Expand Down
8 changes: 4 additions & 4 deletions target/sim/sw/run-full-occamy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"]
10 changes: 5 additions & 5 deletions target/sim/sw/run-single-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"]

0 comments on commit eb48d1a

Please sign in to comment.