-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathMakefile
76 lines (66 loc) · 2.77 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
CST = board_specific.cst
FREQ = 27
DEVICE_PART := GW1NR-LV9QN88PC6/I5
DEVICE_PACK := GW1N-9C
DEVICE_FAMILY := GW1N-9C
#
FLASH_METHOD := $(shell cat flash_method 2> /dev/null)
UPLOAD_METHOD := $(shell cat upload_method 2> /dev/null)
.PHONY: clean
all: $(NAME).bin
.PHONY: upload
upload: $(NAME).bin
ifeq ("$(UPLOAD_METHOD)", "openloader")
$(MAKE) upload_openloader
else
ifeq ("$(UPLOAD_METHOD)", "")
echo "Upload method has not been chosen, use 'bash 04_configure_fpga.bash'"
else
echo "Unsupported upload method: $(UPLOAD_METHOD), use 'bash 04_configure_fpga.bash'"
endif
endif
.PHONY: upload_openloader
upload_openloader:
ifeq ("$(FLASH_METHOD)", "flash")
openFPGALoader -v -b tangnano -f --reset --file-type fs $(NAME).bin
else
openFPGALoader -v -b tangnano --file-type fs $(NAME).bin
endif
fw: $(NAME).bin
$(NAME).bin: $(CST) $(DEPS)
yosys -g -p "verilog_defaults -add -I$(subst :, -I,$(INC))" $(READ_VERILOG) -p "synth_gowin -json $(NAME).json -top board_specific_top"
#nextpnr-gowin --enable-globals --freq $(FREQ) --device $(DEVICE_PART) --family $(DEVICE_FAMILY) --json $(NAME).json --write $(NAME).pack --cst $(CST)
nextpnr-himbaechel --json $(NAME).json --write $(NAME).pack --device $(DEVICE_PART) --vopt family=$(DEVICE_FAMILY) --vopt cst=$(CST)
gowin_pack -d $(DEVICE_PACK) -o $@ $(NAME).pack
.PHONY: gui
gui: $(LPF) $(DEPS)
yosys -p "verilog_defaults -add -I$(subst :, -I,$(INC))" $(READ_VERILOG) -p "read_verilog +/gowin/cells_sim.v" -p "hierarchy -check -top board_specific_top" -p "proc; opt; fsm; memory; opt" -p "show -prefix $(NAME) -notitle -colors 2 -width -format dot"
@if [ -f "`which dot`" ]; then \
echo "Generating PDFs with schematics..."; \
dot -Tpdf -O $(NAME).dot; \
else \
echo "Note: 'dot' utility is not installed, PDF won't be generated!"; \
fi
@echo "Generating SVGs with routing and placement..."
netlistsvg -o $(NAME).svg $(NAME).json
#nextpnr-gowin --enable-globals --freq $(FREQ) --device $(DEVICE_PART) --family $(DEVICE_FAMILY) --json $(NAME).json --write $(NAME).pack --cst $(CST) --placed-svg $(NAME)-placed.svg --routed-svg $(NAME)-routed.svg
@if [ -f "`which firefox`" ]; then \
firefox $(NAME).svg $(NAME)-placed.svg $(NAME)-routed.svg $(NAME).*pdf; \
else \
echo "Firefox is not installed, cannot show you SVG and PDF files:"; \
ls -al $(NAME).svg $(NAME)-placed.svg $(NAME)-routed.svg $(NAME).*pdf; \
fi
@if [ -f "`which xdot`" ]; then \
xdot $(NAME).dot; \
else \
echo "xdot utility is not installed, cannot show you DOT file:"; \
ls -al $(NAME).dot; \
fi
.PHONY: sim
sim: $(NAME).v $(DEPS) $(NAME)_tb.v $(shell yosys-config --datdir)/ice40/cells_sim.v
iverilog $^ -o $(NAME)_tb.out
./$(NAME)_tb.out
gtkwave $(NAME)_tb.vcd $(NAME)_tb.gtkw &
.PHONY: clean
clean:
rm -f *.bin *.txt *.blif *.out *.svg *.dot *.dfu *out.config