2015-06-06 20:01:37 +08:00
|
|
|
|
|
|
|
OBJS = start.o dhry_1.o dhry_2.o stdlib.o
|
2015-06-07 13:29:13 +08:00
|
|
|
CFLAGS = -MD -O3 -m32 -march=RV32I -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
|
|
|
|
|
2015-06-07 14:28:10 +08:00
|
|
|
timing: timing.exe dhry.hex
|
|
|
|
vvp -N timing.exe > timing.txt
|
|
|
|
sed 's,.*## ,,' timing.txt | gawk 'x != "" {print x,$$2-y;} {x=$$1;y=$$2;}' | sort | uniq -c | sort -k3 -n
|
|
|
|
|
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
|
|
|
|
|