Skip to content

Fix: XML Component Multi-Device Variant With names#1605

Merged
ra3xdh merged 3 commits intora3xdh:dev/xml_devicesfrom
abdur-rahman-dev:fix/xml_component_multi_device_names
Apr 7, 2026
Merged

Fix: XML Component Multi-Device Variant With names#1605
ra3xdh merged 3 commits intora3xdh:dev/xml_devicesfrom
abdur-rahman-dev:fix/xml_component_multi_device_names

Conversation

@abdur-rahman-dev
Copy link
Copy Markdown

Problem Statement

When XML components defined multiple device variants via a comma-separated names attribute, three critical issues existed:

Issue 1: Variant Loss on Load

  • Loading a schematic always restored the first registered variant, not the user-selected one
  • No mechanism existed to persist which variant the user had chosen

Issue 2: Placeholder Leakage

  • Parameter defaults containing {names} showed the literal string "{names}" instead of the actual variant name
  • This broke components that used placeholder in parameter defaults

Issue 3: Registration Collisions , Solution of Issue 1 escalation

  • Without {names} resolution in DefaultModel/SpiceModel, all multi-name XML files registered to the same s_modules key: the literal string "{names}"
  • This caused cross-file collisions when multiple XML files used DefaultModel="{names}"
  • Loading any file would resolve to whichever file was registered first

Fixes

  1. Variant persistence via hidden _xml_device_name property : Commit: 1a89db21
  2. Placeholder resolution in DefaultModel, SpiceModel, and parameter defaults : Commit : fdcca170
  3. Conditional parameter filtering with user edit preservation : Commit : 23428486

Details on changes is described in the corresponding commit.

XML Authoring Patterns (Usage Model)

The implementation supports three distinct authoring patterns, giving XML authors flexibility:

Pattern 1: Unique Model Per Variant (Using Placeholder)

<component names="sg13g2_inv_1,sg13g2_inv_2" DefaultModel="{names}">

Result: Each variant gets a unique Model key: sg13g2_inv_1, sg13g2_inv_2

How Mechanisms Work:

  • {names} resolution creates unique s_modules entries
  • Save/load works directly via unique Model key
  • _xml_device_name is a safety net (no-op in normal use)

When to Use:

  • Most common pattern for new multi-variant components
  • Simplicity and automatic uniqueness

Pattern 2: Custom Model Naming (Using Placeholder)

<component names="sg13g2_inv_1,sg13g2_inv_2" DefaultModel="INV_{names}_custom">

Result: Each variant gets a unique Model with custom naming: INV_sg13g2_inv_1_custom, INV_sg13g2_inv_2_custom

How Mechanisms Work:

  • {names} resolution creates unique s_modules entries with custom prefix/suffix
  • Save/load works directly via unique Model key
  • _xml_device_name is a safety net

When to Use:

  • When you want full control over Model naming scheme
  • When display names and model names should differ

Pattern 3: Shared Model (Hardcoded)

<component names="nmoscl_2,nmoscl_4" DefaultModel="nmoscl_2">

Result: Both variants share the same Model key: nmoscl_2

How Mechanisms Work:

  • Only first variant registers in s_modules
  • _xml_device_name is essential - the only way to distinguish variants on load
  • Both variants appear in component picker (registration happens before s_modules check)

When to Use:

  • When variants intentionally share the same underlying model
  • Special cases in existing PDK symbols (e.g., nmoscl_2.xml, sdfrbp.xml)

Migration & Backward Compatibility

Existing Single-Name XML Files

Impact: No changes required, behavior identical to pre-commit.

Why:

  • {names} resolves to the single name (harmless)
  • _xml_device_name always equals a_name (no-op)
  • No functional changes

Existing Multi-Name XML Files

Impact: Most already work, some improvements.

Case A - Hardcoded DefaultModel (Pattern 3):

  • Already works via _xml_device_name
  • No changes needed

Case B - Placeholder Without Resolution:

  • Now works correctly with {names} resolution
  • Save/load round-trips fixed

Case C - Parameter Defaults with Placeholder:

  • Now resolves to actual variant name instead of literal string
  • Fixes parameter initialization issues

Old Schematics

Behavior: Files saved before these changes may not have _xml_device_name.

Fallback: On load, variant will be the first registered variant (same as pre-commit behavior). Acceptable for backward compatibility.

No Breaking Changes: All existing files and schematics continue to work.

Abdur Rahman added 3 commits March 11, 2026 15:02
Persist variant identity of multi-name XML components (e.g. sdfrbp with
sg13g2_sdfrbp_1 and sg13g2_sdfrbp_2) through save/load cycles using a
hidden _xml_device_name property with name-based serialization.

- Append hidden _xml_device_name property with empty Description in
  XmlComponent constructor for robust name=value serialization
- Add recreate() override to detect variant mismatch on load and
  restore correct variant identity from the hidden property
- Add rebuildParameters() to reconstruct conditional parameter list
  for the restored variant while preserving user-edited values
- Clear geometry lists in createSymbol() to prevent doubled ports
  and graphical elements when called again via recreate()
- Trim variant names in module_xml.cpp to strip leading whitespace
  from comma-separated names attribute

Signed-off-by: Abdur Rahman <rahman@ihp-microelectronics.com>
Replace {names} with the actual variant name (a_name) when building
property lists in both the constructor and rebuildParameters(), so that
parameters using default_value="{names}" (e.g. sdfrbp.xml) get the
correct variant-specific value instead of the literal placeholder.

Signed-off-by: Abdur Rahman <rahman@ihp-microelectronics.com>
… component registration

Replace {names} with the actual variant name when constructing XML
components so each variant gets a unique Model and its own entry in
s_modules. This fixes save/load round-trips where all multi-name XML
components were resolving to the first registered variant.

Signed-off-by: Abdur Rahman <rahman@ihp-microelectronics.com>
@ra3xdh ra3xdh added the IHP label Mar 18, 2026
@ra3xdh ra3xdh merged commit 85ace4e into ra3xdh:dev/xml_devices Apr 7, 2026
@ra3xdh
Copy link
Copy Markdown
Owner

ra3xdh commented Apr 7, 2026

Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants