-
Notifications
You must be signed in to change notification settings - Fork 58
Register frontend: C header generation #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -60,6 +60,7 @@ IDMA_FE_IDS ?= $(IDMA_BASE_FE_IDS) $(IDMA_ADD_FE_IDS) | |||||||||||||||||||||||||||||
| # iDMA paths | ||||||||||||||||||||||||||||||
| IDMA_UTIL_DIR := $(IDMA_ROOT)/util | ||||||||||||||||||||||||||||||
| IDMA_RTL_DIR := $(IDMA_ROOT)/target/rtl | ||||||||||||||||||||||||||||||
| IDMA_SW_DIR := $(IDMA_ROOT)/target/sw | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # job file | ||||||||||||||||||||||||||||||
| IDMA_JOBS_JSON := jobs/jobs.json | ||||||||||||||||||||||||||||||
|
|
@@ -191,6 +192,10 @@ regwidth = $(word 1,$(subst _, ,$1)) | |||||||||||||||||||||||||||||
| dimension = $(word 2,$(subst _, ,$1)) | ||||||||||||||||||||||||||||||
| log2dimension = $(shell echo $$(( $$( echo "obase=2;$$(($(1)-1))" | bc | wc -c ) - 1 )) ) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Shared SPDX license header (raw-header takes plain text; c-header gets the //-prefixed variant) | ||||||||||||||||||||||||||||||
| IDMA_LICENSE := Copyright 2026 ETH Zurich and University of Bologna.\nSolderpad Hardware License, Version 0.51, see LICENSE for details.\nSPDX-License-Identifier: SHL-0.51 | ||||||||||||||||||||||||||||||
| IDMA_C_HDR_LIC := // $(subst \n,\n// ,$(IDMA_LICENSE))\n | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| $(IDMA_RTL_DIR)/idma_reg%d_reg_pkg.sv $(IDMA_RTL_DIR)/idma_reg%d_reg_top.sv $(IDMA_RTL_DIR)/idma_reg%d_addrmap_pkg.sv: | ||||||||||||||||||||||||||||||
| $(PEAKRDL) regblock $(IDMA_FE_DIR)/reg/idma_reg.rdl -o $(IDMA_RTL_DIR) \ | ||||||||||||||||||||||||||||||
| --default-reset arst_n --cpuif $(IDMA_REG_CPUIF) \ | ||||||||||||||||||||||||||||||
|
|
@@ -233,6 +238,40 @@ $(IDMA_HTML_DIR)/regs/idma_reg%d_reg/index.html: | |||||||||||||||||||||||||||||
| $(IDMA_HTML_DIR)/regs/idma_desc64_reg/index.html: | ||||||||||||||||||||||||||||||
| $(PEAKRDL) html $(IDMA_FE_DIR)/desc64/idma_desc64_reg.rdl -o $(IDMA_HTML_DIR)/regs/idma_desc64_reg | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # C header | ||||||||||||||||||||||||||||||
| $(IDMA_SW_DIR)/idma_reg%d_regs.h : | ||||||||||||||||||||||||||||||
| $(PEAKRDL) c-header $(IDMA_FE_DIR)/reg/idma_reg.rdl -o $@ \ | ||||||||||||||||||||||||||||||
| -b ltoh --type-style hier --rename idma_reg$*d \ | ||||||||||||||||||||||||||||||
| -P SysAddrWidth=$(call regwidth,$*) \ | ||||||||||||||||||||||||||||||
| -P NumDims=$(call dimension,$*) \ | ||||||||||||||||||||||||||||||
| -P Log2NumDims=$(call log2dimension,$(call dimension,$*)) | ||||||||||||||||||||||||||||||
| sed -i '1i$(IDMA_C_HDR_LIC)' $@ | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| $(IDMA_SW_DIR)/idma_reg%d_regs_unpacked.h : $(IDMA_SW_DIR)/idma_reg%d_regs.h | ||||||||||||||||||||||||||||||
| # with `packed` structs, the compiler may get confused and generate byte loads/stores to access fields. | ||||||||||||||||||||||||||||||
| sed -e "s/__attribute__ ((__packed__)) //" $^ > $@ | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| $(IDMA_SW_DIR)/idma_reg%d_raw_regs.h: | ||||||||||||||||||||||||||||||
| $(PEAKRDL) raw-header $(IDMA_FE_DIR)/reg/idma_reg.rdl -o $@ \ | ||||||||||||||||||||||||||||||
| --format c \ | ||||||||||||||||||||||||||||||
|
Comment on lines
+256
to
+257
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add licensing to the raw header too.
Suggested change
|
||||||||||||||||||||||||||||||
| --license_str="$(IDMA_LICENSE)" \ | ||||||||||||||||||||||||||||||
| -P SysAddrWidth=$(call regwidth,$*) \ | ||||||||||||||||||||||||||||||
| -P NumDims=$(call dimension,$*) \ | ||||||||||||||||||||||||||||||
| -P Log2NumDims=$(call log2dimension,$(call dimension,$*)) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the desc64 rules
Suggested change
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| $(IDMA_SW_DIR)/idma_desc64_regs.h: | ||||||||||||||||||||||||||||||
| $(PEAKRDL) c-header $(IDMA_FE_DIR)/desc64/idma_desc64_reg.rdl -o $@ \ | ||||||||||||||||||||||||||||||
| -b ltoh --type-style hier --rename idma_desc64 | ||||||||||||||||||||||||||||||
| sed -i '1i$(IDMA_C_HDR_LIC)' $@ | ||||||||||||||||||||||||||||||
| $(IDMA_SW_DIR)/idma_desc64_regs_unpacked.h: $(IDMA_SW_DIR)/idma_desc64_regs.h | ||||||||||||||||||||||||||||||
| sed -e "s/__attribute__ ((__packed__)) //" $< > $@ | ||||||||||||||||||||||||||||||
| $(IDMA_SW_DIR)/idma_desc64_raw_regs.h: | ||||||||||||||||||||||||||||||
| $(PEAKRDL) raw-header $(IDMA_FE_DIR)/desc64/idma_desc64_reg.rdl -o $@ \ | ||||||||||||||||||||||||||||||
| --format c --base_name idma_desc64 \ | ||||||||||||||||||||||||||||||
| --license_str="$(IDMA_LICENSE)" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| idma_reg_clean: | ||||||||||||||||||||||||||||||
| rm -rf $(IDMA_HTML_DIR)/regs | ||||||||||||||||||||||||||||||
| rm -f $(IDMA_RTL_DIR)/*_reg_top.sv | ||||||||||||||||||||||||||||||
|
|
@@ -247,6 +286,12 @@ IDMA_RTL_ALL += $(foreach Y,$(IDMA_FE_REGS),$(IDMA_RTL_DIR)/idma_$Y_addrmap_ | |||||||||||||||||||||||||||||
| IDMA_RTL_ALL += $(foreach Y,$(IDMA_FE_REGS),$(IDMA_RTL_DIR)/idma_$Y_top.sv) | ||||||||||||||||||||||||||||||
| IDMA_RTL_DOC_ALL += $(foreach Y,$(IDMA_FE_REGS),$(IDMA_HTML_DIR)/regs/idma_$Y_reg/index.html) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # C headers | ||||||||||||||||||||||||||||||
| IDMA_SW_ALL += $(foreach Y,$(IDMA_FE_REGS),$(IDMA_SW_DIR)/idma_$Y_regs.h) | ||||||||||||||||||||||||||||||
| IDMA_SW_ALL += $(foreach Y,$(IDMA_FE_REGS),$(IDMA_SW_DIR)/idma_$Y_regs_unpacked.h) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # C headers with the "raw-header" plugin | ||||||||||||||||||||||||||||||
| IDMA_SW_ALL += $(foreach Y,$(IDMA_FE_REGS),$(IDMA_SW_DIR)/idma_$Y_raw_regs.h) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # --------------- | ||||||||||||||||||||||||||||||
| # RTL assembly | ||||||||||||||||||||||||||||||
|
|
@@ -556,9 +601,9 @@ idma_nonfree_clean: | |||||||||||||||||||||||||||||
| # Misc Clean | ||||||||||||||||||||||||||||||
| # -------------- | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| .PHONY: idma_clean_all idma_clean idma_misc_clean | ||||||||||||||||||||||||||||||
| .PHONY: idma_clean_all idma_clean idma_misc_clean idma_sw_clean | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| idma_clean_all idma_clean: idma_rtl_clean idma_reg_clean idma_pickle_clean idma_sim_clean idma_vcs_clean idma_verilator_clean idma_spinx_doc_clean idma_trace_clean | ||||||||||||||||||||||||||||||
| idma_clean_all idma_clean: idma_rtl_clean idma_reg_clean idma_pickle_clean idma_sim_clean idma_vcs_clean idma_verilator_clean idma_spinx_doc_clean idma_trace_clean idma_sw_clean | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| idma_misc_clean: | ||||||||||||||||||||||||||||||
| rm -rf scripts/__pycache__ | ||||||||||||||||||||||||||||||
|
|
@@ -569,6 +614,9 @@ idma_misc_clean: | |||||||||||||||||||||||||||||
| idma_nuke: idma_clean idma_nonfree_clean | ||||||||||||||||||||||||||||||
| rm -rf .bender | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| idma_sw_clean: | ||||||||||||||||||||||||||||||
| rm -rf $(IDMA_SW_DIR)/*.h | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # -------------- | ||||||||||||||||||||||||||||||
| # Phony Targets | ||||||||||||||||||||||||||||||
|
|
@@ -582,6 +630,8 @@ idma_pickle_all: $(IDMA_PICKLE_ALL) | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| idma_hw_all: $(IDMA_FULL_RTL) $(IDMA_INCLUDE_ALL) $(IDMA_FULL_TB) $(IDMA_HJSON_ALL) $(IDMA_WAVE_ALL) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| idma_sw_all: $(IDMA_SW_ALL) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| idma_sim_all: $(IDMA_VCS_DIR)/compile.sh $(IDMA_VSIM_DIR)/compile.tcl | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| idma_all: idma_hw_all idma_sim_all idma_doc_all idma_pickle_all | ||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,4 +20,5 @@ dependencies = [ | |
| "pylint", | ||
| "peakrdl>=1.5.0", | ||
| "peakrdl-rawheader>=0.2.4", | ||
| "peakrdl-cheader>=1.1.0", | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *.h |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding license to generated files