-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.comman
More file actions
61 lines (45 loc) · 1.65 KB
/
Copy pathMakefile.comman
File metadata and controls
61 lines (45 loc) · 1.65 KB
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
# ===============================
# Common GateMate FPGA Makefile (future-proof + help)
# ===============================
# Must be set in project Makefile:
# PROJECT = project_name
# TOP = top_module
DEVICE ?= CCGM1A1
OUTDIR ?= $(CURDIR)/build
SRC = $(wildcard $(CURDIR)/*.v)
JSON = $(OUTDIR)/$(PROJECT).json
NETLIST = $(OUTDIR)/$(PROJECT)_post.v
CCF = $(PROJECT).ccf
TXT = $(OUTDIR)/$(PROJECT).txt
BIT = $(OUTDIR)/$(PROJECT).bit
.PHONY: all build clean proj synth pnr pack help
all: build ## Default: build the full FPGA bitstream
# ------------------------------
# Build chain
# ------------------------------
build: $(BIT) ## Run synth → pnr → pack
# ------------------------------
# Rules with dependencies
# ------------------------------
synth: $(JSON) ## Run synthesis (yosys)
$(JSON) $(NETLIST): $(SRC)
@mkdir -p $(OUTDIR)
yosys -p "read_verilog $(SRC); synth_gatemate -top $(TOP) -luttree -nomx8; write_json $(JSON); write_verilog $(NETLIST)"
pnr: $(TXT) ## Run place & route (nextpnr)
$(TXT) $(CCF): $(JSON)
nextpnr-himbaechel --device=$(DEVICE) --json $(JSON) \
-o ccf=$(CCF) -o out=$(TXT) --router router2
pack: $(BIT) ## Pack routing results into bitstream
$(BIT): $(TXT)
gmpack $(TXT) $(BIT)
proj: $(BIT) ## Program FPGA with generated bitstream
openFPGALoader --index-chain 0 --cable dirtyJtag $(BIT)
clean: ## Remove build artifacts
rm -rf $(OUTDIR)
# ------------------------------
# Help system
# ------------------------------
help: ## Show this help
@echo "Available targets:"
@grep -hE '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " make %-10s # %s\n", $$1, $$2}'