2015-06-06 20:01:37 +08:00
|
|
|
|
|
|
|
OBJS = start.o dhry_1.o dhry_2.o stdlib.o
|
2016-04-10 22:55:10 +08:00
|
|
|
CFLAGS = -MD -O3 -m32 -march=RV32IM -ffreestanding -nostdlib -DTIME -DRISCV
|
2015-11-04 01:59:12 +08:00
|
|
|
TOOLCHAIN_PREFIX = riscv32-unknown-elf-
|
2015-06-06 20:01:37 +08:00
|
|
|
|
|
|
|
test: testbench.exe dhry.hex
|
|
|
|
vvp -N testbench.exe
|
|
|
|
|
2016-04-14 06:48:58 +08:00
|
|
|
timing: timing.txt
|
|
|
|
grep '^##' timing.txt | gawk 'x != "" {print x,$$3-y;} {x=$$2;y=$$3;}' | sort | uniq -c | \
|
|
|
|
gawk '{printf("%03d-%-7s %2d %-8s (%d)\n",$$3,$$2,$$3,$$2,$$1);}' | sort | cut -c13-
|
|
|
|
|
|
|
|
timing.txt: timing.exe dhry.hex
|
2015-06-07 14:28:10 +08:00
|
|
|
vvp -N timing.exe > timing.txt
|
|
|
|
|
2015-06-06 20:01:37 +08:00
|
|
|
testbench.exe: testbench.v ../picorv32.v
|
|
|
|
iverilog -o testbench.exe testbench.v ../picorv32.v
|
|
|
|
chmod -x testbench.exe
|
|
|
|
|
2015-06-07 14:28:10 +08:00
|
|
|
timing.exe: testbench.v ../picorv32.v
|
|
|
|
iverilog -o timing.exe -DTIMING testbench.v ../picorv32.v
|
|
|
|
chmod -x timing.exe
|
|
|
|
|
2015-06-06 20:01:37 +08:00
|
|
|
dhry.hex: dhry.bin ../firmware/makehex.py
|
2015-07-16 17:10:02 +08:00
|
|
|
python3 ../firmware/makehex.py $< 16384 > $@
|
2015-06-06 20:01:37 +08:00
|
|
|
|
|
|
|
dhry.bin: dhry.elf
|
2015-11-04 01:59:12 +08:00
|
|
|
$(TOOLCHAIN_PREFIX)objcopy -O binary $< $@
|
2015-06-06 20:01:37 +08:00
|
|
|
chmod -x $@
|
|
|
|
|
|
|
|
dhry.elf: $(OBJS) ../firmware/sections.lds
|
2015-11-04 01:59:12 +08:00
|
|
|
$(TOOLCHAIN_PREFIX)gcc $(CFLAGS) -Wl,-Bstatic,-T,../firmware/sections.lds,-Map,dhry.map,--strip-debug -o $@ $(OBJS) -lgcc
|
2015-06-06 20:01:37 +08:00
|
|
|
chmod -x $@
|
|
|
|
|
|
|
|
%.o: %.c
|
2015-11-04 01:59:12 +08:00
|
|
|
$(TOOLCHAIN_PREFIX)gcc -c $(CFLAGS) $<
|
2015-06-06 20:01:37 +08:00
|
|
|
|
|
|
|
%.o: %.S
|
2015-11-04 01:59:12 +08:00
|
|
|
$(TOOLCHAIN_PREFIX)gcc -c $(CFLAGS) $<
|
|
|
|
|
|
|
|
dhry_1.o dhry_2.o: CFLAGS += -Wno-implicit-int -Wno-implicit-function-declaration
|
2015-06-06 20:01:37 +08:00
|
|
|
|
|
|
|
clean:
|
2015-06-07 14:28:10 +08:00
|
|
|
rm -rf *.o *.d dhry.elf dhry.map dhry.bin dhry.hex testbench.exe testbench.vcd timing.exe timing.txt
|
2015-06-06 20:01:37 +08:00
|
|
|
|
|
|
|
.PHONY: test clean
|
|
|
|
|
|
|
|
-include *.d
|
|
|
|
|