printer::fits() now measures from a multi-line Doc::Inline's last line and
keeps measuring the rest of the group (a with {...} block no longer hides
an overflow). skip_action_stmt tracks begin/end, fork/join, case/endcase
nesting so a concurrent assertion's action block is captured whole.
Comments between bind/target/module and around randomize(...) with are
attached and reprinted instead of being refused by the safety net.
All 800 passing corpus files format byte-identically before and after.
Co-Authored-By: Claude Fable 5 <[email protected]>
320 lines
7.7 KiB
Plaintext
320 lines
7.7 KiB
Plaintext
# a bind directive is a module instantiation with a target scope in front
|
|
module m;
|
|
bind target_mod checker u_chk(.a(x),.b(y));
|
|
endmodule
|
|
----
|
|
module m;
|
|
bind target_mod checker 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 checker u_chk(.*);
|
|
endmodule
|
|
----
|
|
module m;
|
|
bind top.u_dut.u_core checker 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 checker u_chk(.*);
|
|
end
|
|
endgenerate
|
|
endmodule
|
|
----
|
|
module m;
|
|
generate
|
|
if (Enable) begin : g_chk
|
|
bind sub checker u_chk (.*);
|
|
end
|
|
endgenerate
|
|
endmodule
|
|
====
|
|
# comments attached to a bind directive are kept
|
|
module m;
|
|
// bind the checker in
|
|
bind dut checker 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 checker 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 checker u_chk (
|
|
.clk_i,
|
|
`ifdef FPV
|
|
.fpv_only_i,
|
|
`endif
|
|
.rst_ni
|
|
);
|
|
endmodule
|
|
----
|
|
module m;
|
|
bind dut checker 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 checker u_chk ( .clk_i ,.rst_ni );
|
|
// verilog_format: on
|
|
bind dut2 checker u_chk2 ( .clk_i ,.rst_ni );
|
|
endmodule
|
|
----
|
|
module m;
|
|
// verilog_format: off
|
|
bind dut checker u_chk ( .clk_i ,.rst_ni );
|
|
// verilog_format: on
|
|
bind dut2 checker 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
|
|
====
|