Skip to content

Commit

Permalink
Generalize blinky Makefile, align with other examples
Browse files Browse the repository at this point in the history
  • Loading branch information
meriac committed Dec 2, 2023
1 parent 7316322 commit f215c85
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
2 changes: 2 additions & 0 deletions examples/colorlight_i9plus/blinky/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*.zip
/*.bin
/*.bit
/*.fasm
/*.frames
Expand Down
45 changes: 28 additions & 17 deletions examples/colorlight_i9plus/blinky/Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
DB_DIR=${PREFIX}/share/nextpnr/external/prjxray-db

PART = xc7a50tfgg484-1
ARCH:=artix7
BOARD:=arty
PART:=xc7a50tfgg484-1
PROJECT:=blinky

ZIP_FILE:=$(PROJECT)-bitstream.zip
BIT_FILE:=$(PROJECT).bit
CHIPDB:=$(PWD)

.PHONY: all
all: blinky.bit
all: $(ZIP_FILE)

.PHONY: program
program: blinky.bit
openFPGALoader --board arty --bitstream $<
program: $(PROJECT).bit
openFPGALoader --board $(BOARD) --bitstream $<

$(ZIP_FILE): $(BIT_FILE)
zip -j9 $@ $^

blinky.json: blinky.v
yosys -p "synth_xilinx -flatten -abc9 -nobram -arch xc7 -top blinky; write_json blinky.json" $<
$(PROJECT).json: $(PROJECT).v
yosys -p "synth_xilinx -flatten -abc9 -nobram -arch xc7 -top $(PROJECT); write_json $@" $<

# The chip database only needs to be generated once
# that is why we don't clean it with make clean
${CHIPDB}/${PART}.bin:
pypy3 $(PREFIX)/share/nextpnr/python/bbaexport.py --device ${PART} --bba ${PART}.bba
bbasm -l ${PART}.bba ${CHIPDB}/${PART}.bin
bbasm -l ${PART}.bba $@
rm -f ${PART}.bba

blinky.fasm: blinky.json ${CHIPDB}/${PART}.bin
nextpnr-xilinx --chipdb ${CHIPDB}/${PART}.bin --xdc blinky.xdc --json blinky.json --fasm $@ --verbose --debug
$(PROJECT).fasm: $(PROJECT).json ${CHIPDB}/${PART}.bin $(PROJECT).xdc
nextpnr-xilinx --chipdb ${CHIPDB}/${PART}.bin --xdc $(PROJECT).xdc --json $< --fasm $@ --verbose --debug

blinky.frames: blinky.fasm
fasm2frames --part ${PART} --db-root ${DB_DIR}/artix7 $< > $@
$(PROJECT).frames: $(PROJECT).fasm
fasm2frames --part ${PART} --db-root ${DB_DIR}/$(ARCH) $< > $@

blinky.bit: blinky.frames
xc7frames2bit --part_file ${DB_DIR}/artix7/${PART}/part.yaml --part_name ${PART} --frm_file $< --output_file $@
$(BIT_FILE): $(PROJECT).frames
xc7frames2bit --part_file ${DB_DIR}/$(ARCH)/${PART}/part.yaml --part_name ${PART} --frm_file $< --output_file $@

.PHONY: clean
clean:
@rm -f *.bit
@rm -f *.frames
@rm -f *.fasm
@rm -f *.json
@rm -f $(ZIP_FILE) $(PROJECT).bit $(PROJECT).frames $(PROJECT).fasm $(PROJECT).json

.PHONY: clean_all
clean_all: clean
@rm -f ${CHIPDB}/${PART}.bin

0 comments on commit f215c85

Please sign in to comment.