summaryrefslogtreecommitdiffstats
path: root/scripts/torture/test.sh
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2022-11-24 18:49:44 +0000
committerYann Herklotz <git@yannherklotz.com>2022-11-24 18:49:44 +0000
commit3291d86ec38031e191ec1e7e5e8ddfa74b77cb7c (patch)
tree7d604206a2deb29c9f097ff1f3b7de78f44b34a3 /scripts/torture/test.sh
downloadbutterstick-3291d86ec38031e191ec1e7e5e8ddfa74b77cb7c.tar.gz
butterstick-3291d86ec38031e191ec1e7e5e8ddfa74b77cb7c.zip
Squashed 'picorv32/' content from commit f00a88c
git-subtree-dir: picorv32 git-subtree-split: f00a88c36eaab478b64ee27d8162e421049bcc66
Diffstat (limited to 'scripts/torture/test.sh')
-rw-r--r--scripts/torture/test.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/torture/test.sh b/scripts/torture/test.sh
new file mode 100644
index 0000000..17c5a7c
--- /dev/null
+++ b/scripts/torture/test.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+set -ex
+
+
+## Generate test case
+
+if ! test -f config.vh; then
+ python3 config.py
+fi
+
+if ! test -f test.S; then
+ cd riscv-torture
+ ./sbt "generator/run -C config/test.config"
+ cp output/test.S ../test.S
+ cd ..
+fi
+
+
+## Compile test case and create reference
+
+riscv32-unknown-elf-gcc `sed '/march=/ ! d; s,^// ,-,; y/RVIMC/rvimc/;' config.vh` -ffreestanding -nostdlib -Wl,-Bstatic,-T,sections.lds -o test.elf test.S
+LD_LIBRARY_PATH="./riscv-isa-sim:./riscv-fesvr" ./riscv-isa-sim/spike test.elf > test.ref
+riscv32-unknown-elf-objcopy -O binary test.elf test.bin
+python3 ../../firmware/makehex.py test.bin 4096 > test.hex
+
+
+## Run test
+
+iverilog -o test.vvp testbench.v ../../picorv32.v
+vvp test.vvp +vcd +hex=test.hex +ref=test.ref
+