blob: 3155b51c3cb15657a03740b7783748797b9e05d0 [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 \
Eric Shiu5f1d3042021-03-17 17:24:11 -070014 adc_ctrl \
Michael Schaffner1b1ede92019-09-24 18:49:47 -070015 alert_handler \
Timothy Chen2b8ef762021-02-16 14:44:55 -080016 aon_timer \
Timothy Chen3525aa82020-04-23 23:23:18 -070017 clkmgr \
Cindy Chendec07712020-10-27 17:16:12 -070018 entropy_src \
Mark Branstada069bb02020-12-02 11:59:34 -080019 csrng \
20 edn \
Michael Schaffner24984fc2020-01-17 17:42:57 -080021 flash_ctrl \
22 gpio \
23 hmac \
Eunchan Kim1a959052020-09-18 15:10:22 -070024 kmac \
Michael Schaffner24984fc2020-01-17 17:42:57 -080025 i2c \
Timothy Chen15adeee2020-09-09 15:44:35 -070026 keymgr \
Michael Schaffnere81ab752020-09-30 18:57:29 -070027 lc_ctrl \
Michael Schaffner24984fc2020-01-17 17:42:57 -080028 nmi_gen \
Michael Schaffner41319c22020-04-12 15:40:24 -070029 otp_ctrl \
Timothy Chend12569f2021-02-12 15:28:12 -080030 pattgen \
Michael Schaffner24984fc2020-01-17 17:42:57 -080031 pinmux \
Timothy Chenbc16a172020-04-07 23:45:23 -070032 pwrmgr \
Rupert Swarbrick9855d4b2020-12-02 08:41:35 +000033 rom_ctrl \
Timothy Chen612901b2020-03-05 17:03:13 -080034 rstmgr \
Michael Schaffner24984fc2020-01-17 17:42:57 -080035 rv_plic \
36 rv_timer \
Timothy Chen1e6db372020-05-19 20:52:45 -070037 sensor_ctrl \
Michael Schaffner24984fc2020-01-17 17:42:57 -080038 spi_device \
Michael Schaffner8e04df32021-02-09 19:52:24 -080039 spi_host \
Michael Schaffner86c0e322020-10-07 19:56:32 -070040 sram_ctrl \
Eric Shiu33ad5322021-03-11 19:23:00 -080041 sysrst_ctrl \
Michael Schaffner24984fc2020-01-17 17:42:57 -080042 trial1 \
Philipp Wagner5c2d2942020-06-22 11:34:00 +010043 otbn \
Michael Schaffner24984fc2020-01-17 17:42:57 -080044 uart \
45 usbdev \
46 usbuart
lowRISC Contributors802543a2019-08-31 12:12:56 +010047
Eunchan Kim49634d72019-09-05 14:39:57 -070048TOPS ?= top_earlgrey
49
Timothy Chen3193b002019-10-04 16:56:05 -070050# conditional flags
51VERBOSE ?= 0
52toolflags ?=
53ifeq ($(VERBOSE),1)
54 toolflags += -v
55endif
56
Tobias Wölfel4c5fbec2019-10-23 12:43:17 +020057dir_hjson = data
Timothy Chen3193b002019-10-04 16:56:05 -070058
Eunchan Kim23662872019-11-18 11:52:13 -080059dynips_reg = $(addsuffix _reg, $(IPS))
Eunchan Kim53e3b3b2019-11-13 12:33:49 -080060
lowRISC Contributors802543a2019-08-31 12:12:56 +010061ips_reg = $(addsuffix _reg, $(IPS))
62
Tobias Wölfelce06a242019-10-23 13:54:46 +020063ips_reg_header = $(addsuffix _reg_header, $(IPS))
64
Eunchan Kim49634d72019-09-05 14:39:57 -070065tops_gen = $(addsuffix _gen,$(TOPS))
lowRISC Contributors802543a2019-08-31 12:12:56 +010066
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070067tops_reg = $(addsuffix _reg,$(TOPS))
lowRISC Contributors802543a2019-08-31 12:12:56 +010068
Michael Schaffner6db11f22021-01-25 18:24:20 -080069all: $(dynips_reg) $(tops_gen) $(tops_reg) banner
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070070
71banner:
72 @echo "############################################"
73 @echo "Note: Regs for DV & SW are now generated at:"
74 @echo "${REG_OUTPUT_DIR}"
75 @echo "############################################"
76
Eunchan Kim53e3b3b2019-11-13 12:33:49 -080077regs: $(dynips_reg) $(tops_reg) banner
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070078
79pre_reg:
80 mkdir -p ${REG_OUTPUT_DIR}
81 mkdir -p ${REG_OUTPUT_DV_DIR}
82 mkdir -p ${REG_OUTPUT_SW_DIR}
lowRISC Contributors802543a2019-08-31 12:12:56 +010083
Michael Schaffner6db11f22021-01-25 18:24:20 -080084$(ips_reg): pre_reg otp-mmap lc-state-enc
Tobias Wölfel4c5fbec2019-10-23 12:43:17 +020085 if [ -f ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson ]; then \
Rupert Swarbrick6880e212021-02-10 16:10:00 +000086 ${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 -070087 ${PRJ_DIR}/util/regtool.py -s -t ${REG_OUTPUT_DV_DIR} \
Tobias Wölfel4c5fbec2019-10-23 12:43:17 +020088 ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson; \
lowRISC Contributors802543a2019-08-31 12:12:56 +010089 fi
90
Michael Schaffnerf6a79002020-10-27 10:00:13 -070091otp-mmap:
Michael Schaffner1fff9852021-01-08 14:06:35 -080092 cd ${PRJ_DIR} && ./util/design/gen-otp-mmap.py
Michael Schaffnerf6a79002020-10-27 10:00:13 -070093
Michael Schaffner6db11f22021-01-25 18:24:20 -080094lc-state-enc:
95 cd ${PRJ_DIR} && ./util/design/gen-lc-state-enc.py
96
Srikrishna Iyer707f8d62019-11-12 14:17:11 -080097regs-header: $(ips_reg_header) banner
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -070098
Srikrishna Iyer707f8d62019-11-12 14:17:11 -080099$(ips_reg_header): pre_reg
Tobias Wölfelce06a242019-10-23 13:54:46 +0200100 if [ -f ${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/$(dir_hjson)/$(subst _reg_header,,$@).hjson ]; then \
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -0700101 ${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 +0200102 ${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/$(dir_hjson)/$(subst _reg_header,,$@).hjson; \
Tobias Wölfelce06a242019-10-23 13:54:46 +0200103 fi
104
105clean-regs-header:
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -0700106 rm -r -f ${REG_OUTPUT_SW_DIR}
Tobias Wölfelce06a242019-10-23 13:54:46 +0200107
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -0700108top: $(tops_gen) $(tops_reg)
Eunchan Kim49634d72019-09-05 14:39:57 -0700109$(tops_gen):
110 $(eval $@_TOP := $(strip $(foreach top,$(TOPS),$(findstring $(top),$@))))
Michael Schaffner7f134962019-11-03 12:44:50 -0800111 ${PRJ_DIR}/util/topgen.py -t ${PRJ_DIR}/hw/$($@_TOP)/data/$($@_TOP).hjson \
Timothy Chen3193b002019-10-04 16:56:05 -0700112 -o ${PRJ_DIR}/hw/$($@_TOP)/ ${toolflags}
Eunchan Kim49634d72019-09-05 14:39:57 -0700113
Srikrishna Iyer707f8d62019-11-12 14:17:11 -0800114$(tops_reg): pre_reg
Srikrishna Iyer6c870cb2019-10-30 02:08:12 -0700115 $(eval $@_TOP := $(strip $(foreach top,$(TOPS),$(findstring $(top),$@))))
116 mkdir -p ${REG_OUTPUT_DV_DIR}/$($@_TOP)
117 ${PRJ_DIR}/util/topgen.py -t ${PRJ_DIR}/hw/$($@_TOP)/data/$($@_TOP).hjson \
118 -r -o ${REG_OUTPUT_DV_DIR}/$($@_TOP) ${toolflags}
119
120
Michael Schaffner6db11f22021-01-25 18:24:20 -0800121.PHONY: all banner otp-mmap lc-state-enc $(ips_reg) $(tops_gen) $(ips_reg_header)