blob: 8a68e1f9d30c5f7c36f695fcc51e62e59a55c577 (
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
|
PREFIX=../..
BINDIR=${PREFIX}/bin
YOSYS=${BINDIR}/yosys
NEXTPNR=${BINDIR}/nextpnr-ice40
ICEPACK=${BINDIR}/icepack
ICETIME=${BINDIR}/icetime
FLASH=${BINDIR}/flash
GHDL=${BINDIR}/ghdl
BUILDDIR = ./build
FPGA_TYPE = hx8k
FPGA_PKG = ct256
PCF = ice40hx8k-evb.pcf
RMDIR = rmdir
# Targets
top: $(BUILDDIR)/top.rpt $(BUILDDIR)/top.bin
flash: $(BUILDDIR)/top.bin
${FLASH} $(BUILDDIR)/top.bin
$(BUILDDIR)/%.json: %.vhd
@mkdir -p $(@D)
${YOSYS} -m ghdl -ql $(subst .json,,$@).log -p 'ghdl $< -e ${<:%.vhd=%}; 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: top
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 top
|