Skip to content

Emit decoupling metadata for tscircuit/checks - #2953

Open
0hmX wants to merge 8 commits into
mainfrom
emdash/green-peaches-buy-lhpe2
Open

Emit decoupling metadata for tscircuit/checks#2953
0hmX wants to merge 8 commits into
mainfrom
emdash/green-peaches-buy-lhpe2

Conversation

@0hmX

@0hmX 0hmX commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

This is a cross-package implementation of the chip-power-pin decoupling check:

  • @tscircuit/core determines each chip pin's decoupling requirement while rendering JSX and serializes that intent into Circuit JSON.
  • @tscircuit/checks reads the serialized metadata, evaluates circuit connectivity, and emits the warning.

This keeps component semantics in core and DRC warning ownership in checks.

End-to-end workflow

  1. Core copies explicit JSX pinAttributes onto the generated source_port.
  2. Core resolves should_have_decoupling_capacitor using this precedence:
    • An explicit shouldHaveDecouplingCapacitor value wins.
    • providesPower: true resolves to false because a power-source output should not require a local decoupling capacitor.
    • An explicit requiresPower value resolves to the same boolean.
    • Otherwise, a conventional chip power label such as VCC or VDD resolves to true.
    • Unrelated pins remain unset so existing underspecified-pin diagnostics continue to work.
  3. The result is present in Circuit JSON on the source port, for example:
{
  "type": "source_port",
  "should_have_decoupling_capacitor": true,
  "recommended_decoupling_capacitor_capacitance": "100nF"
}
  1. Checks builds a canonical source connectivity map and indexes source components, source ports, capacitors, and ground ports/nets.
  2. For each connected simple_chip port that requires decoupling, checks looks for a two-pin simple_capacitor with:
    • one terminal connected to the chip's power rail; and
    • the other terminal connected to a ground port or ground net.
  3. If that capacitor exists, no warning is produced. Otherwise checks emits a source_pin_missing_trace_warning, including the recommended capacitance in the message when supplied.
  4. The check is exported and registered in runAllNetlistChecks.

False-positive behavior

  • shouldHaveDecouplingCapacitor: false is preserved in Circuit JSON and suppresses the warning.
  • Pins with providesPower: true are serialized with the requirement set to false.
  • Fully unconnected power pins are skipped here because the existing missing-connection check owns that diagnostic.
  • Checks performs no VCC/VDD/GND label inference; it consumes domain metadata from Circuit JSON.
  • For older Circuit JSON without the new field, checks falls back to requires_power === true && provides_power !== true.

Cross-repository PRs

Both changes are required for the complete JSX → Circuit JSON → connectivity check → warning workflow.

Validation

  • Core focused metadata and pin-specification regression tests
  • Checks focused decoupling test and full test suite (133 tests)
  • TypeScript typechecks in both repositories
  • Checks build and formatting validation

@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview Jul 31, 2026 5:54pm

Request Review

@0hmX 0hmX changed the title Implement automatic decoupling capacitor placement Warn when chip power pins lack decoupling capacitors Jul 31, 2026
@0hmX
0hmX marked this pull request as ready for review July 31, 2026 15:52

@seveibar seveibar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should throw the warning in tscircuit/checks!

you may need to use tscircuit/core to add METADATA to the circuit json such that the warning can be thrown!

@0hmX 0hmX changed the title Warn when chip power pins lack decoupling capacitors Verify decoupling metadata for tscircuit/checks Jul 31, 2026
@0hmX 0hmX changed the title Verify decoupling metadata for tscircuit/checks Emit decoupling metadata for tscircuit/checks Jul 31, 2026
) {
sourcePortAttributes.should_have_decoupling_capacitor = true
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this stuff to capacitor

sourcePortAttributes,
sourcePortLabels: port_hints,
parentNormalComponentName: parentNormalComponent?.config.componentName,
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it be moved to capacitor?

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants