blob: 36b2379680c8c6bd93da71e1fad9d8be0ecbedd9 [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001CUR_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
2PRJ_DIR := $(realpath ${CUR_DIR}/../)
3export PRJ_DIR
4
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -07005REG_OUTPUT_DIR ?= ${PRJ_DIR}/build/regs-generated
6REG_OUTPUT_DV_DIR ?= ${REG_OUTPUT_DIR}/dv
7REG_OUTPUT_SW_DIR ?= ${REG_OUTPUT_DIR}/sw
8
Michael Schaffner24984fc2020-01-17 17:42:57 -08009IPS ?= aes \
Michael Schaffner1b1ede92019-09-24 18:49:47 -070010 alert_handler \
Michael Schaffner24984fc2020-01-17 17:42:57 -080011 flash_ctrl \
12 gpio \
13 hmac \
14 i2c \
15 nmi_gen \
Michael Schaffner1795f4d2019-10-29 10:59:12 -070016 padctrl \
Michael Schaffner24984fc2020-01-17 17:42:57 -080017 pinmux \
Timothy Chenbc16a172020-04-07 23:45:23 -070018 pwrmgr \
Timothy Chen612901b2020-03-05 17:03:13 -080019 rstmgr \
Michael Schaffner24984fc2020-01-17 17:42:57 -080020 rv_plic \
21 rv_timer \
22 spi_device \
23 trial1 \
24 uart \
25 usbdev \
26 usbuart
lowRISC Contributors802543a2019-08-31 12:12:56 +010027
Eunchan Kim49634d72019-09-05 14:39:57 -070028TOPS ?= top_earlgrey
29
Timothy Chen3193b002019-10-04 16:56:05 -070030# conditional flags
31VERBOSE ?= 0
32toolflags ?=
33ifeq ($(VERBOSE),1)
34 toolflags += -v
35endif
36
Tobias Wölfel4c5fbec2019-10-23 12:43:17 +020037dir_hjson = data
Timothy Chen3193b002019-10-04 16:56:05 -070038
Eunchan Kim23662872019-11-18 11:52:13 -080039dynips_reg = $(addsuffix _reg, $(IPS))
Eunchan Kim53e3b3b2019-11-13 12:33:49 -080040
lowRISC Contributors802543a2019-08-31 12:12:56 +010041ips_reg = $(addsuffix _reg, $(IPS))
42
Tobias Wölfelce06a242019-10-23 13:54:46 +020043ips_reg_header = $(addsuffix _reg_header, $(IPS))
44
Eunchan Kim49634d72019-09-05 14:39:57 -070045tops_gen = $(addsuffix _gen,$(TOPS))
lowRISC Contributors802543a2019-08-31 12:12:56 +010046
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070047tops_reg = $(addsuffix _reg,$(TOPS))
lowRISC Contributors802543a2019-08-31 12:12:56 +010048
Eunchan Kim53e3b3b2019-11-13 12:33:49 -080049all: $(dynips_reg) $(tops_gen) $(tops_reg) banner
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070050
51banner:
52 @echo "############################################"
53 @echo "Note: Regs for DV & SW are now generated at:"
54 @echo "${REG_OUTPUT_DIR}"
55 @echo "############################################"
56
Eunchan Kim53e3b3b2019-11-13 12:33:49 -080057regs: $(dynips_reg) $(tops_reg) banner
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070058
59pre_reg:
60 mkdir -p ${REG_OUTPUT_DIR}
61 mkdir -p ${REG_OUTPUT_DV_DIR}
62 mkdir -p ${REG_OUTPUT_SW_DIR}
lowRISC Contributors802543a2019-08-31 12:12:56 +010063
Srikrishna Iyer707f8d62019-11-12 14:17:11 -080064$(ips_reg): pre_reg
Tobias Wölfel4c5fbec2019-10-23 12:43:17 +020065 if [ -f ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson ]; then \
66 ${PRJ_DIR}/util/regtool.py -r ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson; \
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070067 ${PRJ_DIR}/util/regtool.py -s -t ${REG_OUTPUT_DV_DIR} \
Tobias Wölfel4c5fbec2019-10-23 12:43:17 +020068 ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson; \
lowRISC Contributors802543a2019-08-31 12:12:56 +010069 fi
70
Srikrishna Iyer707f8d62019-11-12 14:17:11 -080071regs-header: $(ips_reg_header) banner
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070072
Srikrishna Iyer707f8d62019-11-12 14:17:11 -080073$(ips_reg_header): pre_reg
Tobias Wölfelce06a242019-10-23 13:54:46 +020074 if [ -f ${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/$(dir_hjson)/$(subst _reg_header,,$@).hjson ]; then \
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070075 ${PRJ_DIR}/util/regtool.py -D -o ${REG_OUTPUT_SW_DIR}/$(subst _reg_header,_reg_headers,$@).h\
Tobias Wölfelce06a242019-10-23 13:54:46 +020076 ${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/$(dir_hjson)/$(subst _reg_header,,$@).hjson; \
Tobias Wölfelce06a242019-10-23 13:54:46 +020077 fi
78
79clean-regs-header:
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070080 rm -r -f ${REG_OUTPUT_SW_DIR}
Tobias Wölfelce06a242019-10-23 13:54:46 +020081
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070082top: $(tops_gen) $(tops_reg)
Eunchan Kim49634d72019-09-05 14:39:57 -070083$(tops_gen):
84 $(eval $@_TOP := $(strip $(foreach top,$(TOPS),$(findstring $(top),$@))))
Michael Schaffner7f134962019-11-03 12:44:50 -080085 ${PRJ_DIR}/util/topgen.py -t ${PRJ_DIR}/hw/$($@_TOP)/data/$($@_TOP).hjson \
86 --tpl ${PRJ_DIR}/hw/$($@_TOP)/data/ \
Timothy Chen3193b002019-10-04 16:56:05 -070087 -o ${PRJ_DIR}/hw/$($@_TOP)/ ${toolflags}
Eunchan Kim49634d72019-09-05 14:39:57 -070088
Srikrishna Iyer707f8d62019-11-12 14:17:11 -080089$(tops_reg): pre_reg
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070090 $(eval $@_TOP := $(strip $(foreach top,$(TOPS),$(findstring $(top),$@))))
91 mkdir -p ${REG_OUTPUT_DV_DIR}/$($@_TOP)
92 ${PRJ_DIR}/util/topgen.py -t ${PRJ_DIR}/hw/$($@_TOP)/data/$($@_TOP).hjson \
93 -r -o ${REG_OUTPUT_DV_DIR}/$($@_TOP) ${toolflags}
94
95
96.PHONY: all banner $(ips_reg) $(tops_gen) $(ips_reg_header)