Makefile 6.84 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
### FIJI Demo Makefile
# Leads through a possible FIJI flow:
# 1. Synthesize original design to vqm netlist
# 2  generate/edit a fiji configuration file
# 3. generate an instrumented netlist + wrapper/pkg VHD files
# 4. lead through synplify project creation
# 5. lead through quartus project creation
# 6. P&R the modified netlist
# 7. Program FPGA with FIJI bitstream
# 8. execute FIJI test patterns (random, auto, manual)


## Select the used board by setting BOARD= as a commandline argument
## Select the used testcase by setting FIJI_PROJECT_NAME= as a commandline argumetn

# Environment setup
SHELL=/bin/bash
EDITOR?=nano
DBG?=no
20
BOARD?=basys3
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
PERLFLAGS=-I $(FIJI_SCRIPT_DIR)/FIJI -I $(FIJI_SCRIPT_DIR) -I $(FIJI_SCRIPT_DIR)/Log
# FIJI environment
FIJI_SCRIPT_DIR=../../../bin
FIJI_SETUP=$(FIJI_SCRIPT_DIR)/fiji_setup.pl
FIJI_INSTRUMENT=$(FIJI_SCRIPT_DIR)/fiji_instrument.pl
FIJI_EXECUTE=$(FIJI_SCRIPT_DIR)/fiji_ee.pl
FIJI_EXECUTE_GUI=$(FIJI_SCRIPT_DIR)/fiji_ee_gui.pl

FIJI_DIR=fiji

TOPLEVEL_MODULE=spriteflyer_top
FILE_PREFIX=tmr_vga_demo
FIJI_PORT=/dev/ttyUSB0

include boards/$(BOARD).mk

# Project directories and files
FIJI_PROJECT_DIR=$(FIJI_DIR)/$(FIJI_PROJECT_NAME)
FIJI_OUTPUT_DIR=$(FIJI_PROJECT_DIR)/fiji
Stefan Tauner's avatar
Stefan Tauner committed
40
FIJI_SYNPLIFY_PROJECT=$(FIJI_PROJECT_DIR)/synp/$(TOPLEVEL_MODULE).prj
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
MODIFIED_NETLIST_FILE=$(FIJI_OUTPUT_DIR)/$(FILE_PREFIX)_instrumented.$(NETLIST_SUFFIX)
FIJI_CFG_FILE=$(FIJI_OUTPUT_DIR)/fiji.cfg
TEST_FILE=$(FIJI_OUTPUT_DIR)/$(FIJI_PROJECT_NAME).tst
DOWNLOAD_CFG=$(FIJI_OUTPUT_DIR)/$(FILE_PREFIX)_download.cfg


ifneq ($(DBG),no)
  PERLFLAGS+=-d:ptkdb
endif

# always provide opportunity to edit test and settings files
.PHONY: $(TEST_FILE)

# provide opportunity to edit fiji.cfg and then execute test file
all: setup-launch execute-gui

$(FIJI_CFG_FILE): setup-launch

$(ORIGINAL_NETLIST_FILE):
	@read -p "Press [Enter] after you synthesized the original netlist to $(ORIGINAL_NETLIST_FILE)..."
Stefan Tauner's avatar
Stefan Tauner committed
61
	clear
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

# launch the fiji settings editor GUI
setup-launch: $(ORIGINAL_NETLIST_FILE)
	clear
	@echo
	@echo "    FIJIFIJIFIJIFIJIFIJIFIJIFIJIFIJIFIJIFIJI"
	@echo "    FIJIFIJIFIJIFIJIF   FIJIFIJIFIJIFIJIFIJI"
	@echo "    FIJIFIJIFIJIFIJ    IFIJIFIJIFIJIFIJIFIJI"
	@echo "    FIJIF       FI           IJIFIJIFIJIFIJI"
	@echo "    FIJIFIJIFI            JIFIJIFIJIFIJIFIJI"
	@echo "    FIJIFIJI            FIJIFIJIFIJIFIJIFIJI"
	@echo "    FIJIFI     I   IFI   IJIFIJIFIJIFIJIFIJI"
	@echo "    FIJIF         JIFIJ   JIFIJIFIJIFIJIFIJI"
	@echo "    FIJIFIJIFI   IJIFIJI   IFIJIFIJIFIJIFIJI"
	@echo "    FIJIFIJIF    IJIFIJIFIJIFIJIFIJIFIJIFIJI"
	@echo "    FIJIFIJI    FIJIFIJIFIJIFIJIFIJIFIJIFIJI"
	@echo "    FIJIFIJ     FIJIF           FIJIFIJIFIJI"
	@echo "    FIJIFI     IFI      Fault      IFIJIFIJI"
	@echo "    FIJIF             InJection     FIJIFIJI"
	@echo "    FIJ              Instrumenter    IJIFIJI"
	@echo "    F                                    IJI"
	@echo "    FIJIFIJIFIJIFIJIFIJIFIJIFIJIFIJIFIJIFIJI"
	@echo
	@echo "Press enter to edit the fiji configuration file or enter \"s\" to skip..."
	@read skipedit ; \
	if [ x"$${skipedit}" != x"s" ]; then \
Christian Fibich's avatar
Christian Fibich committed
88
		perl $(PERLFLAGS) $(FIJI_SETUP) --settings=$(FIJI_CFG_FILE) --netlist=$(ORIGINAL_NETLIST_FILE) ; \
89
	fi
Stefan Tauner's avatar
Stefan Tauner committed
90
	clear
91
92
93
94

# Generate the instrumented netlist and wrapper/config VHDL files
$(MODIFIED_NETLIST_FILE): $(ORIGINAL_NETLIST_FILE) $(FIJI_CFG_FILE)
	@echo "Instrumenting for $(MODIFIED_NETLIST_FILE)"
