-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (40 loc) · 1.26 KB
/
Copy pathMakefile
File metadata and controls
53 lines (40 loc) · 1.26 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
# leaf project
# Directories
RTL_DIR = rtl
TBS_DIR = tbs
WORK_DIR = work
SYN_DIR = syn
YOSYS_SCRIPT = $(SYN_DIR)/leaf_analysis.ys
RTL_TOP = leaf
TBS_TOP = leaf_tb
# VHDL simulator
SIM = ghdl
SIMFLAGS = --workdir=$(WORK_DIR) --ieee=synopsys
SIMXOPTS = --ieee-asserts=disable
WAVEFORM ?= $(TBS_TOP).ghw
ifdef WAVEFORM
SIMXOPTS += --wave=$(WAVEFORM)
endif
# Source files
RTL_SRC = $(wildcard $(RTL_DIR)/*.vhdl)
TBS_SRC = $(wildcard $(TBS_DIR)/*.vhdl)
PROGRAM = verif/tests/dump/out.bin
DUMP_FILE = verif/tests/dump/out.dump
REG_FILE ?= 32
$(WORK_DIR):
@mkdir $@
$(WORK_DIR)/.import: $(RTL_SRC) $(TBS_SRC) | $(WORK_DIR)
@$(SIM) import $(SIMFLAGS) $(RTL_SRC) $(TBS_SRC) | tee $@
$(WORK_DIR)/.make: $(WORK_DIR)/.import
@$(SIM) make $(SIMFLAGS) $(TBS_TOP) | tee $@
$(WORK_DIR)/$(RTL_TOP).v: $(RTL_SRC) $(WORK_DIR)/.make Makefile
@$(SIM) synth $(SIMFLAGS) --latches --out=verilog -gREG_FILE_SIZE=$(REG_FILE) $(RTL_TOP) > $@
$(WORK_DIR)/$(RTL_TOP).rpt: $(WORK_DIR)/$(RTL_TOP).v $(YOSYS_SCRIPT)
@yosys -q -l $@ $(YOSYS_SCRIPT)
.PHONY: run synthesis clean
run: $(WORK_DIR)/.make $(PROGRAM)
@$(SIM) run $(TBS_TOP) $(SIMXOPTS) -gPROGRAM=$(PROGRAM) -gDUMP_FILE=$(DUMP_FILE)
synthesis: $(WORK_DIR)/$(RTL_TOP).rpt
clean:
$(SIM) clean --workdir=$(WORK_DIR)
@rm -rf $(WORK_DIR)