forked from chipsalliance/riscv-dv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiss_sim
executable file
·69 lines (59 loc) · 2.13 KB
/
iss_sim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#!/bin/bash
# Path for RISC-V GCC toolchain
# You can install the toolchain from /~https://github.com/riscv/riscv-gcc
RISCV_TOOLCHAIN="XXX"
RISCV_GCC="$RISCV_TOOLCHAIN/bin/riscv64-unknown-elf-gcc"
RISCV_OBJCOPY="$RISCV_TOOLCHAIN/bin/riscv64-unknown-elf-objcopy"
RISCV_SPIKE="XXX"
# GCC compile options
ABI="lp64"
ISA="rv64imc"
DATE=`date +%Y-%m-%d`
# RTL simulator, support vcs and irun
SIMULATOR="vcs"
# Test name, "all" means run all tests in the testlist
TEST="riscv_instr_base_test"
# Simulation output directory
SRC_DIR="./out_${DATE}/asm_tests"
find "$SRC_DIR" -name "*.S" > "$SRC_DIR/asm_test_list"
# GCC compile
while read asm_test; do
# Generate binary for RTL simulation
SRC="$asm_test"
OBJFILE="$asm_test.o"
BINFILE="$asm_test.bin"
GCC_CMD="$RISCV_GCC -march=$ISA -mabi=$ABI -static -mcmodel=medany \
-fvisibility=hidden -nostdlib \
-nostartfiles -I$RISCV_TESTS/env/p \
-Tscripts/link.ld $SRC -o $OBJFILE"
echo "Gcc compile :\n$GCC_CMD"
$($GCC_CMD)
echo "Convert $OBJFILE to $BINFILE"
# Convert the ELF to plain binary
# You can load this binary to your RTL simulation
"$RISCV_OBJCOPY" -O binary "$OBJFILE" "$BINFILE"
done <"$SRC_DIR/asm_test_list"
# Run spike simulation
find "$SRC_DIR" -name "*.o" > "$SRC_DIR/elf_list"
mkdir -p "$SRC_DIR/spike_sim"
while read elf_file; do
ELF="$elf_file"
TEST_NAME=$(echo "$elf_file" | sed 's/^.*\///g')
LOGFILE="$SRC_DIR/spike_sim/$TEST_NAME.log"
SPIKE_CMD="timeout 60s $RISCV_SPIKE --isa=$ISA -l $ELF &> $LOGFILE"
echo "$SPIKE_CMD"
$($SPIKE_CMD &> $LOGFILE)
done <"$SRC_DIR/elf_list"