mirror of
https://gitlab.com/brendanhaines/cpu.git
synced 2024-12-26 11:06:50 -07:00
build test code into build directory
This commit is contained in:
parent
180f05fb0a
commit
efd4cb6e48
20
Makefile
Normal file
20
Makefile
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
BUILD_DIR = build
|
||||||
|
SOURCE_V = $(wildcard hdl/*.v)
|
||||||
|
TESTBENCH_V = $(wildcard hdl/tb/*.v)
|
||||||
|
|
||||||
|
all: sim
|
||||||
|
|
||||||
|
$(BUILD_DIR):
|
||||||
|
mkdir -p $(BUILD_DIR)
|
||||||
|
|
||||||
|
$(BUILD_DIR)/tb.out: $(SOURCE_V) $(TESTBENCH_V) | $(BUILD_DIR)
|
||||||
|
iverilog $^ -o $@
|
||||||
|
|
||||||
|
sim: $(BUILD_DIR)/tb.out
|
||||||
|
cd $(BUILD_DIR) && ./tb.out
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(BUILD_DIR)
|
||||||
|
|
||||||
|
.SECONDARY:
|
||||||
|
.PHONY: all clean sim
|
19
hdl/Makefile
19
hdl/Makefile
|
@ -1,19 +0,0 @@
|
||||||
# SOURCE_V = $(wildcard *.v)
|
|
||||||
# TESTBENCH_V = $(wildcard tb/*.v)
|
|
||||||
|
|
||||||
SOURCE_V = core.v
|
|
||||||
TESTBENCH_V = tb/core_tb.v
|
|
||||||
|
|
||||||
all: sim
|
|
||||||
|
|
||||||
tb.out: $(SOURCE_V) $(TESTBENCH_V)
|
|
||||||
iverilog $^ -o $@
|
|
||||||
|
|
||||||
sim: tb.out
|
|
||||||
./tb.out
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf tb.out tb.vcd
|
|
||||||
|
|
||||||
.SECONDARY:
|
|
||||||
.PHONY: all clean sim
|
|
|
@ -1,8 +1,7 @@
|
||||||
all: text.hex data.hex
|
BUILD_DIR = build
|
||||||
|
|
||||||
CC = riscv64-linux-gnu-gcc
|
CC = riscv64-linux-gnu-gcc
|
||||||
# CFLAGS = -march=rv32i -mabi=ilp32
|
# CFLAGS = -march=rv32i -mabi=ilp32
|
||||||
CFLAGS = -march=rv64i -mabi=lp64 -o0
|
CFLAGS = -march=rv64i -mabi=lp64
|
||||||
|
|
||||||
AS = riscv64-linux-gnu-as
|
AS = riscv64-linux-gnu-as
|
||||||
ASFLAGS = $(CFLAGS)
|
ASFLAGS = $(CFLAGS)
|
||||||
|
@ -10,20 +9,25 @@ ASFLAGS = $(CFLAGS)
|
||||||
LD = riscv64-linux-gnu-ld
|
LD = riscv64-linux-gnu-ld
|
||||||
LDFLAGS = -T test.ld
|
LDFLAGS = -T test.ld
|
||||||
|
|
||||||
%.o: %.S
|
all: $(BUILD_DIR)/text.hex $(BUILD_DIR)/data.hex
|
||||||
|
|
||||||
|
$(BUILD_DIR):
|
||||||
|
mkdir -p $(BUILD_DIR)
|
||||||
|
|
||||||
|
$(BUILD_DIR)/%.o: %.S | $(BUILD_DIR)
|
||||||
$(AS) $(ASFLAGS) $^ -o $@
|
$(AS) $(ASFLAGS) $^ -o $@
|
||||||
|
|
||||||
%.o: %.c
|
$(BUILD_DIR)/%.o: %.c | $(BUILD_DIR)
|
||||||
$(CC) $(CFLAGS) $^ -o $@
|
$(CC) $(CFLAGS) $^ -o $@
|
||||||
|
|
||||||
%.elf: %.o %.ld
|
$(BUILD_DIR)/%.elf: $(BUILD_DIR)/%.o %.ld
|
||||||
$(LD) $(LDFLAGS) $< -o $@
|
$(LD) $(LDFLAGS) $< -o $@
|
||||||
|
|
||||||
text.hex: test.elf
|
$(BUILD_DIR)/text.hex: $(BUILD_DIR)/test.elf
|
||||||
riscv64-linux-gnu-objdump -s $^ | sed -n '/.text/,$$p' | tail -n+2 | sed -n '/.data/,$$!p' | cut -f3-6 -d ' ' | sed -e 's/ /\n/g' | sed 's/^\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/' > $@
|
riscv64-linux-gnu-objdump -s $^ | sed -n '/.text/,$$p' | tail -n+2 | sed -n '/.data/,$$!p' | cut -f3-6 -d ' ' | sed -e 's/ /\n/g' | sed 's/^\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/' > $@
|
||||||
|
|
||||||
data.hex: test.elf
|
$(BUILD_DIR)/data.hex: $(BUILD_DIR)/test.elf
|
||||||
riscv64-linux-gnu-objdump -s $^ | sed -n '/.data/,$$p' | tail -n+2 | sed -n '/.bss/,$$!p' | cut -f3-6 -d ' ' | sed -e 's/ /\n/g' | sed 's/^\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/' > $@
|
riscv64-linux-gnu-objdump -s $^ | sed -n '/.data/,$$p' | tail -n+2 | sed -n '/.bss/,$$!p' | cut -f3-6 -d ' ' | sed -e 's/ /\n/g' | sed 's/^\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/' > $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm test.elf text.hex data.hex
|
rm -rf $(BUILD_DIR)
|
|
@ -369,4 +369,4 @@ someint:
|
||||||
|
|
||||||
.bss
|
.bss
|
||||||
anotherint:
|
anotherint:
|
||||||
.word
|
.word
|
||||||
|
|
Loading…
Reference in New Issue
Block a user