# Note: Yosys chokes on spaces in library directories (reported to yosys)
# Library path if not overriden (environment)
NEXTPNR_OPTS=--up5k --package sg48
ICETIME_OPTS=-d up5k
FN=bldc

${FN}.bin: ${FN}.asc
	icepack ${FN}.asc ${FN}.bin

${FN}.json: ${FN}.v
	./run_yosys.sh ${FN}

${FN}.asc: ${FN}.json ${FN}.pcf
	nextpnr-ice40 ${NEXTPNR_OPTS} --pcf "${FN}.pcf" --json "${FN}.json" --asc "${FN}.asc"

#${FN}.rpt: ${FN}.pcf ${FN}.txt
#	icetime $ICETIME_OPTS -p "${FN}.pcf" -mtr "${FN}.rpt" "${FN}.txt"

clean:
	rm ${FN}.json ${FN}.asc ${FN}.bin

flash: $FN.bin