-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·181 lines (162 loc) · 5.95 KB
/
Makefile
File metadata and controls
executable file
·181 lines (162 loc) · 5.95 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#-----------------------------------------------------------------------------
# Title : PYNQ-Z2 SNN Accelerator Makefile
# Project : PYNQ-Z2 SNN Accelerator
# File : Makefile
# Author : Jiwoon Lee (@metr0jw)
# Organization : Kwangwoon University, Seoul, South Korea
# Description : Top-level Makefile for the complete SNN accelerator project
#-----------------------------------------------------------------------------
# Project information
PROJECT_NAME = PYNQ-Z2 SNN Accelerator
VERSION = 1.0.0
AUTHOR = Jiwoon Lee (@metr0jw)
# Colors for output
RED := \033[31m
GREEN := \033[32m
YELLOW := \033[33m
BLUE := \033[34m
RESET := \033[0m
# Directories
HARDWARE_DIR = hardware
SOFTWARE_DIR = software
EXAMPLES_DIR = examples
# Tools
VIVADO = vivado
VPP = v++
PYTHON = python3
PIP = pip3
# Default target
.PHONY: all
all: help
# Help target
.PHONY: help
help:
@echo "$(BLUE)================================================$(RESET)"
@echo "$(BLUE)$(PROJECT_NAME) Build System$(RESET)"
@echo "$(BLUE)Version: $(VERSION)$(RESET)"
@echo "$(BLUE)Author: $(AUTHOR)$(RESET)"
@echo "$(BLUE)================================================$(RESET)"
@echo ""
@echo "$(YELLOW)Available targets:$(RESET)"
@echo ""
@echo "$(GREEN)Setup:$(RESET)"
@echo " setup - Complete project setup (recommended)"
@echo " install - Install Python package only"
@echo " clean - Clean all build artifacts"
@echo ""
@echo "$(GREEN)Hardware:$(RESET)"
@echo " hls - Build HLS IP cores"
@echo " vivado - Build Vivado project and bitstream"
@echo " hardware - Build all hardware components"
@echo " sim - Run hardware simulation"
@echo ""
@echo "$(GREEN)Software:$(RESET)"
@echo " python - Install Python package"
@echo " examples - Run example scripts"
@echo " test - Run all tests"
@echo " verify-parity - Run SW/HW parity verification suite"
@echo ""
@echo "$(YELLOW)Quick commands:$(RESET)"
@echo " make setup - One-command setup"
@echo " make test - Run all tests"
@echo " make examples - Run examples"
# Setup targets
.PHONY: setup
setup:
@echo "$(YELLOW)Running complete project setup...$(RESET)"
@chmod +x setup.sh
@./setup.sh
.PHONY: install
install:
@echo "$(YELLOW)Installing Python package...$(RESET)"
@cd $(SOFTWARE_DIR)/python && $(PIP) install -e .
@echo "$(GREEN)✅ Python package installed$(RESET)"
.PHONY: clean
clean:
@echo "$(YELLOW)Cleaning build artifacts...$(RESET)"
@rm -rf build/
@rm -rf $(SOFTWARE_DIR)/python/build
@rm -rf $(SOFTWARE_DIR)/python/dist
@rm -rf $(SOFTWARE_DIR)/python/*.egg-info
@find . -name "*.pyc" -delete
@find . -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@rm -rf $(HARDWARE_DIR)/hls/*/solution*
@rm -rf $(HARDWARE_DIR)/vivado_*
@rm -f *.log *.jou
@echo "$(GREEN)✅ Cleanup completed$(RESET)"
# Hardware build targets
.PHONY: hls
hls:
@echo "$(YELLOW)Building HLS IP cores with v++ compiler...$(RESET)"
@if command -v $(VPP) >/dev/null 2>&1; then \
cd $(HARDWARE_DIR)/hls && \
./scripts/build_hls.sh --clean; \
if [ -d hls_output/hls/impl/ip ]; then \
rm -rf ../ip_repo/snn_top_hls_1_0; \
mkdir -p ../ip_repo; \
cp -a hls_output/hls/impl/ip ../ip_repo/snn_top_hls_1_0; \
echo "$(GREEN)✅ Synced HLS IP to hardware/ip_repo/snn_top_hls_1_0$(RESET)"; \
fi; \
echo "$(GREEN)✅ HLS build completed$(RESET)"; \
else \
echo "$(RED)❌ v++ compiler not found. Source Vitis settings first.$(RESET)"; \
exit 1; \
fi
.PHONY: vivado
vivado:
@echo "$(YELLOW)Running Vivado synthesis check...$(RESET)"
@if command -v $(VIVADO) >/dev/null 2>&1; then \
cd $(HARDWARE_DIR)/scripts && \
$(VIVADO) -mode batch -source synth_core_group.tcl; \
echo "$(GREEN)✅ Vivado synthesis completed$(RESET)"; \
else \
echo "$(RED)❌ Vivado not found$(RESET)"; \
exit 1; \
fi
.PHONY: hardware
hardware: hls vivado
@echo "$(GREEN)✅ All hardware components built$(RESET)"
.PHONY: sim
sim:
@echo "$(YELLOW)Running RTL testbenches...$(RESET)"
@cd $(HARDWARE_DIR)/scripts && \
chmod +x run_testbenches.sh && \
./run_testbenches.sh
@echo "$(GREEN)✅ RTL simulation completed$(RESET)"
# Software build targets
.PHONY: python
python:
@echo "$(YELLOW)Building Python package...$(RESET)"
@cd $(SOFTWARE_DIR)/python && \
$(PYTHON) setup.py build
@echo "$(GREEN)✅ Python package built$(RESET)"
.PHONY: examples
examples: install
@echo "$(YELLOW)Running example scripts...$(RESET)"
@echo "$(BLUE)Running quick start example...$(RESET)"
@$(PYTHON) quick_start.py || echo "$(YELLOW)Quick start not available$(RESET)"
@echo "$(BLUE)Running integration example...$(RESET)"
@$(PYTHON) $(EXAMPLES_DIR)/complete_integration_example.py --simulation-mode --skip-training
@echo "$(GREEN)✅ Examples completed$(RESET)"
.PHONY: test
test: install
@echo "$(YELLOW)Running all tests...$(RESET)"
@echo "$(BLUE)Python tests...$(RESET)"
@cd $(SOFTWARE_DIR)/python && $(PYTHON) -m pytest tests/ -v || echo "$(YELLOW)Some tests may not be available$(RESET)"
@echo "$(BLUE)Hardware simulation tests...$(RESET)"
@$(MAKE) sim || echo "$(YELLOW)Hardware simulation not available$(RESET)"
@echo "$(BLUE)Integration tests...$(RESET)"
@$(PYTHON) $(EXAMPLES_DIR)/complete_integration_example.py --simulation-mode --skip-training || echo "$(YELLOW)Integration test not available$(RESET)"
@echo "$(GREEN)✅ All tests completed$(RESET)"
.PHONY: verify-parity
verify-parity:
@echo "$(YELLOW)Running SW/HW parity verification suite...$(RESET)"
@./scripts/verify_sw_hw_parity.sh
@echo "$(GREEN)✅ SW/HW parity verification completed$(RESET)"
# Legacy compatibility
.PHONY: software
software: install
.PHONY: program
program:
@echo "$(YELLOW)Programming FPGA...$(RESET)"
@cd hardware/scripts && $(VIVADO) -mode batch -source program_board.tcl || echo "$(YELLOW)Program script not available$(RESET)"