summaryrefslogtreecommitdiffstats
path: root/src/evb-yosys-demo/ice40-io-video/Makefile
blob: 8b5a9b1d14c035890f69961fc8e798cdb8ce17e7 (plain)
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
PREFIX=../../..

YOSYS=${PREFIX}/bin/yosys
NEXTPNR=${PREFIX}/bin/nextpnr-ice40
ICEPACK=${PREFIX}/bin/icepack
ICETIME=${PREFIX}/bin/icetime
FLASH=${PREFIX}/bin/flash

BUILDDIR  = ./build
FPGA_TYPE = hx8k
FPGA_PKG  = ct256
PCF       = ice40-io-video.pcf
RMDIR     = rmdir

# Targets
example: $(BUILDDIR)/example.rpt $(BUILDDIR)/example.bin
example_0: $(BUILDDIR)/example_0.rpt $(BUILDDIR)/example_0.bin
example_1: $(BUILDDIR)/example_1.rpt $(BUILDDIR)/example_1.bin
example_2: $(BUILDDIR)/example_2.rpt $(BUILDDIR)/example_2.bin
example_3: $(BUILDDIR)/example_3.rpt $(BUILDDIR)/example_3.bin
example_4: $(BUILDDIR)/example_4.rpt $(BUILDDIR)/example_4.bin
example_5: $(BUILDDIR)/example_5.rpt $(BUILDDIR)/example_5.bin
example_6: $(BUILDDIR)/example_6.rpt $(BUILDDIR)/example_6.bin
example_7: $(BUILDDIR)/example_7.rpt $(BUILDDIR)/example_7.bin

flash: $(BUILDDIR)/example.bin
	${FLASH} ${BUILDDIR}/example.bin


$(BUILDDIR)/%.json: %.v
	@mkdir -p $(@D)
	${YOSYS} -ql $(subst .json,,$@).log -p 'synth_ice40 -abc9 -device u -top top -json $@' $<

%.asc: %.json
	${NEXTPNR} --${FPGA_TYPE} --package ${FPGA_PKG} --json $< --pcf ${PCF} --asc $@

%.bin: %.asc
	${ICEPACK} $< $@

%.rpt: %.asc
	${ICETIME} -d $(FPGA_TYPE) -mtr $@ $<

all: example example_0 example_1 example_2 example_3 example_4 example_5 example_6 example_7

clean:
	rm -f $(BUILDDIR)/*.asc $(BUILDDIR)/*.bin $(BUILDDIR)/*.rpt $(BUILDDIR)/*.log $(BUILDDIR)/*.json
	$(RMDIR) $(BUILDDIR)

# Uncomment this line if you want to keep the intermediate .json and .asc files
# .PRECIOUS: $(BUILDDIR)/%.json %.asc

.PHONY: all prog clean example example_0 example_1 example_2 example_3 example_4 example_5 example_6 example_7