-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmakefile
57 lines (43 loc) · 1.84 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
COMPILER=ghdl
GHDL_FLAGS= --workdir=work
FILES_FLAG= -Wno-binding
COMMON_FILES := $(shell find ./COMMON -print -type d | grep \.vhdl$$)
CUSTOM_FILES := $(shell find ./CUSTOM -print -type d | grep -v VENDOR | grep -v SIM | grep \.vhdl$$)
TTL_FILES := $(shell find ./TTL -print -type d | grep \.vhdl$$)
MMU_FILES := $(shell find ./MMU -print -type d | grep \.vhdl$$)
IOU_FILES := $(shell find ./IOU -print -type d | grep \.vhdl$$)
ifdef VENDOR
VENDOR_FILES := $(shell find ./CUSTOM -print -type d | grep VENDOR | grep $(VENDOR) | grep \.vhdl$$)
endif
SIM_FILES := $(shell find ./CUSTOM -print -type d | grep SIM | grep \.vhdl$$)
TEST_FILES := $(shell find ./test -print -type d | grep \.vhdl$$)
ALL_ENTITIES = $(shell $(COMPILER) --dir $(GHDL_FLAGS) | grep -e ^entity -e ^configuration | grep -v _entity | sed -e "s/entity //g" | sed -e "s/configuration //g")
TEST_ENTITIES = $(shell $(COMPILER) --dir $(GHDL_FLAGS) | grep -e ^entity -e ^configuration | grep -v _entity | grep _tb | sed -e "s/entity //g" | sed -e "s/configuration //g")
define make-entity
@echo Building $(1)
@$(COMPILER) -m $(GHDL_FLAGS) $(1)
endef
define run-test
@$(COMPILER) -r $(GHDL_FLAGS) $(1)
endef
.PHONY: clean import files build test
clean :
rm -f work/*
import :
@$(COMPILER) -i $(GHDL_FLAGS) $(COMMON_FILES)
@$(COMPILER) -i $(GHDL_FLAGS) $(CUSTOM_FILES)
@$(COMPILER) -i $(GHDL_FLAGS) $(TTL_FILES)
@$(COMPILER) -i $(GHDL_FLAGS) $(MMU_FILES)
@$(COMPILER) -i $(GHDL_FLAGS) $(IOU_FILES)
ifdef VENDOR
@$(COMPILER) -i $(GHDL_FLAGS) $(VENDOR_FILES)
else
@$(COMPILER) -i $(GHDL_FLAGS) $(SIM_FILES)
endif
@$(COMPILER) -i $(GHDL_FLAGS) $(TEST_FILES)
files :
@$(COMPILER) --elab-order $(GHDL_FLAGS) $(FILES_FLAG) $(ASIC)
build :
$(foreach ENTITY, $(ALL_ENTITIES), $(call make-entity, $(ENTITY)))
test :
$(foreach TEST_ENTITY, $(TEST_ENTITIES), $(call run-test, $(TEST_ENTITY)))