Register frontend: C header generation - #158
Merged
Merged
Conversation
- This target generates C headers in `target/sw` with both the `raw-header` and `c-header` PeakRDL plugins - Also added to `deploy` CI job
da-gazzi
requested review from
DanielKellerM,
micprog and
thommythomaso
as code owners
July 13, 2026 08:13
DanielKellerM
requested changes
Jul 30, 2026
DanielKellerM
left a comment
Collaborator
There was a problem hiding this comment.
Thank you for your contribution. Could you check the comments / changes I requested?
Comment on lines
+239
to
+242
| $(PEAKRDL) c-header $(IDMA_FE_DIR)/reg/idma_reg.rdl -i -o $@ \ | ||
| -P SysAddrWidth=$(call regwidth,$*) \ | ||
| -P NumDims=$(call dimension,$*) \ | ||
| -P Log2NumDims=$(call log2dimension,$(call dimension,$*)) |
Collaborator
There was a problem hiding this comment.
- Use the rename to keep compatibility with other IPs that consume the sw.
- Drop -i since we dont need a fixed absolute address.
- Prepend the SPDX header via sed (c-header has no --license_str).
Suggested change
| $(PEAKRDL) c-header $(IDMA_FE_DIR)/reg/idma_reg.rdl -i -o $@ \ | |
| -P SysAddrWidth=$(call regwidth,$*) \ | |
| -P NumDims=$(call dimension,$*) \ | |
| -P Log2NumDims=$(call log2dimension,$(call dimension,$*)) | |
| $(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_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 |
Collaborator
There was a problem hiding this comment.
Adding license to generated files
Suggested change
| # C header | |
| # C header | |
| 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 |
Comment on lines
+250
to
+251
| $(PEAKRDL) raw-header $(IDMA_FE_DIR)/reg/idma_reg.rdl -o $@ \ | ||
| --format c \ |
Collaborator
There was a problem hiding this comment.
Add licensing to the raw header too.
Suggested change
| $(PEAKRDL) raw-header $(IDMA_FE_DIR)/reg/idma_reg.rdl -o $@ \ | |
| --format c \ | |
| $(PEAKRDL) raw-header $(IDMA_FE_DIR)/reg/idma_reg.rdl -o $@ \ | |
| --format c \ | |
| --license_str="$(IDMA_LICENSE)" \ |
Comment on lines
+271
to
+272
| IDMA_SW_ALL += $(foreach Y,$(IDMA_FE_IDS),$(IDMA_SW_DIR)/idma_$Y_regs.h) | ||
| IDMA_SW_ALL += $(foreach Y,$(IDMA_FE_IDS),$(IDMA_SW_DIR)/idma_$Y_regs_unpacked.h) |
Collaborator
There was a problem hiding this comment.
Extend SW generation to descriptor based frontend:
Suggested change
| IDMA_SW_ALL += $(foreach Y,$(IDMA_FE_IDS),$(IDMA_SW_DIR)/idma_$Y_regs.h) | |
| IDMA_SW_ALL += $(foreach Y,$(IDMA_FE_IDS),$(IDMA_SW_DIR)/idma_$Y_regs_unpacked.h) | |
| 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) |
| IDMA_SW_ALL += $(foreach Y,$(IDMA_FE_IDS),$(IDMA_SW_DIR)/idma_$Y_regs_unpacked.h) | ||
|
|
||
| # C headers with the "raw-header" plugin | ||
| IDMA_SW_ALL += $(foreach Y,$(IDMA_FE_IDS),$(IDMA_SW_DIR)/idma_$Y_raw_regs.h) |
Collaborator
There was a problem hiding this comment.
Same SW for descriptro based frontend
Suggested change
| IDMA_SW_ALL += $(foreach Y,$(IDMA_FE_IDS),$(IDMA_SW_DIR)/idma_$Y_raw_regs.h) | |
| IDMA_SW_ALL += $(foreach Y,$(IDMA_FE_REGS),$(IDMA_SW_DIR)/idma_$Y_raw_regs.h) |
| -P SysAddrWidth=$(call regwidth,$*) \ | ||
| -P NumDims=$(call dimension,$*) \ | ||
| -P Log2NumDims=$(call log2dimension,$(call dimension,$*)) | ||
|
|
Collaborator
There was a problem hiding this comment.
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)" |
- the PeakRDL `c-header` plugin generates structs with `__attribute__((__packed__))` which ensures proper packing of fields but can also cause the compiler to emit byte loads/stores to access 32-bit registers, which is definitely not what we want. The `unpacked` version of the C header has the attribute removed. - The `idma_sw_clean` target had a typo and didn't actually clean anything, this is fixed now.
Contributor
Author
|
Implemented, thanks a lot for reviewing! |
DanielKellerM
approved these changes
Jul 31, 2026
DanielKellerM
left a comment
Collaborator
There was a problem hiding this comment.
Feedback addressed (rename/type-style/ltoh, SPDX, desc64). Thanks!
DanielKellerM
pushed a commit
that referenced
this pull request
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
maketargetidma_sw_allto generatetarget/sw/idma_reg{32,64}_${N}d_[raw_]regs.hfor each generated register frontend.rawin the name uses the PeakRDLc-headerplugin to create a struct-based header, the one withrawis generated with theraw-headerplugin. Therawversion is (with the current version ofraw-header) somewhat incomplete as the masks for sub-register bitfields have to be generated/hardcoded externally.deployCI job calls this target anddeploy.pyis amended to edit the appropriate.gitignore; C headers are also checked intodeploybranchesuv.lockandpyproject.tomlamended so thec-headerplugin is part of the environment