blob: d5efe2ccd21fcda5563f37f2deb0e8ca399dd369 [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 \
Cindy Chendec07712020-10-27 17:16:12 -070016 entropy_src \
Mark Branstada069bb02020-12-02 11:59:34 -080017 csrng \
18 edn \
Michael Schaffner24984fc2020-01-17 17:42:57 -080019 flash_ctrl \
20 gpio \
21 hmac \
Eunchan Kim1a959052020-09-18 15:10:22 -070022 kmac \
Michael Schaffner24984fc2020-01-17 17:42:57 -080023 i2c \
Timothy Chen15adeee2020-09-09 15:44:35 -070024 keymgr \
Michael Schaffnere81ab752020-09-30 18:57:29 -070025 lc_ctrl \
Michael Schaffner24984fc2020-01-17 17:42:57 -080026 nmi_gen \
Michael Schaffner41319c22020-04-12 15:40:24 -070027 otp_ctrl \
Michael Schaffner1795f4d2019-10-29 10:59:12 -070028 padctrl \
Michael Schaffner24984fc2020-01-17 17:42:57 -080029 pinmux \
Timothy Chenbc16a172020-04-07 23:45:23 -070030 pwrmgr \
Timothy Chen612901b2020-03-05 17:03:13 -080031 rstmgr \
Michael Schaffner24984fc2020-01-17 17:42:57 -080032 rv_plic \
33 rv_timer \
Timothy Chen1e6db372020-05-19 20:52:45 -070034 sensor_ctrl \
Michael Schaffner24984fc2020-01-17 17:42:57 -080035 spi_device \
Michael Schaffner86c0e322020-10-07 19:56:32 -070036 sram_ctrl \
Michael Schaffner24984fc2020-01-17 17:42:57 -080037 trial1 \
Philipp Wagner5c2d2942020-06-22 11:34:00 +010038 otbn \
Michael Schaffner24984fc2020-01-17 17:42:57 -080039 uart \
40 usbdev \
41 usbuart
lowRISC Contributors802543a2019-08-31 12:12:56 +010042
Eunchan Kim49634d72019-09-05 14:39:57 -070043TOPS ?= top_earlgrey
44
Timothy Chen3193b002019-10-04 16:56:05 -070045# conditional flags
46VERBOSE ?= 0
47toolflags ?=
48ifeq ($(VERBOSE),1)
49 toolflags += -v
50endif
51
Tobias Wölfel4c5fbec2019-10-23 12:43:17 +020052dir_hjson = data
Timothy Chen3193b002019-10-04 16:56:05 -070053
Eunchan Kim23662872019-11-18 11:52:13 -080054dynips_reg = $(addsuffix _reg, $(IPS))
Eunchan Kim53e3b3b2019-11-13 12:33:49 -080055
lowRISC Contributors802543a2019-08-31 12:12:56 +010056ips_reg = $(addsuffix _reg, $(IPS))
57
Tobias Wölfelce06a242019-10-23 13:54:46 +020058ips_reg_header = $(addsuffix _reg_header, $(IPS))
59
Eunchan Kim49634d72019-09-05 14:39:57 -070060tops_gen = $(addsuffix _gen,$(TOPS))
lowRISC Contributors802543a2019-08-31 12:12:56 +010061
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070062tops_reg = $(addsuffix _reg,$(TOPS))
lowRISC Contributors802543a2019-08-31 12:12:56 +010063
Michael Schaffner6db11f22021-01-25 18:24:20 -080064all: $(dynips_reg) $(tops_gen) $(tops_reg) banner
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070065
66banner:
67 @echo "############################################"
68 @echo "Note: Regs for DV & SW are now generated at:"
69 @echo "${REG_OUTPUT_DIR}"
70 @echo "############################################"
71
Eunchan Kim53e3b3b2019-11-13 12:33:49 -080072regs: $(dynips_reg) $(tops_reg) banner
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070073
74pre_reg:
75 mkdir -p ${REG_OUTPUT_DIR}
76 mkdir -p ${REG_OUTPUT_DV_DIR}
77 mkdir -p ${REG_OUTPUT_SW_DIR}
lowRISC Contributors802543a2019-08-31 12:12:56 +010078
Michael Schaffner6db11f22021-01-25 18:24:20 -080079$(ips_reg): pre_reg otp-mmap lc-state-enc
Tobias Wölfel4c5fbec2019-10-23 12:43:17 +020080 if [ -f ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson ]; then \
Timothy Chend2292062020-10-01 22:56:39 -070081 ${PRJ_DIR}/util/regtool.py ${toolflags} -r ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson; \
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070082 ${PRJ_DIR}/util/regtool.py -s -t ${REG_OUTPUT_DV_DIR} \
Tobias Wölfel4c5fbec2019-10-23 12:43:17 +020083 ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson; \
lowRISC Contributors802543a2019-08-31 12:12:56 +010084 fi
85
Michael Schaffnerf6a79002020-10-27 10:00:13 -070086otp-mmap:
Michael Schaffner1fff9852021-01-08 14:06:35 -080087 cd ${PRJ_DIR} && ./util/design/gen-otp-mmap.py
Michael Schaffnerf6a79002020-10-27 10:00:13 -070088
Michael Schaffner6db11f22021-01-25 18:24:20 -080089lc-state-enc:
90 cd ${PRJ_DIR} && ./util/design/gen-lc-state-enc.py
91
Srikrishna Iyer707f8d62019-11-12 14:17:11 -080092regs-header: $(ips_reg_header) banner
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070093
Srikrishna Iyer707f8d62019-11-12 14:17:11 -080094$(ips_reg_header): pre_reg
Tobias Wölfelce06a242019-10-23 13:54:46 +020095 if [ -f ${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/$(dir_hjson)/$(subst _reg_header,,$@).hjson ]; then \
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070096 ${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 +020097 ${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/$(dir_hjson)/$(subst _reg_header,,$@).hjson; \
Tobias Wölfelce06a242019-10-23 13:54:46 +020098 fi
99
100clean-regs-header:
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -0700101 rm -r -f ${REG_OUTPUT_SW_DIR}
Tobias Wölfelce06a242019-10-23 13:54:46 +0200102
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -0700103top: $(tops_gen) $(tops_reg)
Eunchan Kim49634d72019-09-05 14:39:57 -0700104$(tops_gen):
105 $(eval $@_TOP := $(strip $(foreach top,$(TOPS),$(findstring $(top),$@))))
Michael Schaffner7f134962019-11-03 12:44:50 -0800106 ${PRJ_DIR}/util/topgen.py -t ${PRJ_DIR}/hw/$($@_TOP)/data/$($@_TOP).hjson \
107 --tpl ${PRJ_DIR}/hw/$($@_TOP)/data/ \
Timothy Chen3193b002019-10-04 16:56:05 -0700108 -o ${PRJ_DIR}/hw/$($@_TOP)/ ${toolflags}
Eunchan Kim49634d72019-09-05 14:39:57 -0700109
Srikrishna Iyer707f8d62019-11-12 14:17:11 -0800110$(tops_reg): pre_reg
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -0700111 $(eval $@_TOP := $(strip $(foreach top,$(TOPS),$(findstring $(top),$@))))
112 mkdir -p ${REG_OUTPUT_DV_DIR}/$($@_TOP)
113 ${PRJ_DIR}/util/topgen.py -t ${PRJ_DIR}/hw/$($@_TOP)/data/$($@_TOP).hjson \
114 -r -o ${REG_OUTPUT_DV_DIR}/$($@_TOP) ${toolflags}
115
116
Michael Schaffner6db11f22021-01-25 18:24:20 -0800117.PHONY: all banner otp-mmap lc-state-enc $(ips_reg) $(tops_gen) $(ips_reg_header)