cpu/testbench/test_c/Makefile

68 lines
1.4 KiB
Makefile
Raw Normal View History

2021-09-08 23:43:15 -06:00
all: verify
TESTBENCH_V = $(wildcard *tb.sv)
SOURCE_V = $(wildcard ../../src/*.v ../../src/*.sv)
SOURCE_V += $(wildcard ../common/*.v) $(wildcard ../common/*.sv)
LOGS = $(TESTBENCH_V:.sv=.log)
SOURCE_C = $(wildcard *.c)
SOURCE_AS = $(wildcard *.S)
OBJ = $(notdir $(SOURCE_AS:.S=.o))
OBJ += $(notdir $(SOURCE_C:.c=.o))
CC = riscv64-linux-gnu-gcc
CFLAGS = -march=rv32i -mabi=ilp32
2021-09-09 00:06:15 -06:00
# CFLAGS = -march=rv64i -mabi=lp64
# CFLAGS += -nostdlib -lgcc
2021-09-08 23:43:15 -06:00
CPPFLAGS =
AS = riscv64-linux-gnu-as
ASFLAGS = -march=rv32i -mabi=ilp32
2021-09-09 00:06:15 -06:00
# ASFLAGS = -march=rv64i -mabi=lp64
2021-09-08 23:43:15 -06:00
LD = riscv64-linux-gnu-ld
LDFLAGS = -melf32lriscv_ilp32
2021-09-09 00:06:15 -06:00
# LDFLAGS =
2021-09-08 23:43:15 -06:00
# $(info $$TESTBENCH_V is [${TESTBENCH_V}])
# $(info $$SOURCE_V is [${SOURCE_V}])
# $(info $$LOGS is [${LOGS}])
# $(info $$SOURCE_C is [${SOURCE_C}])
# $(info $$SOURCE_AS is [${SOURCE_AS}])
# $(info $$OBJ is [${OBJ}])
%.o: %.S
$(AS) $(ASFLAGS) $^ -o $@
%.o: %.c
%.s: %.c
2021-09-09 00:06:15 -06:00
$(CC) $(CFLAGS) -S $^ -o $@
2021-09-08 23:43:15 -06:00
%.elf: %.ld $(OBJ)
$(LD) $(LDFLAGS) -T $^ -o $@
%.hex: %.elf
riscv64-linux-gnu-objcopy --target=verilog $< $@
%.out: %.sv $(SOURCE_V)
iverilog -o $@ $^
%.vcd %.log: %.out %.hex
./$< | tee $(patsubst %.out, %.log, $<)
verify: $(LOGS)
@echo "Checking log for \"ERROR:\"..."
@! grep "ERROR:" $^
@echo "Checking log for \"SUCCESS:\"..."
@grep "SUCCESS:" $^
clean:
rm -rf *.vcd *.log *.out *.hex
.SECONDARY: %.log %.vcd
.PHONY: all clean verify