-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile
124 lines (83 loc) · 2.98 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Video mode selection:
#
# Supported video modes:
# - VM_640x480 (25Mhz)
# - VM_848x480 (33.75MHz)
# VIDEO_MODE = VM_640x480
VIDEO_MODE = VM_848x480
###
# Boot firmware rules
include ../firmware/boot.mk
###
ICEBREAKER_PREFIX = icebreaker
ULX3S_PREFIX = ulx3s
DEFAULT_PREFIX = $(ICEBREAKER_PREFIX)
### Device specific
ICE40_DEVICE = up5k
ICE40_PACKAGE = sg48
ECP5_PACKAGE = CABGA381
ECP5_SIZE = 85
###
ICEBREAKER_PIN_DEF = icebreaker/icebreaker.pcf
ULX3S_PIN_DEF = ulx3s/ulx3s_v20.lpf
icebreaker.json: TOP = ics32_top_icebreaker
ulx3s.json: TOP = ics32_top_ulx3s
count: TOP = ics32_top_icebreaker
include sources.mk
icebreaker.json: SOURCES += $(ICEBREAKER_SOURCES) icebreaker/$(TOP).v
ulx3s.json: SOURCES += $(ULX3S_SOURCES) ulx3s/$(TOP).v
count: SOURCES += $(ICEBREAKER_SOURCES) icebreaker/$(TOP).v
# Timing constraints vary according to video mode
TIMING_PY := constraints/$(VIDEO_MODE).py
ifeq ($(VIDEO_MODE), VM_848x480)
ENABLE_WIDESCREEN = 1
else
ENABLE_WIDESCREEN = 0
endif
### Supported board targets:
icebreaker: icebreaker.bit
ulx3s: ulx3s.bit
.PHONY: icebreaker ulx3s
###
define synth
yosys $(YOSYS_DEFINE_ARGS) -p \
'chparam -set ENABLE_WIDESCREEN $(ENABLE_WIDESCREEN) $(TOP); \
$(YOSYS_SYNTH_COMMAND) $(YOSYS_SYNTH_FLAGS) $1' \
$(SOURCES)
endef
icebreaker.json: YOSYS_SYNTH_COMMAND = synth_ice40
ulx3s.json: YOSYS_SYNTH_COMMAND = synth_ecp5
count: YOSYS_SYNTH_COMMAND = synth_ice40
icebreaker.json: YOSYS_SYNTH_FLAGS = -dffe_min_ce_use 4 -dsp -top $(TOP)
ulx3s.json: YOSYS_SYNTH_FLAGS = -top $(TOP)
count: YOSYS_SYNTH_FLAGS = -dffe_min_ce_use 4 -dsp -top $(TOP)
icebreaker.json: BOOT_HEX_SELECTED = $(BOOT_HEX)
ulx3s.json: BOOT_HEX_SELECTED = $(BOOT_MULTI_HEX)
YOSYS_DEFINE_ARGS = -f 'verilog -DBOOTLOADER="$(BOOT_HEX_SELECTED)"'
### Common ###
ulx3s.json: $(SOURCES) $(ULX3S_SOURCES) ulx3s/ics32_top_ulx3s.v $(BOOT_MULTI_HEX) $(BOOT_MULTI_NOIPL_BIN)
$(call synth, -json $@)
icebreaker.json: $(SOURCES) $(ICEBREAKER_SOURCES) icebreaker/ics32_top_icebreaker.v $(BOOT_HEX)
$(call synth, -json $@)
count: $(SOURCES) $(BOOT_HEX)
$(call synth, -noflatten)
clean: boot_clean
rm -f \
$(ICEBREAKER_PREFIX).asc $(ICEBREAKER_PREFIX).rpt $(ICEBREAKER_PREFIX).bit $(ICEBREAKER_PREFIX).json \
$(ULX3S_PREFIX).config $(ULX3S_PREFIX).bit $(ULX3S_PREFIX).json $(ULX3S_PREFIX)_pnr.json
### iCE40 ###
%.asc: $(ICEBREAKER_PIN_DEF) %.json
nextpnr-ice40 --$(ICE40_DEVICE) --package $(ICE40_PACKAGE) --json $(filter-out $<,$^) --placer heap --pcf $< --asc $@ --pre-pack $(TIMING_PY) --seed 0
icebreaker.bit: icebreaker.asc
icepack $< $@
icebreaker_prog: $(ICEBREAKER_PREFIX).bit
iceprog $<
### ECP5 ###
%.config: $(ULX3S_PIN_DEF) %.json
nextpnr-ecp5 --package $(ECP5_PACKAGE) --$(ECP5_SIZE)k --json $(filter-out $<,$^) --placer heap --lpf $< --textcfg $@ --write $(@:.config=_pnr.json) --pre-pack $(TIMING_PY) --seed 0
ulx3s.bit: ulx3s.config
ecppack --input $< --bit $@
ulx3s_prog: $(ULX3S_PREFIX).bit
fujprog -j flash $<
.SECONDARY:
.PHONY: main-build icebreaker_prog ulx3s_prog clean count