blob: e0d4fddc811cb1c1517b4c0105be67e2e6816994 [file] [log] [blame]
Sam Elliott45fb1c62020-06-02 18:18:54 +01001# Copyright lowRISC contributors.
2# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3# SPDX-License-Identifier: Apache-2.0
4
lowRISC Contributors802543a2019-08-31 12:12:56 +01005CUR_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
6PRJ_DIR := $(realpath ${CUR_DIR}/../)
7export PRJ_DIR
8
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -07009REG_OUTPUT_DIR ?= ${PRJ_DIR}/build/regs-generated
10REG_OUTPUT_DV_DIR ?= ${REG_OUTPUT_DIR}/dv
11REG_OUTPUT_SW_DIR ?= ${REG_OUTPUT_DIR}/sw
12
Michael Schaffner24984fc2020-01-17 17:42:57 -080013IPS ?= aes \
Michael Schaffner1b1ede92019-09-24 18:49:47 -070014 alert_handler \
Timothy Chen3525aa82020-04-23 23:23:18 -070015 clkmgr \
Michael Schaffner24984fc2020-01-17 17:42:57 -080016 flash_ctrl \
17 gpio \
18 hmac \
Eunchan Kim1a959052020-09-18 15:10:22 -070019 kmac \
Michael Schaffner24984fc2020-01-17 17:42:57 -080020 i2c \
Timothy Chen15adeee2020-09-09 15:44:35 -070021 keymgr \
Michael Schaffner24984fc2020-01-17 17:42:57 -080022 nmi_gen \
Michael Schaffner41319c22020-04-12 15:40:24 -070023 otp_ctrl \
Michael Schaffner1795f4d2019-10-29 10:59:12 -070024 padctrl \
Michael Schaffner24984fc2020-01-17 17:42:57 -080025 pinmux \
Timothy Chenbc16a172020-04-07 23:45:23 -070026 pwrmgr \
Timothy Chen612901b2020-03-05 17:03:13 -080027 rstmgr \
Michael Schaffner24984fc2020-01-17 17:42:57 -080028 rv_plic \
29 rv_timer \
Timothy Chen1e6db372020-05-19 20:52:45 -070030 sensor_ctrl \
Michael Schaffner24984fc2020-01-17 17:42:57 -080031 spi_device \
32 trial1 \
Philipp Wagner5c2d2942020-06-22 11:34:00 +010033 otbn \
Michael Schaffner24984fc2020-01-17 17:42:57 -080034 uart \
35 usbdev \
36 usbuart
lowRISC Contributors802543a2019-08-31 12:12:56 +010037
Eunchan Kim49634d72019-09-05 14:39:57 -070038TOPS ?= top_earlgrey
39
Timothy Chen3193b002019-10-04 16:56:05 -070040# conditional flags
41VERBOSE ?= 0
42toolflags ?=
43ifeq ($(VERBOSE),1)
44 toolflags += -v
45endif
46
Tobias Wölfel4c5fbec2019-10-23 12:43:17 +020047dir_hjson = data
Timothy Chen3193b002019-10-04 16:56:05 -070048
Eunchan Kim23662872019-11-18 11:52:13 -080049dynips_reg = $(addsuffix _reg, $(IPS))
Eunchan Kim53e3b3b2019-11-13 12:33:49 -080050
lowRISC Contributors802543a2019-08-31 12:12:56 +010051ips_reg = $(addsuffix _reg, $(IPS))
52
Tobias Wölfelce06a242019-10-23 13:54:46 +020053ips_reg_header = $(addsuffix _reg_header, $(IPS))
54
Eunchan Kim49634d72019-09-05 14:39:57 -070055tops_gen = $(addsuffix _gen,$(TOPS))
lowRISC Contributors802543a2019-08-31 12:12:56 +010056
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070057tops_reg = $(addsuffix _reg,$(TOPS))
lowRISC Contributors802543a2019-08-31 12:12:56 +010058
Eunchan Kim53e3b3b2019-11-13 12:33:49 -080059all: $(dynips_reg) $(tops_gen) $(tops_reg) banner
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070060
61banner:
62 @echo "############################################"
63 @echo "Note: Regs for DV & SW are now generated at:"
64 @echo "${REG_OUTPUT_DIR}"
65 @echo "############################################"
66
Eunchan Kim53e3b3b2019-11-13 12:33:49 -080067regs: $(dynips_reg) $(tops_reg) banner
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070068
69pre_reg:
70 mkdir -p ${REG_OUTPUT_DIR}
71 mkdir -p ${REG_OUTPUT_DV_DIR}
72 mkdir -p ${REG_OUTPUT_SW_DIR}
lowRISC Contributors802543a2019-08-31 12:12:56 +010073
Srikrishna Iyer707f8d62019-11-12 14:17:11 -080074$(ips_reg): pre_reg
Tobias Wölfel4c5fbec2019-10-23 12:43:17 +020075 if [ -f ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson ]; then \
76 ${PRJ_DIR}/util/regtool.py -r ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson; \
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070077 ${PRJ_DIR}/util/regtool.py -s -t ${REG_OUTPUT_DV_DIR} \
Tobias Wölfel4c5fbec2019-10-23 12:43:17 +020078 ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson; \
lowRISC Contributors802543a2019-08-31 12:12:56 +010079 fi
80
Srikrishna Iyer707f8d62019-11-12 14:17:11 -080081regs-header: $(ips_reg_header) banner
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070082
Srikrishna Iyer707f8d62019-11-12 14:17:11 -080083$(ips_reg_header): pre_reg
Tobias Wölfelce06a242019-10-23 13:54:46 +020084 if [ -f ${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/$(dir_hjson)/$(subst _reg_header,,$@).hjson ]; then \
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070085 ${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 +020086 ${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/$(dir_hjson)/$(subst _reg_header,,$@).hjson; \
Tobias Wölfelce06a242019-10-23 13:54:46 +020087 fi
88
89clean-regs-header:
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070090 rm -r -f ${REG_OUTPUT_SW_DIR}
Tobias Wölfelce06a242019-10-23 13:54:46 +020091
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070092top: $(tops_gen) $(tops_reg)
Eunchan Kim49634d72019-09-05 14:39:57 -070093$(tops_gen):
94 $(eval $@_TOP := $(strip $(foreach top,$(TOPS),$(findstring $(top),$@))))
Michael Schaffner7f134962019-11-03 12:44:50 -080095 ${PRJ_DIR}/util/topgen.py -t ${PRJ_DIR}/hw/$($@_TOP)/data/$($@_TOP).hjson \
96 --tpl ${PRJ_DIR}/hw/$($@_TOP)/data/ \
Timothy Chen3193b002019-10-04 16:56:05 -070097 -o ${PRJ_DIR}/hw/$($@_TOP)/ ${toolflags}
Eunchan Kim49634d72019-09-05 14:39:57 -070098
Srikrishna Iyer707f8d62019-11-12 14:17:11 -080099$(tops_reg): pre_reg
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -0700100 $(eval $@_TOP := $(strip $(foreach top,$(TOPS),$(findstring $(top),$@))))
101 mkdir -p ${REG_OUTPUT_DV_DIR}/$($@_TOP)
102 ${PRJ_DIR}/util/topgen.py -t ${PRJ_DIR}/hw/$($@_TOP)/data/$($@_TOP).hjson \
103 -r -o ${REG_OUTPUT_DV_DIR}/$($@_TOP) ${toolflags}
104
105
106.PHONY: all banner $(ips_reg) $(tops_gen) $(ips_reg_header)