-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (51 loc) · 1.49 KB
/
Makefile
File metadata and controls
65 lines (51 loc) · 1.49 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
# Variables
ASSEMBLER_SCRIPT = assembler/main.py
MEM_FILE = simulation/memory.mem
# == 1. CONFIGURABLE INPUTS (The ?= means "use this unless user overrides it") ==
# Usage: make asm ASM_SOURCE=assembler/programs/fibonacci.asm
ASM_SOURCE ?= assembler/programs/test_prog.asm
# Usage: make compile COMPILE_SCRIPT=scripts/compile_alu.do
COMPILE_SCRIPT ?= scripts/compile.do
# Usage: make sim SIM_SCRIPT=scripts/run_alu.do
SIM_SCRIPT ?= scripts/run.do
# Tools
PYTHON = python3
ifeq ($(OS),Windows_NT)
EXE := .exe
else
EXE :=
endif
VSIM = vsim$(EXE)
VCOM = vcom$(EXE)
VLIB = vlib$(EXE)
VMAP = vmap$(EXE)
# Directories
WORK_DIR = simulation/work
# Default target
all: clean asm lib compile sim
# 1. Run the Assembler
asm:
@echo "--- Assembling $(ASM_SOURCE) ---"
$(PYTHON) $(ASSEMBLER_SCRIPT) $(ASM_SOURCE) > $(MEM_FILE)
# 2. Create ModelSim Library
lib:
@echo "--- Creating Library ---"
cd simulation && $(VLIB) work
cd simulation && $(VMAP) work work
# 3. Compile VHDL
# Uses $(COMPILE_SCRIPT) which defaults to "scripts/compile.do"
compile:
@echo "--- Compiling with $(COMPILE_SCRIPT) ---"
cd simulation && $(VSIM) -c -do "do $(COMPILE_SCRIPT); quit"
# 4. Run Simulation (GUI Mode)
# Uses $(SIM_SCRIPT) which defaults to "scripts/run.do"
sim:
@echo "--- Simulating with $(SIM_SCRIPT) ---"
cd simulation && $(VSIM) -gui -do "do $(SIM_SCRIPT)"
# 5. Clean up ModelSim trash
clean:
@echo "--- Cleaning ---"
rm -rf $(WORK_DIR)
rm -f simulation/transcript
rm -f simulation/*.wlf
rm -f $(MEM_FILE)