Skip to content

Add support for hierarchical module instantiation syntax#12

Open
robtaylor wants to merge 1 commit into
allow-analog-in-conditionalsfrom
module-instantiation-support
Open

Add support for hierarchical module instantiation syntax#12
robtaylor wants to merge 1 commit into
allow-analog-in-conditionalsfrom
module-instantiation-support

Conversation

@robtaylor

Copy link
Copy Markdown
Owner

Summary

This PR adds parsing and HIR support for Verilog-A hierarchical module instantiation syntax:

module_name #(.param(value)) instance_name (port1, port2);

This syntax is used in some foundry PDK models (e.g., GlobalFoundries GF130 ESD models) to instantiate primitive modules like resistors and capacitors with parameter overrides.

Example from GF130 ESD model:

resistor #(.r(rwire)) r1 (d, de0);
resistor #(.r(rdummy)) r4 (de0, de1);

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)
  • Add unit tests for item_tree and def_map
  • Add integration test with sample VA file

Limitations

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. This allows models using module instantiation to compile (the instances are ignored during code generation).

Test plan

  • New unit tests for item_tree and def_map pass
  • Existing tests continue to pass
  • GF130 ESD models that previously failed now compile successfully

🤖 Generated with Claude Code

@robtaylor
robtaylor force-pushed the allow-analog-in-conditionals branch 2 times, most recently from be1ef89 to cdb6796 Compare December 18, 2025 14:32
@robtaylor
robtaylor force-pushed the module-instantiation-support branch from ca84621 to 6bdf113 Compare December 18, 2025 14:33
@robtaylor
robtaylor force-pushed the allow-analog-in-conditionals branch 6 times, most recently from 882ca3a to 449993c Compare December 18, 2025 18:23
@robtaylor
robtaylor force-pushed the module-instantiation-support branch 2 times, most recently from c9f9ee3 to 3828184 Compare December 18, 2025 18:41
@robtaylor
robtaylor force-pushed the allow-analog-in-conditionals branch from 449993c to 1f90eea Compare December 23, 2025 00:26
@robtaylor
robtaylor force-pushed the module-instantiation-support branch from 3828184 to 0188873 Compare December 23, 2025 00:28
@robtaylor
robtaylor force-pushed the allow-analog-in-conditionals branch 2 times, most recently from ac1a82d to e3617c8 Compare December 24, 2025 01:33
@robtaylor
robtaylor force-pushed the allow-analog-in-conditionals branch from 83ce287 to eedcee9 Compare January 9, 2026 01:57
@robtaylor
robtaylor force-pushed the module-instantiation-support branch from 0188873 to ab10655 Compare January 9, 2026 02:11
@robtaylor
robtaylor force-pushed the allow-analog-in-conditionals branch from eedcee9 to f8505dd Compare January 9, 2026 02:30
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>
@robtaylor
robtaylor force-pushed the module-instantiation-support branch from ab10655 to e48013c Compare January 9, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant