filename = top
pcf_file = io.pcf

RPI_USER=pi
RPI_IP=192.168.10.90
RPI_DIR=/home/pi/ice40/build2

build:
	yosys -p "synth_ice40 -blif $(filename).blif" $(filename).v
	arachne-pnr -d 5k -P sg48 -p $(pcf_file) $(filename).blif -o $(filename).asc
	icepack $(filename).asc $(filename).bin

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

prog_flash:
	iceprog $(filename).bin

rpi_prog: build
	scp $(filename).bin $(RPI_USER)@$(RPI_IP):$(RPI_DIR)
	ssh $(RPI_USER)@$(RPI_IP) "cd $(RPI_DIR); iceprog $(filename).bin" 

clean:
	rm -rf $(filename).blif $(filename).asc $(filename).bin
