#896 d_cosim with a vlnggen (Verilator) model drops one output change of a counter
A registered 8-bit counter built with vlnggen and run in d_cosim loses one output change: the first carry into q[4] (at 322 ns) never reaches the output, so the counter reads 15 → 0. The bit is driven again from its next change on (15 → 32 at 642 ns, then +1 per clock up to 2 µs). With 1 or 2 inputs instead of 3, the lost change is the first carry into q[2] or q[3]. The same netlist with simulation="ivlng" and Icarus Verilog counts correctly, and so does a plain verilator --binary run of the RTL.
module c8b(input clk, input rst_n, input en, output reg [7:0] q);
always @(posedge clk) if (!rst_n) q <= 0; else if (en) q <= q + 1;
endmodule
* ngspice vlnggen c8b.v ; ngspice -b t.cir
Vclk clk 0 pulse(0 1.5 0 10p 10p 10n 20n)
Vrst rst 0 pulse(0 1.5 20n 10p 10p 1 2)
Ven en 0 1.5
a1 [clk rst en] [q7 q6 q5 q4 q3 q2 q1 q0] dut
.model dut d_cosim simulation="./c8b.so"
Rq7 q7 0 1k
Rq6 q6 0 1k
Rq5 q5 0 1k
Rq4 q4 0 1k
Rq3 q3 0 1k
Rq2 q2 0 1k
Rq1 q1 0 1k
Rq0 q0 0 1k
.control
pre_set auto_bridge_d_in = ( ".model auto_adc adc_bridge(in_low=0.75 in_high=0.75)" "auto_bridge%d [ %s ] [ %s ] auto_adc" )
pre_set auto_bridge_d_out = ( ".model auto_dac dac_bridge(out_low=0 out_high=1.5)" "auto_bridge%d [ %s ] [ %s ] auto_dac" )
tran 100p 400n
wrdata bits.txt v(q7) v(q6) v(q5) v(q4) v(q3) v(q2) v(q1) v(q0)
.endc
.end
Observed: 00001111 at 302 ns, 00000000 at 322 ns. Expected: 00010000 at 322 ns, which ivlng gives with the same netlist.
Versions: ngspice-47, Verilator 5.054 and 5.052, IIC-OSIC-TOOLS nightly of 2026-11-20 and 2026.10.
Also seen: with only .sv sources, vlnggen writes the library as .so (the fallback name verilated is never used), and ngspice vlnggen --timescale 1ns/1ps ... fails because ngspice parses --timescale itself (ngspice -- vlnggen ... works).
"Also seen: with only .sv sources, vlnggen writes the library as .so ...": a known bug, fixed in development. "ngspice vlnggen --timescale 1ns/1ps ... fails ...": documented behaviour.
For the rest, it is not established that there is a problem in Ngspice, and standard elements of a bug report are missing.