File: Makefile

package info (click to toggle)
prjtrellis 1.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 83,000 kB
  • sloc: cpp: 20,813; python: 16,246; sh: 375; makefile: 262; asm: 80; ansic: 58
file content (50 lines) | stat: -rw-r--r-- 1,392 bytes parent folder | download
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
PROJ ?= blinky
TRELLIS_ROOT ?= ../..
export DEV_PACKAGE ?= QFN32
export JEDEC_BITSTREAM ?= 1
export COMPRESSED_BITSTREAM ?= 1

all: ${PROJ}.bit ${PROJ}-nextpnr.bit ${PROJ}.txt ${PROJ}-nextpnr.txt

# Get proportion of known bits.
stats:
	@python3 -c "import sys; print(\"{:.3f}\".format(int(sys.argv[1]) / int(sys.argv[2])))" \
		`grep -e arc -e word -e enum ${PROJ}.txt | wc -l` \
		`grep -e arc -e word -e enum -e unknown  ${PROJ}.txt | wc -l`

# Avoid intermediate files from being deleted.
.PRECIOUS: %.txt %.bit %-roundtrip.txt %-roundtrip.bit %-comp.txt %-comp-roundtrip.bit

# Test that a bitstream from Diamond survives a round-trip from .bit to .txt
# back to .bit and .txt again.
%-roundtrip.bit: %.txt
	ecppack --db ${TRELLIS_ROOT}/database $< $@

%-comp-roundtrip.bit: %-comp.txt
	ecppack --db ${TRELLIS_ROOT}/database --compress $< $@

%.txt: %.bit
	ecpunpack --db ${TRELLIS_ROOT}/database --input $< --textcfg $@

# Diamond rules.
%.bit: %.v %.lpf
	${TRELLIS_ROOT}/diamond.sh LCMXO2-1200HC ${PROJ}.v

# FOSS rules.
# yosys
%.json: %.v %.lpf
	@true

# ecppack --db ${TRELLIS_ROOT}/database --input $< $@
%-nextpnr.bit: %-nextpnr.txt
	@true

# nextpnr-generic
${PROJ}-nextpnr.txt: ${PROJ}.json
	@true

clean:
	rm -rf ${PROJ}.tmp ${PROJ}_out.ncl ${PROJ}*.bit ${PROJ}.jed ${PROJ}.dump \
		${PROJ}.twr ${PROJ}*.txt ${PROJ}.json ${PROJ}-nextpnr.* ${PROJ}*.hex

.PHONY: all stats clean