aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2015-06-06 14:01:37 +0200
committerClifford Wolf <clifford@clifford.at>2015-06-06 14:14:32 +0200
commit77ba5a18973bd02b461ab96047acfcc3fb62cf7b (patch)
tree573afedb6a3a14c91224e16724fa21ba3a939de2 /Makefile
downloadpicorv32-77ba5a18973bd02b461ab96047acfcc3fb62cf7b.tar.gz
picorv32-77ba5a18973bd02b461ab96047acfcc3fb62cf7b.zip
Initial import
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile37
1 files changed, 37 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..73cb4d1
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,37 @@
+
+TEST_OBJS=$(addsuffix .o,$(basename $(wildcard tests/*.S)))
+
+test: testbench.exe firmware/firmware.hex
+ vvp -N testbench.exe
+
+testbench.exe: testbench.v picorv32.v
+ iverilog -o testbench.exe testbench.v picorv32.v
+ chmod -x testbench.exe
+
+firmware/firmware.hex: firmware/firmware.bin firmware/makehex.py
+ python3 firmware/makehex.py $< > $@
+
+firmware/firmware.bin: firmware/firmware.elf
+ riscv64-unknown-elf-objcopy -O binary $< $@
+ chmod -x $@
+
+firmware/firmware.elf: $(TEST_OBJS) firmware/sections.lds firmware/start.S firmware/sieve.c firmware/stats.c
+ riscv64-unknown-elf-gcc -Os -m32 -march=RV32I -ffreestanding -nostdlib -o $@ \
+ -Wl,-Bstatic,-T,firmware/sections.lds,-Map,firmware/firmware.map,--strip-debug \
+ firmware/start.S firmware/sieve.c firmware/stats.c $(TEST_OBJS) -lgcc
+ chmod -x $@
+
+tests/%.o: tests/%.S tests/riscv_test.h tests/test_macros.h
+ riscv64-unknown-elf-gcc -m32 -march=RV32I -c -o $@ -DTEST_FUNC_NAME=$(notdir $(basename $<)) \
+ -DTEST_FUNC_TXT='"$(notdir $(basename $<))"' -DTEST_FUNC_RET=$(notdir $(basename $<))_ret $<
+
+synth_vivado:
+ vivado -nojournal -log synth_vivado.log -mode batch -source synth_vivado.tcl
+
+clean:
+ rm -vrf $(TEST_OBJS) firmware/firmware.elf firmware/firmware.bin firmware/firmware.hex \
+ firmware/firmware.map testbench.exe testbench.vcd .Xil fsm_encoding.os \
+ synth_vivado.log synth_vivado_*.backup.log synth_vivado.v
+
+.PHONY: test synth_vivado clean
+