Sam Elliott | 45fb1c6 | 2020-06-02 18:18:54 +0100 | [diff] [blame] | 1 | # 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 Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 5 | CUR_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) |
| 6 | PRJ_DIR := $(realpath ${CUR_DIR}/../) |
| 7 | export PRJ_DIR |
| 8 | |
Srikrishna Iyer | 6c870cb | 2019-10-30 02:08:12 -0700 | [diff] [blame] | 9 | REG_OUTPUT_DIR ?= ${PRJ_DIR}/build/regs-generated |
| 10 | REG_OUTPUT_DV_DIR ?= ${REG_OUTPUT_DIR}/dv |
| 11 | REG_OUTPUT_SW_DIR ?= ${REG_OUTPUT_DIR}/sw |
| 12 | |
Michael Schaffner | 24984fc | 2020-01-17 17:42:57 -0800 | [diff] [blame] | 13 | IPS ?= aes \ |
Eric Shiu | 5f1d304 | 2021-03-17 17:24:11 -0700 | [diff] [blame] | 14 | adc_ctrl \ |
Michael Schaffner | 1b1ede9 | 2019-09-24 18:49:47 -0700 | [diff] [blame] | 15 | alert_handler \ |
Timothy Chen | 2b8ef76 | 2021-02-16 14:44:55 -0800 | [diff] [blame] | 16 | aon_timer \ |
Timothy Chen | 3525aa8 | 2020-04-23 23:23:18 -0700 | [diff] [blame] | 17 | clkmgr \ |
Cindy Chen | dec0771 | 2020-10-27 17:16:12 -0700 | [diff] [blame] | 18 | entropy_src \ |
Mark Branstad | a069bb0 | 2020-12-02 11:59:34 -0800 | [diff] [blame] | 19 | csrng \ |
| 20 | edn \ |
Michael Schaffner | 24984fc | 2020-01-17 17:42:57 -0800 | [diff] [blame] | 21 | flash_ctrl \ |
| 22 | gpio \ |
| 23 | hmac \ |
Eunchan Kim | 1a95905 | 2020-09-18 15:10:22 -0700 | [diff] [blame] | 24 | kmac \ |
Michael Schaffner | 24984fc | 2020-01-17 17:42:57 -0800 | [diff] [blame] | 25 | i2c \ |
Timothy Chen | 15adeee | 2020-09-09 15:44:35 -0700 | [diff] [blame] | 26 | keymgr \ |
Michael Schaffner | e81ab75 | 2020-09-30 18:57:29 -0700 | [diff] [blame] | 27 | lc_ctrl \ |
Michael Schaffner | 24984fc | 2020-01-17 17:42:57 -0800 | [diff] [blame] | 28 | nmi_gen \ |
Michael Schaffner | 41319c2 | 2020-04-12 15:40:24 -0700 | [diff] [blame] | 29 | otp_ctrl \ |
Timothy Chen | d12569f | 2021-02-12 15:28:12 -0800 | [diff] [blame] | 30 | pattgen \ |
Michael Schaffner | 24984fc | 2020-01-17 17:42:57 -0800 | [diff] [blame] | 31 | pinmux \ |
Timothy Chen | bc16a17 | 2020-04-07 23:45:23 -0700 | [diff] [blame] | 32 | pwrmgr \ |
Rupert Swarbrick | 9855d4b | 2020-12-02 08:41:35 +0000 | [diff] [blame] | 33 | rom_ctrl \ |
Timothy Chen | 612901b | 2020-03-05 17:03:13 -0800 | [diff] [blame] | 34 | rstmgr \ |
Michael Schaffner | 24984fc | 2020-01-17 17:42:57 -0800 | [diff] [blame] | 35 | rv_plic \ |
| 36 | rv_timer \ |
Timothy Chen | 1e6db37 | 2020-05-19 20:52:45 -0700 | [diff] [blame] | 37 | sensor_ctrl \ |
Michael Schaffner | 24984fc | 2020-01-17 17:42:57 -0800 | [diff] [blame] | 38 | spi_device \ |
Michael Schaffner | 8e04df3 | 2021-02-09 19:52:24 -0800 | [diff] [blame] | 39 | spi_host \ |
Michael Schaffner | 86c0e32 | 2020-10-07 19:56:32 -0700 | [diff] [blame] | 40 | sram_ctrl \ |
Eric Shiu | 33ad532 | 2021-03-11 19:23:00 -0800 | [diff] [blame] | 41 | sysrst_ctrl \ |
Michael Schaffner | 24984fc | 2020-01-17 17:42:57 -0800 | [diff] [blame] | 42 | trial1 \ |
Philipp Wagner | 5c2d294 | 2020-06-22 11:34:00 +0100 | [diff] [blame] | 43 | otbn \ |
Michael Schaffner | 24984fc | 2020-01-17 17:42:57 -0800 | [diff] [blame] | 44 | uart \ |
| 45 | usbdev \ |
| 46 | usbuart |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 47 | |
Eunchan Kim | 49634d7 | 2019-09-05 14:39:57 -0700 | [diff] [blame] | 48 | TOPS ?= top_earlgrey |
| 49 | |
Timothy Chen | 3193b00 | 2019-10-04 16:56:05 -0700 | [diff] [blame] | 50 | # conditional flags |
| 51 | VERBOSE ?= 0 |
| 52 | toolflags ?= |
| 53 | ifeq ($(VERBOSE),1) |
| 54 | toolflags += -v |
| 55 | endif |
| 56 | |
Tobias Wölfel | 4c5fbec | 2019-10-23 12:43:17 +0200 | [diff] [blame] | 57 | dir_hjson = data |
Timothy Chen | 3193b00 | 2019-10-04 16:56:05 -0700 | [diff] [blame] | 58 | |
Eunchan Kim | 2366287 | 2019-11-18 11:52:13 -0800 | [diff] [blame] | 59 | dynips_reg = $(addsuffix _reg, $(IPS)) |
Eunchan Kim | 53e3b3b | 2019-11-13 12:33:49 -0800 | [diff] [blame] | 60 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 61 | ips_reg = $(addsuffix _reg, $(IPS)) |
| 62 | |
Tobias Wölfel | ce06a24 | 2019-10-23 13:54:46 +0200 | [diff] [blame] | 63 | ips_reg_header = $(addsuffix _reg_header, $(IPS)) |
| 64 | |
Eunchan Kim | 49634d7 | 2019-09-05 14:39:57 -0700 | [diff] [blame] | 65 | tops_gen = $(addsuffix _gen,$(TOPS)) |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 66 | |
Srikrishna Iyer | 6c870cb | 2019-10-30 02:08:12 -0700 | [diff] [blame] | 67 | tops_reg = $(addsuffix _reg,$(TOPS)) |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 68 | |
Michael Schaffner | 6db11f2 | 2021-01-25 18:24:20 -0800 | [diff] [blame] | 69 | all: $(dynips_reg) $(tops_gen) $(tops_reg) banner |
Srikrishna Iyer | 6c870cb | 2019-10-30 02:08:12 -0700 | [diff] [blame] | 70 | |
| 71 | banner: |
| 72 | @echo "############################################" |
| 73 | @echo "Note: Regs for DV & SW are now generated at:" |
| 74 | @echo "${REG_OUTPUT_DIR}" |
| 75 | @echo "############################################" |
| 76 | |
Eunchan Kim | 53e3b3b | 2019-11-13 12:33:49 -0800 | [diff] [blame] | 77 | regs: $(dynips_reg) $(tops_reg) banner |
Srikrishna Iyer | 6c870cb | 2019-10-30 02:08:12 -0700 | [diff] [blame] | 78 | |
| 79 | pre_reg: |
| 80 | mkdir -p ${REG_OUTPUT_DIR} |
| 81 | mkdir -p ${REG_OUTPUT_DV_DIR} |
| 82 | mkdir -p ${REG_OUTPUT_SW_DIR} |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 83 | |
Michael Schaffner | 6db11f2 | 2021-01-25 18:24:20 -0800 | [diff] [blame] | 84 | $(ips_reg): pre_reg otp-mmap lc-state-enc |
Tobias Wölfel | 4c5fbec | 2019-10-23 12:43:17 +0200 | [diff] [blame] | 85 | if [ -f ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson ]; then \ |
Rupert Swarbrick | 6880e21 | 2021-02-10 16:10:00 +0000 | [diff] [blame] | 86 | ${PRJ_DIR}/util/regtool.py ${toolflags} -r ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson && \ |
Srikrishna Iyer | 6c870cb | 2019-10-30 02:08:12 -0700 | [diff] [blame] | 87 | ${PRJ_DIR}/util/regtool.py -s -t ${REG_OUTPUT_DV_DIR} \ |
Tobias Wölfel | 4c5fbec | 2019-10-23 12:43:17 +0200 | [diff] [blame] | 88 | ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson; \ |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 89 | fi |
| 90 | |
Michael Schaffner | f6a7900 | 2020-10-27 10:00:13 -0700 | [diff] [blame] | 91 | otp-mmap: |
Michael Schaffner | 1fff985 | 2021-01-08 14:06:35 -0800 | [diff] [blame] | 92 | cd ${PRJ_DIR} && ./util/design/gen-otp-mmap.py |
Michael Schaffner | f6a7900 | 2020-10-27 10:00:13 -0700 | [diff] [blame] | 93 | |
Michael Schaffner | 6db11f2 | 2021-01-25 18:24:20 -0800 | [diff] [blame] | 94 | lc-state-enc: |
| 95 | cd ${PRJ_DIR} && ./util/design/gen-lc-state-enc.py |
| 96 | |
Srikrishna Iyer | 707f8d6 | 2019-11-12 14:17:11 -0800 | [diff] [blame] | 97 | regs-header: $(ips_reg_header) banner |
Srikrishna Iyer | 6c870cb | 2019-10-30 02:08:12 -0700 | [diff] [blame] | 98 | |
Srikrishna Iyer | 707f8d6 | 2019-11-12 14:17:11 -0800 | [diff] [blame] | 99 | $(ips_reg_header): pre_reg |
Tobias Wölfel | ce06a24 | 2019-10-23 13:54:46 +0200 | [diff] [blame] | 100 | if [ -f ${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/$(dir_hjson)/$(subst _reg_header,,$@).hjson ]; then \ |
Srikrishna Iyer | 6c870cb | 2019-10-30 02:08:12 -0700 | [diff] [blame] | 101 | ${PRJ_DIR}/util/regtool.py -D -o ${REG_OUTPUT_SW_DIR}/$(subst _reg_header,_reg_headers,$@).h\ |
Tobias Wölfel | ce06a24 | 2019-10-23 13:54:46 +0200 | [diff] [blame] | 102 | ${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/$(dir_hjson)/$(subst _reg_header,,$@).hjson; \ |
Tobias Wölfel | ce06a24 | 2019-10-23 13:54:46 +0200 | [diff] [blame] | 103 | fi |
| 104 | |
| 105 | clean-regs-header: |
Srikrishna Iyer | 6c870cb | 2019-10-30 02:08:12 -0700 | [diff] [blame] | 106 | rm -r -f ${REG_OUTPUT_SW_DIR} |
Tobias Wölfel | ce06a24 | 2019-10-23 13:54:46 +0200 | [diff] [blame] | 107 | |
Srikrishna Iyer | 6c870cb | 2019-10-30 02:08:12 -0700 | [diff] [blame] | 108 | top: $(tops_gen) $(tops_reg) |
Eunchan Kim | 49634d7 | 2019-09-05 14:39:57 -0700 | [diff] [blame] | 109 | $(tops_gen): |
| 110 | $(eval $@_TOP := $(strip $(foreach top,$(TOPS),$(findstring $(top),$@)))) |
Michael Schaffner | 7f13496 | 2019-11-03 12:44:50 -0800 | [diff] [blame] | 111 | ${PRJ_DIR}/util/topgen.py -t ${PRJ_DIR}/hw/$($@_TOP)/data/$($@_TOP).hjson \ |
Timothy Chen | 3193b00 | 2019-10-04 16:56:05 -0700 | [diff] [blame] | 112 | -o ${PRJ_DIR}/hw/$($@_TOP)/ ${toolflags} |
Eunchan Kim | 49634d7 | 2019-09-05 14:39:57 -0700 | [diff] [blame] | 113 | |
Srikrishna Iyer | 707f8d6 | 2019-11-12 14:17:11 -0800 | [diff] [blame] | 114 | $(tops_reg): pre_reg |
Srikrishna Iyer | 6c870cb | 2019-10-30 02:08:12 -0700 | [diff] [blame] | 115 | $(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 Schaffner | 6db11f2 | 2021-01-25 18:24:20 -0800 | [diff] [blame] | 121 | .PHONY: all banner otp-mmap lc-state-enc $(ips_reg) $(tops_gen) $(ips_reg_header) |