Kicad insists on annotating every component with a numeric suffix that can change depending on the sequence of components encountered during the annotation process. HAL, on the other hand, identifies multiple components using a numeric value as a suffix or embedded within the reference. HAL also has singleton components without a numeric value.
A Moby Hack™ merges the two systems: Kicad will annotate each of its components, then Kicad-to-HAL can strip the annotation from the reference to form the HAL identifier.
A Kicad component with a StripAnno field containing a “1” will trigger the stripping:

The StripAnno digit (generally) appears to the right of the component name. A Kicad component without a StripAnno field or with the field containing anything other than “1” will pass its reference field directly into the HAL component.
The Kicad reference for the HM2_5I25 component (center right) is hm2_5i25.0.0 and its stripped HAL reference is hm2_5i25.0:
addf hm2_5i25.0.read servo-thread
The THREAD component (center bottom) is a singleton, because there will be only one component with a given thread name:

The Kicad reference appends a zero to make servo-thread.0:

The stripped HAL reference, as used in addf statements, is just servo-thread:
addf and2.0 servo-thread
addf constant.0 servo-thread
addf constant.1 servo-thread
addf not.0 servo-thread
addf timedelay.0 servo-thread
addf toggle.0 servo-thread
Every Kicad symbol must have a reference ending with a period so Kicad-to-HAL can strip the trailing annotation value.
Comments
2 responses to “Kicad-to-HAL: Annotation Stripping”
[…] of the Kicad symbols include the StripAnno field to remove the Kicad annotation, as described earlier. The Kicad annotations now start from 100, because I’m in the midst of tinkering an automagic […]
[…] Kicad annotation stripping: https://softsolder.com/2021/03/31/kicad-to-hal-annotation-stripping/ […]