-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile.icestorm
103 lines (85 loc) · 2.01 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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-4:1.0
BOARD ?= upduino
DEVICE := $(DEVICE-$(BOARD))
FOOTPRINT := $(FOOTPRINT-$(BOARD))
PIN_SRC := $(PIN_SRC-$(BOARD))
FPGA ?= FPGA_ICE40UP5K
PNR ?= $(ICEPATH)nextpnr-ice40
.SECONDARY:
%.flash: %.bit
$(ICEPATH)iceprog -e 128 # Force a reset
$(ICEPATH)iceprog $<
echo $(USB_DEV) | tee /sys/bus/usb/drivers/ftdi_sio/bind
sleep 1
-stty -F /dev/ttyUSB0 1:0:1cbd:0:3:1c:7f:15:4:5:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
%.bit: %.asc
$(ICEPATH)icepack $< $@
%.json: %.v
$(ICEPATH)yosys \
-q \
-D$(FPGA) \
-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 \
--timing-allow-fail \
%.gui: %.json
$(PNR) --gui --$(DEVICE) --pcf $(PIN_SRC) --json $<
%.bit: %.asc
cp $< $<.new
for bram in $(filter %.hex,$^); do \
echo "Replacing $$bram" ; \
$(ICEPATH)icebram \
$$(basename $$bram .hex).syn.hex \
$$bram \
< $<.new > $<.tmp \
|| exit 1 ; \
mv $<.tmp $<.new ; \
done
$(ICEPATH)icepack $<.new $@
$(RM) $<.new
# 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 $$<
$1.vvp: $1.v
endef
test: $(TEST-y)
$(foreach t,$(TEST-y),$(eval $(call make-test,$t)))
%.vvp:
iverilog \
-o $@ \
-s top \
-D "RISC8_PROGRAM=\"$(PROGRAM)\"" \
-M $(dir $@).$(basename $@).m \
$^
sed -i -e '1s/^/$@: /' -e 's/$$/ \\/' $(dir $@).$(basename $@).m
mv $(dir $@).$(basename $@).m $(dir $@).$(basename $@).d
clean:
$(RM) *.blif *.asc *.bin *.json .*.d
-include .*.d