Skip to content

Commit

Permalink
Skip code generation for fields marked "reserved"
Browse files Browse the repository at this point in the history
The goal is to correct the documentation generated for the CCM CCGR
fields. Based on how the combiner works, these fields are generally
considered combine-able across all chips. So when we generate code for
the 1061 CCM, we're permitted to use the fields from the 1011 CCM. The
1011 CCM has many more reserved gates than the 1062 CCM, so those end up
leaking into the documentation.

This commit drops the fields that are marked "reserved" in their
human-readable description. It's not clear why these are provided in the
SVD. By dropping these reserved fields, we change the "field plurality"
heuristic that the combiner uses to understand equivalent fieldsets.
Notice how the CCGR documentation corrects itself in the 1061 CCM. We
also generate less code, and less chance for humans to poke at reserved
registers.

I'm not a fan of hard-coding this behavior into the SVD importer. But it
was easy to prototype. I might consider a transform that does this
across all document-able items.

I didn't use a 'contains("reserved")' predicate for the field skip.
There are some fields that are documented with "all other values are
reserved," so that larger-reaching predicate would incorrectly remove
those fields. I briefly scanned these changes to make sure removals
seemed appropriate.
  • Loading branch information
mciantyre committed Apr 6, 2024
1 parent 51f6f70 commit 293049f
Show file tree
Hide file tree
Showing 22 changed files with 236 additions and 3,694 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ Exclude the interrupt vector table when we're building for a target with an
operating system. This ensures you can build imxrt-ral in different contexts,
like build scripts.

Drop all register fields that are documented as "reserved" (first word of the
description, all lowercase). Dropping these fields changes the combiner's
approach for combining fieldsets, enabling correct documentation for non-
reserved fields.

## [0.5.0] 2022-12-27

Add support for NXP's i.MX RT 1176 dual-core MCUs. An `"imxrt1176_cm7"` feature
Expand Down
6 changes: 6 additions & 0 deletions raltool/src/svd2ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ pub fn convert_peripheral(ir: &mut IR, p: &svd::Peripheral) -> anyhow::Result<()
warn!("unsupported derived_from in fieldset");
}

if let Some(desc) = &f.description {
if desc.to_lowercase().starts_with("reserved") {
continue;
}
}

let mut field = Field {
name: f.name.clone(),
description: f.description.clone(),
Expand Down
Loading

0 comments on commit 293049f

Please sign in to comment.