-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
44 lines (33 loc) · 1013 Bytes
/
Makefile
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
# vhdl files
FILES = source/*
# testbench
TESTBENCHPATH = testbench/${TESTBENCHFILE}*
TESTBENCHFILE = ${TESTBENCH}_tb
WORKDIR = work
#GHDL CONFIG
GHDL_CMD = ghdl
GHDL_FLAGS = --ieee=synopsys --warn-no-vital-generic --workdir=$(WORKDIR)
STOP_TIME = 500ns
# Simulation break condition
#GHDL_SIM_OPT = --assert-level=error
GHDL_SIM_OPT = --stop-time=$(STOP_TIME)
WAVEFORM_VIEWER = flatpak run io.github.gtkwave.GTKWave
# WAVEFORM_VIEWER = gtkwave
.PHONY: clean
all: clean make run view
make:
ifeq ($(strip $(TESTBENCH)),)
@echo "TESTBENCH not set. Use TESTBENCH=<value> to set it."
@exit 1
endif
@mkdir -p $(WORKDIR)
@$(GHDL_CMD) -a $(GHDL_FLAGS) $(FILES)
@$(GHDL_CMD) -a $(GHDL_FLAGS) $(TESTBENCHPATH)
@$(GHDL_CMD) -e $(GHDL_FLAGS) $(TESTBENCHFILE)
run:
@$(GHDL_CMD) -r $(GHDL_FLAGS) --workdir=$(WORKDIR) $(TESTBENCHFILE) --vcd=$(TESTBENCHFILE).vcd $(GHDL_SIM_OPT)
@mv $(TESTBENCHFILE).vcd $(WORKDIR)/
view:
@$(WAVEFORM_VIEWER) --dump=$(WORKDIR)/$(TESTBENCHFILE).vcd
clean:
@rm -rf $(WORKDIR)