AdaCore / AdaCore/svd2ada

`svd2ada` doesn't support `dimElementGroup` in peripheral tags (`peripheralType`)

Open
#100 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ada
Stars
71
Forks
41
PR merge metrics
No merged PRs in 30d

Description

SVD schema 1.3.1 allows use of tags to define arrays/lists of peripheralType. The schema is used by svd2ada but the current implementation raises CONSTRAINT_ERROR because it doesn't recognize the dim-related tags when they appear in a peripheralType.

<xs:complexType name="peripheralType">
    <xs:sequence>
      <!-- 1.3: specify uni-dimensional array of peripheral - requires name="<name>[%s]" -->
      <xs:group    ref="dimElementGroup" minOccurs="0"/>
      <!-- name specifies the name of a peripheral. This name is used for the System View and device header file -->

dimElementGroup contains tags defining the kind of list of peripherals based on the peripheral containing the dim-tag, pretty much like it's done for registers, too.

  <!-- dimElementGroup specifies the number of array elements (dim), the address offset
       between to consecutive array elements and an a comma seperated list of strings
       being used for identifying each element in the array -->
  <xs:group name="dimElementGroup">
    <xs:sequence>
      <xs:element name="dim" type="scaledNonNegativeInteger"/>
      <xs:element name="dimIncrement" type="scaledNonNegativeInteger"/>
      <xs:element name="dimIndex" type="dimIndexType" minOccurs="0"/>
    </xs:sequence>
  </xs:group>

My assumption is that svd2ada implements the schema which is located in directory schema of this project, but this might be wrong, so I'm sorry in case I've missed something!

Support of dimElementGroup for peripheralType would reduce SVD size and complexity, and thus the resulting code, at least in case a device realizes multiple instances of an individual periphery. Using arrays could also simplify the driver implementation.

A similar effect could be achieved by use of clusters. I guess this therefore is not a major blocker... But once there's a more complex SVD which makes use of this feaure, it would be necessary to modify the file to work around this issue.

If there were plans to realize this in svd2ada, it might be worth considering an update to SVD version 1.3.9 which additionally supports dimArrayIndex in dimElementGroup. This is pretty useful when it comes to symbolic access of array elements (applicable to all tags supporting dimElementGroup, not only periphalType). Further information on this can be found here: https://www.keil.com/pack/doc/CMSIS/SVD/html/elem_special.html#elem_dimArrayIndex

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the schema directory and the existing register handling for dimElementGroup in svd2ada. Trace how peripheralType tags are parsed and identify where the unrecognized dim-related tags cause CONSTRAINT_ERROR. Done means peripheral arrays using dim, dimIncrement, and optional dimIndex are accepted without that failure.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.