Skip to content
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

generating headers from neorv32.svd #595

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Conversation

biosbob
Copy link
Collaborator

@biosbob biosbob commented Apr 22, 2023

for some background, see #590

@biosbob
Copy link
Collaborator Author

biosbob commented Apr 23, 2023

there are definitely some "wrong" values still sourced in neorv32.svd.... until an exhaustive regression test is run, the generated headers should NOT be used in general....

right now, i'm looking for general approval of the approach -- after which i'll take this PR a few steps further....

@stnolting
Copy link
Owner

stnolting commented Apr 23, 2023

Hey there!

This looks really promising! Unfortunately, my Python capabilities are quite limited, so it'll take a while for me to understand your script 😉

I see a general problem here. The current C and header files use Doxygen comments for generating the online software framework documentation at https://stnolting.github.io/neorv32/sw/files.html. How would we generate those comments from the SVD file?

I also think that would be a nice feature if the automatic conversion could generate an individual header file for each module (like it is done manually now). I think this would be much cleaner. What do you think?

@biosbob
Copy link
Collaborator Author

biosbob commented Apr 23, 2023

my python skills are also quite limited; i only picked python because i found other .py files in the project.... my preferred scripting language is node.js, if that helps.... let me know what you'd prefer....

as for the doxygen comments, it's a straightforward exercise to generate these as well.... the .svd file already has <description> elements, which can be used as the "source" for the doxygen comments; they're already quite close....

@biosbob
Copy link
Collaborator Author

biosbob commented Apr 23, 2023

the individual header files would continue to exist in this approach -- they would still need to define the functional APIs implemented in the corresponding C files....

but since these API defintions are NOT sourced from the .svd file, they would still need to be maintained manually in the headers themselves....

while it is possible to mix "automatically-generated" and "manually-maintained" code in a single file, it's not a best-practice.... the generated neorv32_svd.h is a "lower-level" register interface to the raw hardware, while the neorv32_<peripheral>.h files are a higher-level functional interface....

@stnolting
Copy link
Owner

my python skills are also quite limited; i only picked python because i found other .py files in the project.... my preferred scripting language is node.js, if that helps.... let me know what you'd prefer....

I Think I am pretty old-school here. I like bash scripts and good old makefiles 😅 But Python is also just fine.

as for the doxygen comments, it's a straightforward exercise to generate these as well.... the .svd file already has elements, which can be used as the "source" for the doxygen comments; they're already quite close....

That would be great!

Btw, have you tested the auto-generated header file for completeness? I think some defines might be missing (e.g. pre-defined bit patters). You could also define NEORV32_STD_HEADER in the CI pipeline's run script:

neorv32/do.py

Line 30 in d0cd94a

"make -C sw/example/processor_check clean_all USER_FLAGS+=-DRUN_CHECK USER_FLAGS+=-DUART0_SIM_MODE USER_FLAGS+=-DUART1_SIM_MODE USER_FLAGS+=-flto MARCH=rv32imc info all",

@stnolting stnolting marked this pull request as draft April 23, 2023 19:05
@stnolting stnolting added enhancement New feature or request SW software-related experimental Experimental feature labels Apr 23, 2023
@stnolting
Copy link
Owner

Hey @biosbob!

This PR has been pending for way too long... sorry for that 🙈

How about refreshing this? I think it would be really handy if we could provide a simple script that turns all the header files into a single SVD file - automatically.

If the impact on the header files is low (which it seems to be) and if we keep the manually-drafted SVD file for now I would be totally fine with this. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request experimental Experimental feature SW software-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants