build-fpga-regmap: namespace generated enum types#2392
Open
Conversation
this is intended to fix colliding names for fields
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.
When the
build-fpga-regmapcode generation emits a Rust enum type for enum fields in FPGA registers, the generated Rust type is named after the name of the register field (after being converted to CamelCase), and emitted in the same top-level generated code module as the register view types.This is all well and good until two different FPGA registers want to have enum fields with the same name, which seems like a fairly reasonable thing for the hardware folks to want to do. When there are two or more enum fields in different registers sharing the same name, the generated Rust types collide and the code no longer compiles.For instance, the FPGA changes @nathanaelhuffman pushed in 26f4837 added a second enum field named
hw_sm, in thenic_raw_statusregister. This results in generating a type that collides with theseq_raw_status[hw_sm]field. Rather than making Nathanael go back and rename all his register fields, the codegen should properly handle this.Thus, this commit changes the code generation a bit so that enum field types generated by
build-fpga-regmapare now emitted in submodules named after the register containing that field. So, rather than havingfmc_sequencer::HwSmas the enum that represents theseq_raw_status[hw_sm]field, we now producefmc_sequencer::seq_raw_status::HwSm, allowing it to coexist with the newnic_raw_status[hw_sm]field's enum, which lands infmc_sequencer::nic_raw_status::HwSm.This requires a small change to
cosmo_seqto get the enum types from the correct places. Thus far, I think thecosmo_seqtask is the only Hubris task that touches FPGA registers with enums.This is required for #2390