2021-08-31 17:38:28 +08:00
|
|
|
# Project setup
|
2021-12-26 16:53:27 +08:00
|
|
|
PROJ = syrostan_fpga
|
2021-08-31 17:38:28 +08:00
|
|
|
BUILD = ./build
|
|
|
|
DEVICE = 8k
|
|
|
|
FOOTPRINT = ct256
|
|
|
|
|
|
|
|
# Files
|
|
|
|
FILES = top.v
|
|
|
|
|
|
|
|
.PHONY: all clean burn
|
|
|
|
|
|
|
|
all:
|
|
|
|
# if build folder doesn't exist, create it
|
|
|
|
mkdir -p $(BUILD)
|
|
|
|
# synthesize using Yosys
|
|
|
|
yosys -p "synth_ice40 -top top -blif $(BUILD)/$(PROJ).blif" $(FILES)
|
|
|
|
# Place and route using arachne
|
|
|
|
arachne-pnr -d $(DEVICE) -P $(FOOTPRINT) -o $(BUILD)/$(PROJ).asc -p pinmap.pcf $(BUILD)/$(PROJ).blif
|
|
|
|
# Convert to bitstream using IcePack
|
|
|
|
icepack $(BUILD)/$(PROJ).asc $(BUILD)/$(PROJ).bin
|
|
|
|
|
2021-12-26 16:53:27 +08:00
|
|
|
# Convert bin file to hex C array
|
|
|
|
xxd -i $(BUILD)/$(PROJ).bin fpga_bin.h
|
|
|
|
echo "const $$(cat fpga_bin.h)" > fpga_bin.h
|
|
|
|
mv fpga_bin.h ../Core/Inc/User/fpga_bin.h
|
|
|
|
|
2021-08-31 17:38:28 +08:00
|
|
|
burn:
|
|
|
|
iceprog $(BUILD)/$(PROJ).bin
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm build/*
|
2021-12-26 16:53:27 +08:00
|
|
|
|
|
|
|
hex:
|
|
|
|
xxd -i $(BUILD)/$(PROJ).bin fpga_bin.h
|
|
|
|
echo "const $$(cat fpga_bin.h)" > fpga_bin.h
|
|
|
|
mv fpga_bin.h ../Core/Inc/User/fpga_bin.h
|