-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathMakefile.old
68 lines (58 loc) · 2.3 KB
/
Makefile.old
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
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$(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)
gowin_pack -d $(DEVICE_PACK) -o $@ $(NAME).pack
.PHONY: gui
gui: $(CST) $(DEPS)
yosys -g -p "verilog_defaults -add -I$(INC)" $(READ_VERILOG) -p "synth_gowin -json $(NAME).json -top top" -p "hierarchy -check -top top" -p "proc" -p "show -prefix $(NAME) -notitle -colors 2 -width -format dot"
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; \
else \
echo "Firefox is not installed, cannot show you SVG files:"; \
ls -al $(NAME).svg $(NAME)-placed.svg $(NAME)-routed.svg; \
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