50 lines
1.5 KiB
Makefile
50 lines
1.5 KiB
Makefile
PODMAN_RUN=podman run --mount=type=bind,source=.,target=/root/code
|
|
PODMAN_IMAGE=localhost/fmn-toolchain
|
|
PODMAN=$(PODMAN_RUN) $(PODMAN_IMAGE)
|
|
BUILD=build
|
|
|
|
create-image:
|
|
podman build -t fmn-toolchain .
|
|
|
|
run:
|
|
podman run --rm localhost/fmn-toolchain
|
|
|
|
CONSTRAINTS=example/adder.xdc
|
|
SYSTEM_VERILOG=$(shell find example -name "*.sv")
|
|
VERILOG=$(shell find example -name "*.v")
|
|
SOURCES=$(patsubst %,$(BUILD)/%,$(VERILOG)) $(patsubst %.sv,$(BUILD)/%.v,$(SYSTEM_VERILOG))
|
|
|
|
$(BUILD):
|
|
mkdir -p $(BUILD)
|
|
|
|
$(BUILD)/%.v: %.sv
|
|
mkdir -p $(dir $@)
|
|
$(PODMAN) sv2v $^ -w $@
|
|
|
|
$(BUILD)/%.v: %.v
|
|
mkdir -p $(dir $@)
|
|
cp $^ $@
|
|
|
|
$(BUILD)/synthesis.json: $(SOURCES)
|
|
$(PODMAN) yosys $^ -p "synth_xilinx; write_json $@"
|
|
|
|
$(BUILD)/out.fasm: $(BUILD)/synthesis.json
|
|
$(PODMAN) nextpnr-himbaechel --json $(filter %.json,$^) -o xdc=$(CONSTRAINTS) -o fasm=$@ --device xc7z010clg400-1
|
|
|
|
$(BUILD)/out.frames: $(BUILD)/out.fasm
|
|
$(PODMAN) fasm2frames --part xc7z010clg400-1 --db-root /usr/share/xray/database/zynq7 $^ $@
|
|
|
|
$(BUILD)/out.bin: $(BUILD)/out.frames
|
|
$(PODMAN) xc7frames2bit -frm_file $^ -part_file /usr/share/xray/database/zynq7/xc7z010clg400-1/part.yaml --output_file $@
|
|
|
|
bitstream: $(BUILD) $(BUILD)/out.bin
|
|
|
|
flash: bitstream
|
|
$(eval USB = $(shell lsusb -d 0403:6010 | sed -E "s/Bus ([0-9]{3}) Device ([0-9]{3}).*/\/dev\/bus\/usb\/\1\/\2/g"))
|
|
@if [ "$(USB)" = "" ]; then \
|
|
echo "No USB device found !"; \
|
|
else \
|
|
$(PODMAN_RUN) --device=$(USB) \
|
|
$(PODMAN_IMAGE) openFPGALoader -b zybo_z7_10 $(BUILD)/out.bin; \
|
|
fi
|