[dv] refactor reggen for on-the-fly ral generation
- refactored ral template to encapsulate classes within <block>_ral_pkg
package
- modified flow to generate above package in scratch area
- removed `hw/ip/uart/dv/env/uart_reg_block.sv` and made associated
changes in that area to support this change
- added `hw/dv/tools/gen_ral_pkg.py` wrapper script that generates the
ral pkg by calling regtool as well as the associated fusesoc core file
to insert the dependency correctly
- removed hw/ip/*/dv/env/*_reg_block.sv
- Updated hw/ip/*/env/*_env_pkg.sv and hw/ip/*/env/*_env.core files
accordingly to add the autogenerated ral pkg as dependency
- updated DV plan docs to reflect this
- updated `hw/Makefile` to create RAL and SW sources in
$REPO_TOP/build/regs-generated area
Signed-off-by: Srikrishna Iyer <sriyer@google.com>
diff --git a/hw/Makefile b/hw/Makefile
index 9997031..3169380 100644
--- a/hw/Makefile
+++ b/hw/Makefile
@@ -2,6 +2,10 @@
PRJ_DIR := $(realpath ${CUR_DIR}/../)
export PRJ_DIR
+REG_OUTPUT_DIR ?= ${PRJ_DIR}/build/regs-generated
+REG_OUTPUT_DV_DIR ?= ${REG_OUTPUT_DIR}/dv
+REG_OUTPUT_SW_DIR ?= ${REG_OUTPUT_DIR}/sw
+
IPS ?= uart \
gpio \
rv_plic \
@@ -32,35 +36,53 @@
tops_gen = $(addsuffix _gen,$(TOPS))
-all: $(ips_reg) $(tops_gen)
+tops_reg = $(addsuffix _reg,$(TOPS))
-regs: $(ips_reg)
+all: $(ips_reg) $(tops_gen) $(tops_reg)
+
+banner:
+ @echo "############################################"
+ @echo "Note: Regs for DV & SW are now generated at:"
+ @echo "${REG_OUTPUT_DIR}"
+ @echo "############################################"
+
+regs: pre_reg $(ips_reg) $(tops_reg) banner
+
+pre_reg:
+ mkdir -p ${REG_OUTPUT_DIR}
+ mkdir -p ${REG_OUTPUT_DV_DIR}
+ mkdir -p ${REG_OUTPUT_SW_DIR}
$(ips_reg):
if [ -f ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson ]; then \
${PRJ_DIR}/util/regtool.py -r ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson; \
- ${PRJ_DIR}/util/regtool.py -s -t ${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/dv/env \
+ ${PRJ_DIR}/util/regtool.py -s -t ${REG_OUTPUT_DV_DIR} \
${PRJ_DIR}/hw/ip/$(subst _reg,,$@)/$(dir_hjson)/$(subst _reg,,$@).hjson; \
fi
-regs-header: $(ips_reg_header)
+regs-header: pre_reg $(ips_reg_header) banner
+
$(ips_reg_header):
if [ -f ${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/$(dir_hjson)/$(subst _reg_header,,$@).hjson ]; then \
- [[ -d ${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/sw ]] || mkdir ${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/sw; \
- ${PRJ_DIR}/util/regtool.py -D -o ${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/sw/$(subst _reg_header,_reg_headers,$@).h\
+ ${PRJ_DIR}/util/regtool.py -D -o ${REG_OUTPUT_SW_DIR}/$(subst _reg_header,_reg_headers,$@).h\
${PRJ_DIR}/hw/ip/$(subst _reg_header,,$@)/$(dir_hjson)/$(subst _reg_header,,$@).hjson; \
fi
clean-regs-header:
- rm -r -f ip/*/sw
+ rm -r -f ${REG_OUTPUT_SW_DIR}
-top: $(tops_gen)
+top: $(tops_gen) $(tops_reg)
$(tops_gen):
$(eval $@_TOP := $(strip $(foreach top,$(TOPS),$(findstring $(top),$@))))
${PRJ_DIR}/util/topgen.py -t ${PRJ_DIR}/hw/$($@_TOP)/data/$($@_TOP).hjson \
--tpl ${PRJ_DIR}/hw/$($@_TOP)/data/ \
-o ${PRJ_DIR}/hw/$($@_TOP)/ ${toolflags}
- ${PRJ_DIR}/util/topgen.py -t ${PRJ_DIR}/hw/$($@_TOP)/data/$($@_TOP).hjson \
- -r -o ${PRJ_DIR}/hw/$($@_TOP)/dv/env/ ${toolflags}
-.PHONY: all $(ips_reg) $(tops_gen) $(ips_reg_header)
+$(tops_reg):
+ $(eval $@_TOP := $(strip $(foreach top,$(TOPS),$(findstring $(top),$@))))
+ mkdir -p ${REG_OUTPUT_DV_DIR}/$($@_TOP)
+ ${PRJ_DIR}/util/topgen.py -t ${PRJ_DIR}/hw/$($@_TOP)/data/$($@_TOP).hjson \
+ -r -o ${REG_OUTPUT_DV_DIR}/$($@_TOP) ${toolflags}
+
+
+.PHONY: all banner $(ips_reg) $(tops_gen) $(ips_reg_header)