Skip to content

Commit

Permalink
3.1.3 - Some pruning for XMC4700
Browse files Browse the repository at this point in the history
  • Loading branch information
vkottler committed Oct 17, 2023
1 parent e254170 commit 531963d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions ifgen/commands/svd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# internal
from ifgen import PKG_NAME
from ifgen.svd import register_processors
from ifgen.svd.group import base, enums
from ifgen.svd.task import SvdProcessingTask


Expand All @@ -31,6 +32,12 @@ def svd_cmd(args: _Namespace) -> int:
)
assert path is not None, args.svd_file

enable_pruning = path.with_suffix("").name in {"XMC4700"}

# Only enable certain pruning strategies for certain processors.
enums.PRUNE_ENUMS = enable_pruning
base.PRUNE_STRUCTS = enable_pruning

SvdProcessingTask.svd(path).generate_configs(args.output)

return 0
Expand Down
5 changes: 4 additions & 1 deletion ifgen/svd/group/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def peripherals(self) -> Iterator[Peripheral]:
yield from self.derivatives


PRUNE_STRUCTS = False


def get_derived(
peripheral: Peripheral, peripherals: list[Peripheral]
) -> Optional[Peripheral]:
Expand All @@ -35,7 +38,7 @@ def get_derived(
result = peripheral.derived_elem

# Check if this peripheral is equivalent to some other peripheral.
else:
elif PRUNE_STRUCTS:
for other in peripherals:
# Always return None if you get far enough to see yourself in the
# list. That way this peripheral becomes the effective 'root'.
Expand Down
4 changes: 4 additions & 0 deletions ifgen/svd/group/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
}

BY_HASH: dict[str, dict[int, str]] = {}
PRUNE_ENUMS = False


def get_enum_name(name: str, peripheral: str, raw_mapping: EnumValues) -> str:
"""Get the name of an enumeration."""

if not PRUNE_ENUMS:
return name

hashed = hash(
",".join(
name + f"={val['value']}" for name, val in raw_mapping.items()
Expand Down
2 changes: 1 addition & 1 deletion local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 3
minor: 1
patch: 2
patch: 3
entry: ig

0 comments on commit 531963d

Please sign in to comment.