2016-05-04 07:21:39 +08:00
|
|
|
RISCV_TOOLS_DIR = /opt/riscv32imc
|
|
|
|
RISCV_TOOLS_PREFIX = $(RISCV_TOOLS_DIR)/bin/riscv32-unknown-elf-
|
2016-05-03 22:53:22 +08:00
|
|
|
CSMITH_INCDIR = $(shell ls -d /usr/local/include/csmith-* | head -n1)
|
|
|
|
CC = $(RISCV_TOOLS_PREFIX)gcc
|
|
|
|
|
2016-05-04 14:57:16 +08:00
|
|
|
run: test_ref test.hex testbench.vvp
|
|
|
|
./test_ref | tee output_ref.txt
|
|
|
|
vvp -N testbench.vvp | tee output_sim.txt
|
2016-05-03 22:53:22 +08:00
|
|
|
diff -u output_ref.txt output_sim.txt
|
|
|
|
|
2016-05-04 16:34:51 +08:00
|
|
|
spike: riscv-fesvr/build.ok riscv-isa-sim/build.ok test_ref test.elf
|
|
|
|
./test_ref | tee output_ref.txt
|
|
|
|
LD_LIBRARY_PATH="./riscv-isa-sim:./riscv-fesvr" ./riscv-isa-sim/spike test.elf | tee output_spike.txt
|
|
|
|
diff -u output_ref.txt output_spike.txt
|
2016-05-04 07:21:39 +08:00
|
|
|
|
|
|
|
riscv-fesvr/build.ok:
|
|
|
|
rm -rf riscv-fesvr
|
|
|
|
git clone https://github.com/riscv/riscv-fesvr.git riscv-fesvr
|
|
|
|
+cd riscv-fesvr && git checkout 1c02bd6 && ./configure && make && touch build.ok
|
|
|
|
|
|
|
|
riscv-isa-sim/build.ok: riscv-fesvr/build.ok
|
|
|
|
rm -rf riscv-isa-sim
|
|
|
|
git clone https://github.com/riscv/riscv-isa-sim.git riscv-isa-sim
|
|
|
|
cd riscv-isa-sim && git checkout 10ae74e
|
|
|
|
cd riscv-isa-sim && patch -p1 < ../riscv-isa-sim-exit.diff
|
2016-05-04 15:10:58 +08:00
|
|
|
cd riscv-isa-sim && patch -p1 < ../riscv-isa-sim-console.diff
|
2016-05-04 07:21:39 +08:00
|
|
|
cd riscv-isa-sim && LDFLAGS="-L../riscv-fesvr" ./configure --with-isa=RV32IMC
|
|
|
|
+cd riscv-isa-sim && ln -s ../riscv-fesvr/fesvr . && make && touch build.ok
|
|
|
|
|
2016-05-04 14:57:16 +08:00
|
|
|
testbench.vvp: testbench.v ../../picorv32.v
|
|
|
|
iverilog -o testbench.vvp testbench.v ../../picorv32.v
|
|
|
|
chmod -x testbench.vvp
|
2016-05-03 22:53:22 +08:00
|
|
|
|
2016-05-04 07:21:39 +08:00
|
|
|
test.hex: test.elf
|
|
|
|
$(RISCV_TOOLS_PREFIX)objcopy -O verilog test.elf test.hex
|
2016-05-03 22:53:22 +08:00
|
|
|
|
|
|
|
start.elf: start.S start.ld
|
|
|
|
$(CC) -nostdlib -o start.elf start.S -T start.ld
|
|
|
|
chmod -x start.elf
|
|
|
|
|
2016-05-04 14:57:16 +08:00
|
|
|
test_ref: test.c
|
|
|
|
gcc -m32 -o test_ref -w -Os -I $(CSMITH_INCDIR) test.c
|
2016-05-03 22:53:22 +08:00
|
|
|
|
2016-05-04 07:21:39 +08:00
|
|
|
test.elf: test.c syscalls.c start.S
|
|
|
|
sed -e '/SECTIONS/,+1 s/{/{ . = 0x00000000; .start : { *(.text.start) } application_entry_point = 0x00010000;/;' \
|
|
|
|
$(RISCV_TOOLS_DIR)/riscv32-unknown-elf/lib/riscv.ld > test.ld
|
|
|
|
$(CC) -o test.elf -w -Os -I $(CSMITH_INCDIR) -T test.ld test.c syscalls.c start.S
|
2016-05-03 22:53:22 +08:00
|
|
|
chmod -x test.elf
|
|
|
|
|
|
|
|
test.c:
|
|
|
|
echo "integer size = 4" > platform.info
|
|
|
|
echo "pointer size = 4" >> platform.info
|
2016-05-04 16:34:51 +08:00
|
|
|
csmith --no-packed-struct -o test.c
|
2016-05-03 22:53:22 +08:00
|
|
|
|
|
|
|
clean:
|
2016-05-04 16:34:51 +08:00
|
|
|
rm -f platform.info test.c test.ld test.elf test.hex test_ref testbench.vvp testbench.vcd
|
|
|
|
rm -f output_ref.txt output_sim.txt output_spike.txt
|
2016-05-03 22:53:22 +08:00
|
|
|
|
2016-05-04 07:21:39 +08:00
|
|
|
mrproper: clean
|
|
|
|
rm -rf riscv-fesvr riscv-isa-sim
|
|
|
|
|
|
|
|
.PHONY: run spike clean mrproper
|
|
|
|
|