-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
59 lines (42 loc) · 1.68 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
# Use Docker images
# DOCKER = docker
DOCKER = podman
DOCKERARGS = run --rm -v /"$(PWD)"://wrk -w //wrk
GHDL = $(DOCKER) $(DOCKERARGS) docker.io/hdlc/ghdl:yosys ghdl
GHDLSYNTH = ghdl
YOSYS = $(DOCKER) $(DOCKERARGS) docker.io/hdlc/ghdl:yosys yosys
NEXTPNR = $(DOCKER) $(DOCKERARGS) docker.io/hdlc/nextpnr:ice40 nextpnr-ice40
ICEPACK = $(DOCKER) $(DOCKERARGS) docker.io/hdlc/icestorm:latest icepack
ICETIME = $(DOCKER) $(DOCKERARGS) docker.io/hdlc/icestorm:latest icetime
ICEPROG = $(DOCKER) $(DOCKERARGS) --device /dev/bus/usb docker.io/hdlc/prog:latest iceprog
OPENFPGALOADER = $(DOCKER) $(DOCKERARGS) --device /dev/bus/usb docker.io/hdlc/openfpgaloader:latest openFPGALoader
# Parameters
PROJ ?= counter
PIN_DEF = constraints/alhambra2.pcf
DEVICE = hx4k
PACKAGE = tq144
STYLE = style/my_style.yaml
TOPLVL = TOP
GHDLARGS = --std=08
SRC += src/top.vhdl
SRC += src/counter.vhdl
all: build/$(PROJ).bit
build/$(PROJ).json: $(SRC)
mkdir -p build
$(YOSYS) -m $(GHDLSYNTH) -p 'ghdl $(GHDLARGS) $^ -e $(TOPLVL); synth_ice40 -json $@'
build/$(PROJ).asc: $(PIN_DEF) build/$(PROJ).json
$(NEXTPNR) --$(DEVICE) --json build/$(PROJ).json --pcf $(PIN_DEF) --asc $@ --placed-svg build/placement.svg --routed-svg build/routing.svg
build/$(PROJ).bit: build/$(PROJ).asc
$(ICEPACK) $< $@
report: build/$(PROJ).asc
$(ICETIME) -d $(DEVICE) -p $(PIN_DEF) -P $(PACKAGE) -mtr build/timing.txt $<
prog: build/$(PROJ).bit
# $(ICEPROG) -d i:0x0403:0x6010:0 $<
$(OPENFPGALOADER) --board ice40_generic $<
clean:
rm -rf build
rm -f work-obj*.cf
format: $(SRC)
vsg -f $^ -c $(STYLE) --fix
.PHONY: all clean format prog report
.PRECIOUS: build/$(PROJ).json build/$(PROJ).bit