Add bind directives

bind <target> [: inst, ...] <module> [#(...)] <inst> (...); reusing the instantiation AST and layout wholesale.

Coverage loop round 1, cluster 3: 671 -> 699 / 820 (81.8% -> 85.2%).
Feature README: docs/features/bind/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
lucioandClaude Fable 5 committed 2026-08-20 23:23:41 -07:00
1 parent 8007a71932
commit f7c66c79bf
9 files changed
+707 -38

No files matched your search

+22
View File
@@ -218,6 +218,8 @@ pub enum ItemKind {
Final(Stmt),
Instantiation(Instantiation),
GateInstantiation(GateInstantiation),
/// `bind <target> [: <instances>] <instantiation>` (IEEE 1800 §23.11).
Bind(BindDirective),
Genvar(Vec<Name>),
GenerateRegion {
items: Vec<Item>,
@@ -647,6 +649,26 @@ pub struct Connection {
pub span: TextRange,
}
/// A `bind` directive: everything after the target scope is an ordinary
/// module instantiation, so it is parsed and printed as one.
#[derive(Debug)]
pub struct BindDirective {
/// The bind target: a module or interface name (`prim_secded_22_16_tb`),
/// an instance name (`i_nopass1`) or a hierarchical path
/// (`top.u_dut.u_core`), stored with its `.` separators glued.
pub target: String,
/// Byte range of `target`. A hierarchical target is stored with its `.`
/// glued, so there the slice matches `target` only modulo the whitespace
/// the source may have written around the dots — the same caveat
/// [`Instantiation::module_span`] carries for `::`.
pub target_span: TextRange,
/// The `: u_a, u_b` instance list that narrows a module target to
/// particular instances. Empty when the source wrote no `:`.
pub instances: Vec<Name>,
/// The instantiation being bound, identical in shape to a standalone one.
pub inst: Instantiation,
}
#[derive(Debug)]
pub struct GateInstantiation {
/// `and`, `or`, `not`, ...