-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
110 lines (90 loc) · 2.84 KB
/
Copy pathMakefile
File metadata and controls
110 lines (90 loc) · 2.84 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
# OpenGPU Makefile
# =================
# Build and simulation targets for the OpenGPU project
# Tools
IVERILOG = iverilog
VVP = vvp
PYTHON = python3
# Directories
RTL_DIR = rtl
SIM_DIR = sim
SW_DIR = sw
BUILD_DIR = build
# Source files
PKG_SRC = $(RTL_DIR)/common/pkg_opengpu.sv
# FPU sources
FPU_SRC = \
$(RTL_DIR)/exec/fpu/fp_classifier.sv \
$(RTL_DIR)/exec/fpu/fp_misc.sv \
$(RTL_DIR)/exec/fpu/fp_compare.sv \
$(RTL_DIR)/exec/fpu/fp_addsub.sv \
$(RTL_DIR)/exec/fpu/fp_mul.sv \
$(RTL_DIR)/exec/fpu/fp_convert.sv \
$(RTL_DIR)/exec/fpu/fp_div.sv \
$(RTL_DIR)/exec/fpu/fp_sqrt.sv \
$(RTL_DIR)/exec/fpu/fp_fma.sv \
$(RTL_DIR)/exec/fpu/fp_alu.sv
CORE_SRC = \
$(RTL_DIR)/exec/int_alu.sv \
$(FPU_SRC) \
$(RTL_DIR)/core/regfile/vector_regfile.sv \
$(RTL_DIR)/core/pipeline/fetch_stage.sv \
$(RTL_DIR)/core/pipeline/decode_stage.sv \
$(RTL_DIR)/core/pipeline/execute_stage.sv \
$(RTL_DIR)/core/pipeline/memory_stage.sv \
$(RTL_DIR)/core/pipeline/writeback_stage.sv \
$(RTL_DIR)/core/core_top.sv
SIM_SRC = \
$(SIM_DIR)/models/memory_model.sv \
$(SIM_DIR)/tb/tb_core.sv
ALL_SRC = $(PKG_SRC) $(CORE_SRC) $(SIM_SRC)
# Flags
IVERILOG_FLAGS = -g2012 -Wall -DSIMULATION
# Targets
.PHONY: all clean sim test assemble
all: sim
# Create build directory
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
# Compile testbench
$(BUILD_DIR)/tb_core: $(ALL_SRC) | $(BUILD_DIR)
$(IVERILOG) $(IVERILOG_FLAGS) -o $@ $(ALL_SRC)
# Run simulation
sim: $(BUILD_DIR)/tb_core
cd $(BUILD_DIR) && $(VVP) tb_core
# Run tests (alias for sim)
test: sim
# Assemble a program
# Usage: make assemble SRC=sw/kernels/test.asm
assemble:
$(PYTHON) $(SW_DIR)/assembler/opengpu_asm.py $(SRC)
# Assemble all test kernels
assemble-all:
$(PYTHON) $(SW_DIR)/assembler/opengpu_asm.py $(SW_DIR)/kernels/test_arithmetic.asm
$(PYTHON) $(SW_DIR)/assembler/opengpu_asm.py $(SW_DIR)/kernels/test_loop.asm
$(PYTHON) $(SW_DIR)/assembler/opengpu_asm.py $(SW_DIR)/kernels/vector_add.asm
$(PYTHON) $(SW_DIR)/assembler/opengpu_asm.py $(SW_DIR)/kernels/matrix_mul.asm
$(PYTHON) $(SW_DIR)/assembler/opengpu_asm.py $(SW_DIR)/kernels/reduction.asm
$(PYTHON) $(SW_DIR)/assembler/opengpu_asm.py $(SW_DIR)/kernels/fp_test.asm
# Clean build artifacts
clean:
rm -rf $(BUILD_DIR)
rm -f *.vcd
rm -f $(SW_DIR)/kernels/*.hex
# View waveforms (requires gtkwave)
wave:
gtkwave $(BUILD_DIR)/tb_core.vcd &
# Lint check
lint: | $(BUILD_DIR)
$(IVERILOG) $(IVERILOG_FLAGS) -o /dev/null $(PKG_SRC) $(CORE_SRC)
@echo "Lint check passed!"
# Help
help:
@echo "OpenGPU Build Targets:"
@echo " make sim - Compile and run simulation"
@echo " make test - Same as sim"
@echo " make lint - Run lint checks"
@echo " make assemble SRC=file.asm - Assemble a program"
@echo " make assemble-all - Assemble all test kernels"
@echo " make wave - View waveforms in gtkwave"
@echo " make clean - Clean build artifacts"