Files
lucioandClaude Fable 5 81df63d942 Bind semantics, the spaced macro call and the directive inside a connection, and lucisv.instantiate
TODO section 26; closes docs/topo.md 2.9-15 and 2.9-19; coverage_gaps
M4/M5/M6 corrected against a fresh opentitan census.
A bind directive's target is a path of segments with optional indices
(bind top.gen[0].u_core chk u_chk (...)); a lone target binds as a
module reference, an instance path records nothing rather than a guess.
Each connection's port half resolves against the module being bound in
and its expression half in the target module's scope first, the
workspace's member path when the target lives elsewhere, the writing
scope last (Target::BindScope, resolve::in_bind_target - the
inline-constraint shape). FACTS_FORMAT 14 -> 15: binds now post
references and an instantiation edge.
Expression-position spaced macro calls (assign x = `WIDTH (a + b);)
keep the author's gap, read from the source as glued_null_item reads
its gap; verify.rs untouched, both pins stand. A conditional directive
inside a connection value becomes ExprKind::Verbatim, byte-exact
through raw_inline as Doc::Inline, with the closing paren's line and
the list's break read from the source - so the instantiation keeps its
edge, lens and port references instead of collapsing to opaque bytes
(opentitan: the two padring sites in chip_earlgrey_{asic,cw340}.sv,
+2 edges, everything else byte-identical to 0.31.0).
lucisv.instantiate [uri, position, module] renders the inline ghost's
plan as plain text through workspace/applyEdit for clients without
inline completion; the Neovim README documents it.
QA: 3186 tests / 47 binaries, corpus 814/820, independent binary diff
over corpus and 2 645 opentitan files: only the two named files differ.

docs/features/bind-semantics/README.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-09-02 13:15:21 -07:00

347 lines
8.3 KiB
Plaintext

# a bind directive is a module instantiation with a target scope in front
module m;
bind target_mod chk_mod u_chk(.a(x),.b(y));
endmodule
----
module m;
bind target_mod chk_mod u_chk (.a(x), .b(y));
endmodule
====
# implicit named connections, target on its own line
# corpus/ibex/vendor/lowrisc_ip/ip/prim/fpv/tb/prim_secded_22_16_bind_fpv.sv:9
module prim_secded_22_16_bind_fpv;
bind prim_secded_22_16_tb
prim_secded_22_16_assert_fpv prim_secded_22_16_assert_fpv (
.clk_i,
.rst_ni,
.data_i,
.data_o,
.encoded_o,
.syndrome_o,
.err_o,
.error_inject_i
);
endmodule : prim_secded_22_16_bind_fpv
----
module prim_secded_22_16_bind_fpv;
bind prim_secded_22_16_tb prim_secded_22_16_assert_fpv prim_secded_22_16_assert_fpv (
.clk_i,
.rst_ni,
.data_i,
.data_o,
.encoded_o,
.syndrome_o,
.err_o,
.error_inject_i
);
endmodule : prim_secded_22_16_bind_fpv
====
# parameter overrides: the head does not fit, so the `#(` group breaks first
# -- the same choice the identically wide standalone instantiation makes
# corpus/ibex/vendor/lowrisc_ip/ip/prim/fpv/tb/prim_esc_rxtx_bind_fpv.sv:8
module m;
bind prim_esc_rxtx_tb
prim_esc_rxtx_assert_fpv #(.TimeoutCntDw(6))
prim_esc_rxtx_assert_fpv (
.clk_i ,
.rst_ni ,
.esc_req_o
);
endmodule
----
module m;
bind prim_esc_rxtx_tb prim_esc_rxtx_assert_fpv #(
.TimeoutCntDw(6)
) prim_esc_rxtx_assert_fpv (.clk_i, .rst_ni, .esc_req_o);
endmodule
====
# the target may be an instance name rather than a module name
# corpus/ibex/vendor/lowrisc_ip/ip/prim/fpv/tb/prim_fifo_sync_bind_fpv.sv:17
module m;
bind i_nopass1 prim_fifo_sync_assert_fpv #(
.Width(Width),
.Pass(1'b0)
) i_nopass1_assert_fpv (
.clk_i,
.rst_ni
);
endmodule
----
module m;
bind i_nopass1 prim_fifo_sync_assert_fpv #(
.Width(Width),
.Pass(1'b0)
) i_nopass1_assert_fpv (.clk_i, .rst_ni);
endmodule
====
# a `.*` connection list
# corpus/ibex/dv/uvm/core_ibex/fcov/core_ibex_fcov_bind.sv:6
module core_ibex_fcov_bind;
bind ibex_core core_ibex_fcov_if u_fcov_bind (
.*
);
endmodule
----
module core_ibex_fcov_bind;
bind ibex_core core_ibex_fcov_if u_fcov_bind (.*);
endmodule
====
# `#(` glued to the module name gets its space back
# corpus/ibex/dv/uvm/icache/dv/fcov/ibex_icache_fcov_bind.sv:8
module ibex_icache_fcov_bind;
bind ibex_icache ibex_icache_fcov_if#(
.NUM_FB(NUM_FB)
) u_ibex_icache_fcov_if (.*);
endmodule
----
module ibex_icache_fcov_bind;
bind ibex_icache ibex_icache_fcov_if #(.NUM_FB(NUM_FB)) u_ibex_icache_fcov_if (.*);
endmodule
====
# implicit named *parameter* overrides, and an aligned connection list
# corpus/ibex/dv/verilator/simple_system_cosim/ibex_simple_system_cosim_checker_bind.sv:6
module ibex_simple_system_cosim_checker_bind;
bind ibex_simple_system ibex_simple_system_cosim_checker#(
.SecureIbex,
.ICache,
.PMPEnable,
.PMPGranularity,
.PMPNumRegions,
.MHPMCounterNum
) u_ibex_simple_system_cosim_checker_bind (
.clk_i (IO_CLK),
.rst_ni (IO_RST_N),
.host_dmem_req (host_req[CoreD]),
.host_dmem_err (host_err[CoreD])
);
endmodule
----
module ibex_simple_system_cosim_checker_bind;
bind ibex_simple_system ibex_simple_system_cosim_checker #(
.SecureIbex,
.ICache,
.PMPEnable,
.PMPGranularity,
.PMPNumRegions,
.MHPMCounterNum
) u_ibex_simple_system_cosim_checker_bind (
.clk_i (IO_CLK),
.rst_ni (IO_RST_N),
.host_dmem_req (host_req[CoreD]),
.host_dmem_err (host_err[CoreD])
);
endmodule
====
# two bind directives at module scope, blank line between them kept
# corpus/opentitan/hw/ip/uart/dv/sva/uart_bind.sv:7
module uart_bind;
bind uart tlul_assert #(
.EndpointType("Device")
) tlul_assert_device (
.clk_i,
.rst_ni,
.h2d (tl_i),
.d2h (tl_o)
);
bind uart uart_csr_assert_fpv uart_csr_assert (
.clk_i,
.rst_ni,
.h2d (tl_i),
.d2h (tl_o)
);
endmodule
----
module uart_bind;
bind uart tlul_assert #(
.EndpointType("Device")
) tlul_assert_device (.clk_i, .rst_ni, .h2d(tl_i), .d2h(tl_o));
bind uart uart_csr_assert_fpv uart_csr_assert (.clk_i, .rst_ni, .h2d(tl_i), .d2h(tl_o));
endmodule
====
# the `target : instance_list` form (IEEE 1800 §23.11)
module m;
bind fifo_v3 : i_fifo_a , i_fifo_b fifo_props u_props (.clk_i, .rst_ni);
endmodule
----
module m;
bind fifo_v3 : i_fifo_a, i_fifo_b fifo_props u_props (.clk_i, .rst_ni);
endmodule
====
# a hierarchical target path
module m;
bind top.u_dut.u_core chk_mod u_chk(.*);
endmodule
----
module m;
bind top.u_dut.u_core chk_mod u_chk (.*);
endmodule
====
# a bind directive at top level, outside any module
bind cpu cpu_assert u_cpu_assert (.clk_i, .rst_ni);
----
bind cpu cpu_assert u_cpu_assert (.clk_i, .rst_ni);
====
# inside a generate region
module m;
generate
if (Enable) begin : g_chk
bind sub chk_mod u_chk(.*);
end
endgenerate
endmodule
----
module m;
generate
if (Enable) begin : g_chk
bind sub chk_mod u_chk (.*);
end
endgenerate
endmodule
====
# comments attached to a bind directive are kept
module m;
// bind the checker in
bind dut chk_mod u_chk (
// clock and reset come in implicitly
.clk_i,
.rst_ni // active low
); // and that is that
endmodule
----
module m;
// bind the checker in
bind dut chk_mod u_chk (
// clock and reset come in implicitly
.clk_i,
.rst_ni // active low
); // and that is that
endmodule
====
# an `ifdef inside the connection list of a bind
module m;
bind dut chk_mod u_chk (
.clk_i,
`ifdef FPV
.fpv_only_i,
`endif
.rst_ni
);
endmodule
----
module m;
bind dut chk_mod u_chk (
.clk_i,
`ifdef FPV
.fpv_only_i,
`endif
.rst_ni
);
endmodule
====
# a bind directive inside a `verilog_format: off` fence is untouched
module m;
// verilog_format: off
bind dut chk_mod u_chk ( .clk_i ,.rst_ni );
// verilog_format: on
bind dut2 chk_mod u_chk2 ( .clk_i ,.rst_ni );
endmodule
----
module m;
// verilog_format: off
bind dut chk_mod u_chk ( .clk_i ,.rst_ni );
// verilog_format: on
bind dut2 chk_mod u_chk2 (.clk_i, .rst_ni);
endmodule
====
# at the line-length boundary: exactly 100 columns stays on one line
module m;
bind target_module_name checker_module_name u_checker_instance_name25 (.clk_i, .rst_ni, .a, .bcd);
endmodule
----
module m;
bind target_module_name checker_module_name u_checker_instance_name25 (.clk_i, .rst_ni, .a, .bcd);
endmodule
====
# one column over the limit breaks the connection list
module m;
bind target_module_name checker_module_name u_checker_instance_name260 (.clk_i, .rst_ni, .a, .bcd);
endmodule
----
module m;
bind target_module_name checker_module_name u_checker_instance_name260 (
.clk_i,
.rst_ni,
.a,
.bcd
);
endmodule
====
# `bind` is not a reserved word here: `obj.bind()` keeps parsing
module m;
initial begin
obj.bind();
x = obj.bind;
end
endmodule
----
module m;
initial begin
obj.bind();
x = obj.bind;
end
endmodule
====
# comments written where the directive has no node to hang them on: between
# `bind` and the target, and between the target (or the instance list) and
# the module name
module m;
bind /*c1*/ dut /*c2*/ checker_mod c_inst (.clk(clk));
bind dut : u_a, u_b /*c3*/ checker_mod c2_inst (.clk(clk));
endmodule
----
module m;
bind /*c1*/ dut /*c2*/ checker_mod c_inst (.clk(clk));
bind dut : u_a, u_b /*c3*/ checker_mod c2_inst (.clk(clk));
endmodule
====
# a *line* comment after `bind` ends its line, so the target starts the next
module m;
bind // the target is the design under test
dut checker_mod c_inst (.clk(clk));
endmodule
----
module m;
bind // the target is the design under test
dut checker_mod c_inst (.clk(clk));
endmodule
====
====
# an indexed hierarchical target -- binding SVA into a generate array (coverage_gaps M6)
module tb;
bind top.gen[0].u_core chk c_inst (.clk(clk));
endmodule
----
module tb;
bind top.gen[0].u_core chk c_inst (.clk(clk));
endmodule
====
# a selector on the head alone, with an expression inside it
module tb;
bind arr[N-1] chk c (.*);
endmodule
----
module tb;
bind arr[N-1] chk c (.*);
endmodule
====
# an escaped segment keeps the whitespace that terminates it
module tb;
bind \my-inst .u_core chk c (.*);
endmodule
----
module tb;
bind \my-inst .u_core chk c (.*);
endmodule