2016-06-07 23:09:26 +08:00
|
|
|
USE_MYSTDLIB = 0
|
|
|
|
OBJS = dhry_1.o dhry_2.o stdlib.o
|
2021-12-27 18:09:39 +08:00
|
|
|
CFLAGS = -MD -O3 -mabi=ilp32 -march=rv32im -DTIME -DRISCV
|
2016-06-07 23:09:26 +08:00
|
|
|
TOOLCHAIN_PREFIX = /opt/riscv32im/bin/riscv32-unknown-elf-
|
|
|
|
|
|
|
|
ifeq ($(USE_MYSTDLIB),1)
|
|
|
|
CFLAGS += -DUSE_MYSTDLIB -ffreestanding -nostdlib
|
|
|
|
OBJS += start.o
|
|
|
|
else
|
|
|
|
OBJS += syscalls.o
|
|
|
|
endif
|
2015-06-06 20:01:37 +08:00
|
|
|
|
2016-05-04 14:57:16 +08:00
|
|
|
test: testbench.vvp dhry.hex
|
|
|
|
vvp -N testbench.vvp
|
2015-06-06 20:01:37 +08:00
|
|
|
|
2019-08-18 23:32:45 +08:00
|
|
|
test_trace: testbench.vvp dhry.hex
|
|
|
|
vvp -N $< +trace
|
|
|
|
python3 ../showtrace.py testbench.trace dhry.elf > testbench.ins
|
|
|
|
|
2016-09-04 18:27:38 +08:00
|
|
|
test_nola: testbench_nola.vvp dhry.hex
|
|
|
|
vvp -N testbench_nola.vvp
|
2016-09-03 13:16:59 +08:00
|
|
|
|
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-
|
|
|
|
|
2016-05-04 14:57:16 +08:00
|
|
|
timing.txt: timing.vvp dhry.hex
|
|
|
|
vvp -N timing.vvp > timing.txt
|
2015-06-07 14:28:10 +08:00
|
|
|
|
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
|
2015-06-06 20:01:37 +08:00
|
|
|
|
2016-09-04 18:27:38 +08:00
|
|
|
testbench_nola.vvp: testbench_nola.v ../picorv32.v
|
|
|
|
iverilog -o testbench_nola.vvp testbench_nola.v ../picorv32.v
|
|
|
|
chmod -x testbench_nola.vvp
|
2016-09-03 13:16:59 +08:00
|
|
|
|
2016-05-04 14:57:16 +08:00
|
|
|
timing.vvp: testbench.v ../picorv32.v
|
|
|
|
iverilog -o timing.vvp -DTIMING testbench.v ../picorv32.v
|
|
|
|
chmod -x timing.vvp
|
2015-06-07 14:28:10 +08:00
|
|
|
|
2016-06-07 23:09:26 +08:00
|
|
|
dhry.hex: dhry.elf
|
2016-08-30 12:08:21 +08:00
|
|
|
$(TOOLCHAIN_PREFIX)objcopy -O verilog $< $@
|
2015-06-06 20:01:37 +08:00
|
|
|
|
2016-06-07 23:09:26 +08:00
|
|
|
ifeq ($(USE_MYSTDLIB),1)
|
|
|
|
dhry.elf: $(OBJS) sections.lds
|
|
|
|
$(TOOLCHAIN_PREFIX)gcc $(CFLAGS) -Wl,-Bstatic,-T,sections.lds,-Map,dhry.map,--strip-debug -o $@ $(OBJS) -lgcc
|
2015-06-06 20:01:37 +08:00
|
|
|
chmod -x $@
|
2016-06-07 23:09:26 +08:00
|
|
|
else
|
|
|
|
dhry.elf: $(OBJS)
|
2017-01-14 00:04:22 +08:00
|
|
|
$(TOOLCHAIN_PREFIX)gcc $(CFLAGS) -Wl,-Bstatic,-T,../firmware/riscv.ld,-Map,dhry.map,--strip-debug -o $@ $(OBJS) -lgcc -lc
|
2015-06-06 20:01:37 +08:00
|
|
|
chmod -x $@
|
2016-06-07 23:09:26 +08:00
|
|
|
endif
|
2015-06-06 20:01:37 +08:00
|
|
|
|
|
|
|
%.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:
|
2016-09-04 18:27:38 +08:00
|
|
|
rm -rf *.o *.d dhry.elf dhry.map dhry.bin dhry.hex testbench.vvp testbench.vcd timing.vvp timing.txt testbench_nola.vvp
|
2015-06-06 20:01:37 +08:00
|
|
|
|
|
|
|
.PHONY: test clean
|
|
|
|
|
|
|
|
-include *.d
|
|
|
|
|