2015-06-06 08:01:37 -04:00
|
|
|
|
2015-06-26 16:02:22 -04:00
|
|
|
TEST_OBJS = $(addsuffix .o,$(basename $(wildcard tests/*.S)))
|
2015-06-26 17:14:38 -04:00
|
|
|
FIRMWARE_OBJS = firmware/start.o firmware/irq.o firmware/print.o firmware/sieve.o firmware/multest.o firmware/stats.o
|
2015-07-04 05:47:19 -04:00
|
|
|
GCC_WARNS = -Wall -Wextra -Wshadow -Wundef -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings
|
|
|
|
GCC_WARNS += -Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes -pedantic # -Wconversion
|
|
|
|
TOOLCHAIN_PREFIX = riscv64-unknown-elf-
|
2015-06-06 08:01:37 -04:00
|
|
|
|
|
|
|
test: testbench.exe firmware/firmware.hex
|
|
|
|
vvp -N testbench.exe
|
|
|
|
|
2015-07-02 04:45:35 -04:00
|
|
|
testbench.vcd: testbench.exe firmware/firmware.hex
|
|
|
|
vvp -N $< +vcd
|
|
|
|
|
2015-07-02 05:01:21 -04:00
|
|
|
view: testbench.vcd
|
2015-07-02 04:45:35 -04:00
|
|
|
gtkwave $< testbench.gtkw
|
|
|
|
|
2015-06-26 17:54:12 -04:00
|
|
|
test_sp: testbench_sp.exe firmware/firmware.hex
|
|
|
|
vvp -N testbench_sp.exe
|
|
|
|
|
2015-06-06 13:22:28 -04:00
|
|
|
test_axi: testbench_axi.exe firmware/firmware.hex
|
|
|
|
vvp -N testbench_axi.exe
|
|
|
|
|
2015-06-29 19:46:25 -04:00
|
|
|
test_synth: testbench_synth.exe firmware/firmware.hex
|
|
|
|
vvp -N testbench_synth.exe
|
|
|
|
|
2015-06-06 08:01:37 -04:00
|
|
|
testbench.exe: testbench.v picorv32.v
|
|
|
|
iverilog -o testbench.exe testbench.v picorv32.v
|
|
|
|
chmod -x testbench.exe
|
|
|
|
|
2015-06-26 17:54:12 -04:00
|
|
|
testbench_sp.exe: testbench.v picorv32.v
|
|
|
|
iverilog -o testbench_sp.exe -DSP_TEST testbench.v picorv32.v
|
|
|
|
chmod -x testbench_sp.exe
|
|
|
|
|
2015-06-06 13:22:28 -04:00
|
|
|
testbench_axi.exe: testbench.v picorv32.v
|
|
|
|
iverilog -o testbench_axi.exe -DAXI_TEST testbench.v picorv32.v
|
|
|
|
chmod -x testbench_axi.exe
|
|
|
|
|
2015-06-29 19:46:25 -04:00
|
|
|
testbench_synth.exe: testbench.v synth.v
|
|
|
|
iverilog -o testbench_synth.exe testbench.v synth.v
|
|
|
|
chmod -x testbench_synth.exe
|
|
|
|
|
|
|
|
synth.v: picorv32.v scripts/yosys/synth_sim.ys
|
|
|
|
yosys -qv3 -l synth.log scripts/yosys/synth_sim.ys
|
|
|
|
|
2015-06-06 08:01:37 -04:00
|
|
|
firmware/firmware.hex: firmware/firmware.bin firmware/makehex.py
|
|
|
|
python3 firmware/makehex.py $< > $@
|
|
|
|
|
|
|
|
firmware/firmware.bin: firmware/firmware.elf
|
2015-07-04 05:47:19 -04:00
|
|
|
$(TOOLCHAIN_PREFIX)objcopy -O binary $< $@
|
2015-06-06 08:01:37 -04:00
|
|
|
chmod -x $@
|
|
|
|
|
2015-06-26 16:02:22 -04:00
|
|
|
firmware/firmware.elf: $(FIRMWARE_OBJS) $(TEST_OBJS) firmware/sections.lds
|
2015-07-04 05:47:19 -04:00
|
|
|
$(TOOLCHAIN_PREFIX)gcc -Os -m32 -ffreestanding -nostdlib -o $@ \
|
2015-06-06 08:01:37 -04:00
|
|
|
-Wl,-Bstatic,-T,firmware/sections.lds,-Map,firmware/firmware.map,--strip-debug \
|
2015-06-26 16:02:22 -04:00
|
|
|
$(FIRMWARE_OBJS) $(TEST_OBJS) -lgcc
|
2015-06-06 08:01:37 -04:00
|
|
|
chmod -x $@
|
|
|
|
|
2015-06-25 08:08:39 -04:00
|
|
|
firmware/start.o: firmware/start.S
|
2015-07-04 05:47:19 -04:00
|
|
|
$(TOOLCHAIN_PREFIX)gcc -c -m32 -o $@ $<
|
2015-06-25 08:08:39 -04:00
|
|
|
|
2015-06-26 16:02:22 -04:00
|
|
|
firmware/%.o: firmware/%.c
|
2015-07-04 05:47:19 -04:00
|
|
|
$(TOOLCHAIN_PREFIX)gcc -c -m32 -march=RV32I -Os --std=c99 $(GCC_WARNS) -ffreestanding -nostdlib -o $@ $<
|
2015-06-26 16:02:22 -04:00
|
|
|
|
2015-06-06 08:01:37 -04:00
|
|
|
tests/%.o: tests/%.S tests/riscv_test.h tests/test_macros.h
|
2015-07-04 05:47:19 -04:00
|
|
|
$(TOOLCHAIN_PREFIX)gcc -c -m32 -o $@ -DTEST_FUNC_NAME=$(notdir $(basename $<)) \
|
2015-06-06 08:01:37 -04:00
|
|
|
-DTEST_FUNC_TXT='"$(notdir $(basename $<))"' -DTEST_FUNC_RET=$(notdir $(basename $<))_ret $<
|
|
|
|
|
2015-06-30 06:25:05 -04:00
|
|
|
toc:
|
|
|
|
gawk '/^-+$$/ { y=tolower(x); gsub("[^a-z0-9]+", "-", y); gsub("-$$", "", y); printf("- [%s](#%s)\n", x, y); } { x=$$0; }' README.md
|
|
|
|
|
2015-06-06 08:01:37 -04:00
|
|
|
clean:
|
2015-06-27 20:10:45 -04:00
|
|
|
rm -vrf $(FIRMWARE_OBJS) $(TEST_OBJS) \
|
2015-07-02 05:01:21 -04:00
|
|
|
firmware/firmware.elf firmware/firmware.bin firmware/firmware.hex firmware/firmware.map \
|
|
|
|
synth.v testbench.exe testbench_sp.exe testbench_axi.exe testbench_synth.exe testbench.vcd
|
2015-06-06 08:01:37 -04:00
|
|
|
|
2015-07-03 12:43:37 -04:00
|
|
|
.PHONY: test view test_sp test_axi test_synth toc clean
|
2015-06-06 08:01:37 -04:00
|
|
|
|