buildpath = build/
filename = uart_test
files = top.v
pcf_file = io.pcf

.PHONY: build prog prog_flash clean

build:
	#yosys -p "synth_ice40 -blif $(buildpath)$(filename).blif -top top" $(files)
	#arachne-pnr -r -d 5k -P sg48 -p $(pcf_file) $(buildpath)$(filename).blif -o $(buildpath)$(filename).asc
	yosys -p "synth_ice40 -json $(buildpath)$(filename).json -top top" $(files)
	nextpnr-ice40 --up5k --json $(buildpath)$(filename).json --pcf $(pcf_file) --asc $(buildpath)$(filename).asc
	icepack $(buildpath)$(filename).asc $(buildpath)$(filename).bin

prog: build #for sram
	iceprog -S $(buildpath)$(filename).bin

prog_flash: build
	iceprog $(buildpath)$(filename).bin

clean:
	rm -rf $(buildpath)/*