-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
73 lines (52 loc) · 1.17 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Disable builtin rules.
.SUFFIXES:
# Software
# ==========================
## Config
## =============
TOOLCHAIN=riscv64-unknown-elf-
OSDIR=os
AS=$(TOOLCHAIN)as
LD=$(TOOLCHAIN)ld
LINKER_SCRIPT=$(OSDIR)/virt.ld
SOURCES=$(wildcard $(OSDIR)/*.S)
OUTDIR=build
OBJ=$(OUTDIR)/mossos.o
BIN=$(OUTDIR)/mossos
QEMU=qemu-system-riscv64
HARTS=1
GDB=$(TOOLCHAIN)gdb
OBJDUMP=$(TOOLCHAIN)objdump
## Build
## =============
$(OUTDIR)/%.o: $(SOURCES)
@mkdir -p $(@D)
@$(AS) $^ -o $@
$(BIN): $(OBJ)
@mkdir -p $(@D)
@$(LD) -T$(LINKER_SCRIPT) $^ -o $@
build: $(BIN)
## Debug
## =============
qemu:
@$(QEMU) -machine virt -cpu rv64 -smp $(HARTS) -s -S -nographic -bios none -kernel $(BIN)
gdb:
@$(GDB) $(BIN) -ex "target remote :1234"
dump:
@$(OBJDUMP) -Dtr $(BIN)
# Hardware
# ==========================
## Simulate
## =============
RTLDIR=rtl
SIMDIR=sim
SIMOUTDIR=obj_dir
VERILATOR=verilator
GTKWAVE=gtkwave
$(SIMOUTDIR)/%.o: $(SIMDIR)/%.cpp $(RTLDIR)/%.v
$(VERILATOR) -Wall --cc -I$(RTLDIR) --trace $*.v --exe --build $(SIMDIR)/$*.cpp
verilate: $(SIMOUTDIR)/top.o $(SIMOUTDIR)/alu.o $(SIMOUTDIR)/regfile.o
simulate.%: verilate
@$(SIMOUTDIR)/V$*
wave.%: simulate.%
$(GTKWAVE) obj_dir/$*.vcd