-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile.icestorm
80 lines (61 loc) · 1.4 KB
/
Makefile.icestorm
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
DEVICE-upduino ?= up5k
FOOTPRINT-upduino ?= sg48
PIN_SRC-upduino ?= upduino_v2.pcf
DEVICE-icebreaker ?= up5k
FOOTPRINT-icebreaker ?= sg48
PIN_SRC-icebreaker ?= icebreaker.pcf
DEVICE-tinyfpga := lp8k
FOOTPRINT-tinyfpga := cm81
PIN_SRC-tinyfpga := tinyfpga-bx.pcf
DEVICE-tomu := up5k
FOOTPRINT-tomu := uwg30
PIN_SRC-tomu := tomu.pcf
USB_DEV ?= 1-1:1.0
BOARD ?= upduino
DEVICE := $(DEVICE-$(BOARD))
FOOTPRINT := $(FOOTPRINT-$(BOARD))
PIN_SRC := $(PIN_SRC-$(BOARD))
PNR ?= $(ICEPATH)nextpnr-ice40
.SECONDARY:
%.flash: %.bin
$(ICEPATH)iceprog -e 128 # Force a reset
$(ICEPATH)iceprog $<
echo $(USB_DEV) | tee /sys/bus/usb/drivers/ftdi_sio/bind
%.bin: %.asc
$(ICEPATH)icepack $< $@
%.json: %.v
$(ICEPATH)yosys \
-q \
-p 'read_verilog $<' \
-p 'synth_ice40 -top top -json $@' \
-E .$(basename $@).d \
%.asc: $(PIN_SRC) %.json
$(PNR) \
--$(DEVICE) \
--package $(FOOTPRINT) \
--asc $@ \
--pcf $(PIN_SRC) \
--json $(basename $@).json \
%.gui: %.json
$(PNR) --gui --$(DEVICE) --pcf $(PIN_SRC) --json $<
%.bin: %.asc
$(ICEPATH)icepack $^ $@
# Generate a desired MHz pll
pll_%.v:
$(ICEPATH)icepll \
-i 48 \
-o $(subst pll_,,$(basename $@)) \
-m \
-n $(basename $@) \
-f $@
define make-test =
$1: $1.vvp
vvp $$<
endef
test: $(TEST-y)
$(foreach t,$(TEST-y),$(eval $(call make-test,$t)))
%.vvp:
iverilog -o $@ -s $(basename $@) $^
clean:
$(RM) *.blif *.asc *.bin *.json .*.d
-include .*.d