2016-04-08 22:08:23 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
|
|
|
|
## Generate test case
|
|
|
|
|
2016-04-13 02:17:36 +08:00
|
|
|
if ! test -f config.vh; then
|
|
|
|
python3 config.py
|
|
|
|
fi
|
|
|
|
|
2016-04-08 22:08:23 +08:00
|
|
|
if ! test -f test.S; then
|
|
|
|
cd riscv-torture
|
2016-04-13 02:17:36 +08:00
|
|
|
./sbt "generator/run -C config/test.config"
|
2016-04-08 22:08:23 +08:00
|
|
|
cp output/test.S ../test.S
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
## Compile test case and create reference
|
|
|
|
|
2017-07-10 17:52:10 +08:00
|
|
|
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
|
2016-04-08 22:08:23 +08:00
|
|
|
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
|
2016-04-10 19:39:39 +08:00
|
|
|
vvp test.vvp +vcd +hex=test.hex +ref=test.ref
|
2016-04-08 22:08:23 +08:00
|
|
|
|