-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (55 loc) · 1.54 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
# Project Configuration
PRJ = cl2
PRJ_DIR = $(CURDIR)
BUILD_DIR = ./build
VSRC_DIR = ./vsrc
WAVE = cl2.fst
TEST_BUILD = ./test/riscv-arch-test-am/build
# Makefile Paths
VERILATOR_MAKE = ./scripts/verilator_sim.mk
RVTEST_MAKE = ./test/riscv-arch-test-am/Makefile
# Tools
MILL = $(or $(shell which mill), ./mill) # Use global mill if available, otherwise use local ./mill
MKDIR = mkdir -p
RM = rm -rf
DUMPWAVE = gtkwave
MAKE = make
# Export Variables
export PRJ_DIR
# Phony Targets
.PHONY: all verilog gen help reformat checkformat clean fst run gdb latest
# Default Target
all: gen
# Generate Verilog
verilog:
@echo "Generating Verilog files..."
$(MKDIR) $(VSRC_DIR)
$(MILL) -i $(PRJ).runMain Elaborate --target-dir $(VSRC_DIR)
# Generate Binary (depends on verilog)
gen: verilog
@echo "Generating binary using Verilator..."
$(MAKE) -f $(VERILATOR_MAKE) verilator_bin
# Show Help for Elaborate
help:
@echo "Displaying help for Elaborate..."
$(MILL) -i $(PRJ).runMain Elaborate --help
# Reformat Code
reformat:
@echo "Reformatting code..."
$(MILL) -i __.reformat
# Check Code Format
checkformat:
@echo "Checking code format..."
$(MILL) -i __.checkFormat
# Clean Build Artifacts
clean:
@echo "Cleaning build artifacts..."
$(RM) $(BUILD_DIR) $(TEST_BUILD) $(WAVE)
# Open Waveform
fst:
@echo "Opening waveform with gtkwave..."
$(DUMPWAVE) $(WAVE)
# Test Targets (run, gdb, latest)
run gdb latest:
@echo "Running target '$@' for ARCH=$(ARCH)..."
$(MAKE) -C test/riscv-arch-test-am ARCH=$(ARCH) $@