Add built-in primitive module support (resistor, capacitor, inductor)#14
Open
robtaylor wants to merge 6 commits into
Open
Add built-in primitive module support (resistor, capacitor, inductor)#14robtaylor wants to merge 6 commits into
robtaylor wants to merge 6 commits into
Conversation
robtaylor
force-pushed
the
builtin-primitive-support
branch
2 times, most recently
from
December 18, 2025 13:16
268b07e to
bcc7756
Compare
robtaylor
force-pushed
the
module-instantiation-support
branch
from
December 18, 2025 14:33
ca84621 to
6bdf113
Compare
robtaylor
force-pushed
the
builtin-primitive-support
branch
from
December 18, 2025 14:33
bcc7756 to
d5889ea
Compare
robtaylor
changed the base branch from
module-instantiation-support
to
allow-analog-in-conditionals
December 18, 2025 14:34
robtaylor
force-pushed
the
allow-analog-in-conditionals
branch
5 times, most recently
from
December 18, 2025 18:03
c7ae814 to
882ca3a
Compare
robtaylor
force-pushed
the
builtin-primitive-support
branch
2 times, most recently
from
December 18, 2025 18:11
00f9083 to
2a714c8
Compare
robtaylor
force-pushed
the
allow-analog-in-conditionals
branch
from
December 18, 2025 18:23
882ca3a to
449993c
Compare
robtaylor
force-pushed
the
builtin-primitive-support
branch
4 times, most recently
from
December 18, 2025 18:46
427fe7e to
2e32d2c
Compare
robtaylor
force-pushed
the
allow-analog-in-conditionals
branch
from
December 23, 2025 00:26
449993c to
1f90eea
Compare
robtaylor
force-pushed
the
builtin-primitive-support
branch
from
December 23, 2025 00:39
573ef7c to
f32f40c
Compare
robtaylor
force-pushed
the
allow-analog-in-conditionals
branch
2 times, most recently
from
December 24, 2025 01:33
ac1a82d to
e3617c8
Compare
robtaylor
force-pushed
the
allow-analog-in-conditionals
branch
2 times, most recently
from
January 9, 2026 02:30
eedcee9 to
f8505dd
Compare
This adds parsing and HIR support for Verilog-A module instantiation syntax: module_name #(.param(value)) instance_name (port1, port2); This syntax is used in some foundry PDK models (e.g., GF130 ESD models) to instantiate primitive modules like resistors and capacitors with parameter overrides. Changes: - Add ModuleInst grammar to veriloga.ungram with ParamAssignments and PortConnections - Implement parser grammar with lookahead to distinguish module instantiation from net declarations - Add ModuleInstItem HIR type to store instance name, module type, parameter assignments, and port connections - Add HIR lowering for module instances - Module instances are recorded but don't participate in name resolution (they will be processed during elaboration/flattening) Note: This is parsing support only. The actual instantiation/flattening of modules is not implemented - the instances are simply stored in the HIR for potential future use. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add a CLI flag to enable built-in primitive module support (resistor, capacitor, inductor). This feature is now disabled by default to maintain compatibility with models that may define their own modules with these names. Changes: - Add ALLOW_BUILTIN_PRIMITIVES constant and CLI argument in cli_def.rs - Add allow_builtin_primitives field to CompilationOpts - Add allow_builtin_primitives() salsa input to HirDefDB - Gate primitive lowering in body.rs on the flag - Update tests to set the flag where needed - Integration tests enable the flag for BUILTIN_PRIMITIVES test dir Usage: openvaf-r --allow-builtin-primitives model.va 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Apply nightly rustfmt formatting to satisfy CI requirements. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The BuiltInPrimitive enum was in builtin.rs which is auto-generated by sourcegen. Moving it to body/lower.rs where it's actually used prevents it from being removed during code generation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
robtaylor
force-pushed
the
builtin-primitive-support
branch
from
January 9, 2026 02:40
f32f40c to
eab1d71
Compare
- Update compile_and_load_with_opts to handle files with multiple modules - Add OSDI snapshots for BUILTIN_PRIMITIVES and MODULE_INST tests - Remove unused compile_and_load function 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add missing imports in body/lower.rs: Name, AssignOp, BinaryOp, AstNode, ItemTree, Module, ModuleInstItem, ModuleItem - Add AstPtr import in item_tree/lower.rs - Fix duplicate ConstExprValue import in item_tree.rs - Change ModuleInstItem.param_assignments to store AstPtr<ast::Expr> instead of Name to allow proper expression handling - Add builtin_primitives.va test file with resistor and capacitor primitives demonstrating the feature - Update OSDI snapshot to match test output 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
robtaylor
force-pushed
the
builtin-primitive-support
branch
from
January 9, 2026 23:10
eab1d71 to
c86d6ad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resistor,capacitor,inductor) that transform into equivalent contribution statements during HIR body loweringBuilt-in Primitive Transformations
resistor #(.r(R)) r1 (a, b)I(a,b) <+ V(a,b) / Rcapacitor #(.c(C)) c1 (a, b)I(a,b) <+ ddt(C * V(a,b))inductor #(.l(L)) l1 (a, b)V(a,b) <+ ddt(L * I(a,b))This enables PDK models (like GF130) that use built-in primitives to compile successfully without defining the primitive modules explicitly.
Changes
BuiltInPrimitiveenum inbuiltin.rsAstPtrinModuleInstItem(changed fromName)lower_primitive_instances()inbody/lower.rsto generate synthetic contribution statementsTest plan
primitive_modules.vatest verifies correct lowering output🤖 Generated with Claude Code