Christian Fibich's avatar
Christian Fibich committed
95
96
	perl $(PERLFLAGS) $(FIJI_INSTRUMENT) --settings=$(FIJI_CFG_FILE) \
                                         --netlist=$(ORIGINAL_NETLIST_FILE) \
97
                                         --file-prefix=$(FILE_PREFIX) \
Christian Fibich's avatar
Christian Fibich committed
98
                                         --output-dir=$(FIJI_OUTPUT_DIR)
Stefan Tauner's avatar
Stefan Tauner committed
99
	@read -p "Instrumentation done. Press [Enter] to continue..."
100
101
102
103
104
105
106
107
108
109
	clear

# Open editor to modify test file
$(TEST_FILE):
	@read -p "Press [Enter] to edit the test file..."
	perl $(PERLFLAGS) $(FIJI_EXECUTE_GUI) -s $(FIJI_CFG_FILE) -t $(TEST_FILE)

# Prompt the user to execute the FPGA bitstream
# TODO: Automatization possible?
program-fpga: $(BITSTREAM_FILE)
Stefan Tauner's avatar
Stefan Tauner committed
110
	clear
111
112
113
114
115
	@read -p "Press [Enter] after you programmed the FPGA..."

# Prompt the user to generate the new Synplify project and display instructions 
# on-screen
# TODO: Automatization possible?
Stefan Tauner's avatar
Stefan Tauner committed
116
117
118
119
120
121
122
123
124
125
126
127
define SYNPLIFY_INSTRUCTIONS
Follow these instructions to generate the Synplify project
$(FIJI_DIR)/$(FIJI_SYNPLIFY_PROJECT):

0. Open terminal in $(FIJI_PROJECT_DIR)/synp"

1. Create a new Synplify project *file* named 'spriteflyer_top.prj' in
the respective directory.

2. Open this project (if not done automatically)

endef
128
$(FIJI_SYNPLIFY_PROJECT):
Stefan Tauner's avatar
Stefan Tauner committed
129
130
131
132
133
134
	$(info $(SYNPLIFY_INSTRUCTIONS))
	@cat $(FIJI_PROJECT_DIR)/synp/README
	@echo "Finally, synthesize the design (F8)."
	@read -p "Press [Enter] when Synplify is done and you are ready..."
	clear

135
136
137
# Prompt the user to generate the new Quartus project and display instructions 
# on-screen
# TODO: Automatization possible?
Stefan Tauner's avatar
Stefan Tauner committed
138
139
define PNR_INSTRUCTIONS
Follow these instructions to generate the Place & Route project
140
$(FIJI_PNR_PROJECT):
Stefan Tauner's avatar
Stefan Tauner committed
141
142
143
144
145
146
147
148

0. Open terminal in $(FIJI_PROJECT_DIR)/$(FIJI_PNR_DIR)

endef

$(FIJI_PNR_PROJECT):
	$(info $(PNR_INSTRUCTIONS))
	@cat $(FIJI_PROJECT_DIR)/$(FIJI_PNR_DIR)/README
149
150
151
152
153
	@read -p "Press [Enter] when you are ready..."

# Prompt the user to place&route the modified netlist + wrapper
# TODO: Automatization possible?
$(BITSTREAM_FILE): $(MODIFIED_NETLIST_FILE) $(FIJI_SYNPLIFY_PROJECT) $(FIJI_PNR_PROJECT) 
Stefan Tauner's avatar
Stefan Tauner committed
154
	clear
155
156
	@echo "Place & Route the modified netlist:"
	@echo '    in Quartus: "Compile Design"'
Stefan Tauner's avatar
Stefan Tauner committed
157
	@echo '    in Vivado: "Generate Bitstream"'
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
	@echo
	@read -p "Press [Enter] when you are ready..."

# Interactive test execution mode
execute-manual: $(BITSTREAM_FILE) $(TEST_FILE) program-fpga
	perl $(PERLFLAGS) $(FIJI_EXECUTE) --mode=manual --settings=$(DOWNLOAD_CFG) --tests=$(TEST_FILE) --port=$(FIJI_PORT)

# Interactive test execution mode
# execute the tests in TEST_FILE
execute-auto: $(BITSTREAM_FILE) $(TEST_FILE) program-fpga
	perl $(PERLFLAGS) $(FIJI_EXECUTE) --mode=auto --settings=$(DOWNLOAD_CFG)  --tests=$(TEST_FILE) --port=$(FIJI_PORT)

# Random test execution mode
# execute random tests generated according the time and fault probability
# constraints
execute-random: $(BITSTREAM_FILE) $(TEST_FILE) program-fpga
	perl $(PERLFLAGS) $(FIJI_EXECUTE) --mode=random --settings=$(DOWNLOAD_CFG) --tests=$(TEST_FILE) \
                                       -a=200000 -A=1000000 \
                                       -b=200000 -B=1000000 \
                                       -0=0.19  \
                                       -1=0.2  \
                                       -d=0.2 \
                                       -f=0.2 \
                                       -o=0.2 --port=$(FIJI_PORT)

execute-gui: $(BITSTREAM_FILE) program-fpga
Stefan Tauner's avatar
Stefan Tauner committed
184
	@echo "Launching Executing Engine GUI with pre-defined test sequence..."
Christian Fibich's avatar
Christian Fibich committed
185
	perl $(PERLFLAGS) $(FIJI_EXECUTE_GUI) --settings=$(DOWNLOAD_CFG) --tests=$(TEST_FILE)
Stefan Tauner's avatar
Stefan Tauner committed
186
187
188
189

MAKEFLAGS += --no-builtin-rules
.SUFFIXES:
.PRECIOUS: %.bit %.sof