-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (81 loc) · 2.44 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
-include config.mk
# Tools
SBT = sbt
SBTFLAGS ?=
# Project definitions
TOPMOD = Blinky
MAIN = BlinkyMain
# Directories
SRCDIR = $(CURDIR)/src/main/scala
TESTDIR = $(CURDIR)/src/test/scala
RTLDIR = $(CURDIR)/rtl
SYNTHDIR = $(CURDIR)/synth
F4PGADIR = $(CURDIR)/f4pga
DIRS = $(SRCDIR) $(TESTDIR) $(RTLDIR)
# Sources
SRCS = $(shell find $(SRCDIR) -name '*.scala')
TESTS = $(shell find $(TESTDIR) -name '*.scala')
# Targets (configured in config.mk)
RTLFILE ?= $(RTLDIR)/$(TOPMOD).sv
MAINTARGET ?= $(MAIN)
TESTTARGET ?= $(TOPMOD)Tester
BOARD ?= basys3
# F4PGA
F4PGA_INSTALL_DIR ?= $(CURDIR)/f4pga/tools
F4PGA_EXAMPLES_DIR ?= $(CURDIR)/f4pga/f4pga-examples
# Generic target names
.PHONY: all
all: $(RTLFILE) test
.PHONY: rtl
rtl: $(RTLFILE)
# Generate SystemVerilog
$(RTLFILE): $(SRCS)
$(SBT) $(SBTFLAGS) "runMain $(MAINTARGET)"
# Synthesize design
.PHONY: synth
synth: $(RTLFILE)
$(MAKE) -C $(SYNTHDIR) synth BOARD=$(BOARD) TOPMOD=$(TOPMOD) RTLFILE=$(RTLFILE) F4PGA_INSTALL_DIR=$(F4PGA_INSTALL_DIR) F4PGA_EXAMPLES_DIR=$(F4PGA_EXAMPLES_DIR)
# Program FPGA
.PHONY: program
program: $(RTLFILE)
$(MAKE) -C $(SYNTHDIR) program BOARD=$(BOARD) TOPMOD=$(TOPMOD) RTLFILE=$(RTLFILE) F4PGA_INSTALL_DIR=$(F4PGA_INSTALL_DIR) F4PGA_EXAMPLES_DIR=$(F4PGA_EXAMPLES_DIR)
# Run specific test
.PHONY: test
test: $(SRCS) $(TESTS)
$(SBT) $(SBTFLAGS) "testOnly $(TESTTARGET)"
# Run all tests
.PHONY: testall
testall: $(SRCS) $(TESTS)
$(SBT) $(SBTFLAGS) test
# Install synthesis tools
.PHONY: install
install:
cd $(F4PGADIR) && ./install.sh
.PHONY: uninstall
uninstall:
$(RM) -rf $(F4PGA_INSTALL_DIR) $(F4PGA_EXAMPLES_DIR)
# Cleanup working directory
.PHONY: clean
clean:
@echo "Cleaning workspace"
$(RM) -rf $(RTLDIR) test_run_dir/ target/ project/target project/project
$(MAKE) -C $(SYNTHDIR) BOARD=$(BOARD) F4PGA_EXAMPLES_DIR=$(F4PGA_EXAMPLES_DIR) clean
# For debugging Makefile
.PHONY: show
show:
@echo 'SBT :' $(SBT)
@echo 'SBTFLAGS :' $(SBTFLAGS)
@echo 'MAIN :' $(MAIN)
@echo 'TOPMOD :' $(TOPMOD)
@echo 'SRCDIR :' $(SRCDIR)
@echo 'TESTDIR :' $(TESTDIR)
@echo 'RTLDIR :' $(RTLDIR)
@echo 'SYNTHDIR :' $(SYNTHDIR)
@echo 'F4PGADIR :' $(F4PGADIR)
@echo 'DIRS :' $(DIRS)
@echo 'SRCS :' $(SRCS)
@echo 'TESTS :' $(TESTS)
@echo 'RTLFILE :' $(RTLFILE)
@echo 'MAINTARGET :' $(MAINTARGET)
@echo 'TESTTARGET :' $(TESTTARGET)
@echo 'BOARD :' $(BOARD)