Menu

#843 verilator mixed signal compilation broken with ngspice 46

v1.0 (example)
open-fixed
nobody
None
5
2026-06-12
2026-06-11
Matt Venn
No

mixed signal with verilator has broken since version 44. I tried on 46 and got this error:

/foss/designs/shuttle-ttgf26a/gf-r2r-dac/sim > ngspice vlnggen ../verilog/rtl/*v
******
** ngspice-46 : Circuit level simulation program
** Compiled with KLU Direct Linear Solver
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Copyright 2001-2025, The ngspice team.
** Please get your ngspice manual from https://ngspice.sourceforge.io/docs.html
** Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
** Creation Date: Wed May 13 18:50:08 UTC 2026
******
%Error: Invalid option: --mdir... Suggested alternative: '-Mdir'
        ... See the manual at https://verilator.org/verilator_doc.html?v=5.048 for more assistance.
ngspice-46 done

I looked inside the verilator directory and grepped for mdir:

/foss/designs/shuttle-ttgf26a/gf-r2r-dac/sim/r2r_dac_control_obj_dir > grep 'Mdir' *
Vlng__verFiles.dat:C "--Mdir r2r_dac_control_obj_dir --prefix Vlng --CFLAGS -I/foss/tools/ngspice/share/ngspice/scripts/src --CFLAGS -fpic --cc --build --exe /foss/tools/ngspice/share/ngspice/scripts/src/verilator_main.cpp /foss/tools/ngspice/share/ngspice/scripts/src/verilator_shim.cpp ../verilog/rtl/r2r_dac_control.v ../verilog/rtl/sine.v"

So maybe this is an issue with verilator changing its options?
The verilator version is Verilator 5.048 2026-04-26 rev v5.048

Discussion

  • Giles Atkinson

    Giles Atkinson - 2026-06-11

    Tested today on Linux. Mac, Windows (fix for bug #775) and on every release since introduction in 42, at least on Linux. So not that simple. Please post a description of your environment, and files for reproduction. Any bug report should have those,

     
    👍
    1
  • Alan G

    Alan G - 2026-06-12

    Coincidentally, I think I ran into this exact issue today as well!

    It looks like the OP is using the popular IIC-OSIC-TOOLS docker container (https://github.com/iic-jku/IIC-OSIC-TOOLS). From the Docker build files, the container builds ngspice from source. The latest container (Release 2026.05) actually seems to get ngspice from the following place:

    Repo: https://github.com/danchitnis/ngspice-sf-mirror.git
    Tag: ngspice-46
    

    I downloaded the zip of the repo (https://github.com/danchitnis/ngspice-sf-mirror/releases/tag/ngspice-46) and built with the same arguments as IIC-OSIC-TOOLS:

    autogen.sh
    NGSPICE_COMPILE_OPTS=("--disable-debug" "--enable-openmp" "--with-x" "--with-readline=yes" "--enable-pss" "--enable-xspice" "--with-fftw3=yes" "--enable-osdi" "--enable-klu")
    ./configure "${NGSPICE_COMPILE_OPTS[@]}"
    make
    make install
    

    I did this locally on my machine (running Ubuntu 22.04.3 LTS) and was able to reproduce this behavior with the following minimal Verilog example.

    module myblock(clk, rst, in_a, out_b);
      input wire clk, rst, in_a;
      output reg out_b;
      always @(posedge clk or posedge rst) begin
        if (rst)
          out_b <= 0;
        else
          out_b <= in_a;
      end
    endmodule
    

    The following traceback was given after passing this module to vlnggen.

    ngspice vlnggen myblock.v
    ******
    ** ngspice-46 : Circuit level simulation program
    ** Compiled with KLU Direct Linear Solver
    ** The U. C. Berkeley CAD Group
    ** Copyright 1985-1994, Regents of the University of California.
    ** Copyright 2001-2025, The ngspice team.
    ** Please get your ngspice manual from https://ngspice.sourceforge.io/docs.html
    ** Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
    ** Creation Date: Fri Jun 12 01:41:08 UTC 2026
    ******
    %Error: Invalid option: --mdir... Suggested alternative: '-Mdir'
            ... See the manual at https://verilator.org/verilator_doc.html?v=5.049 for more assistance.
    ngspice-46 done
    

    Note that I also downloaded/built the source using the same args from Sourceforge (commit SHA: 65fb8e245bce1fac55eee28bec290df04cea1eaf) and the minimal Verilog example successfully produced a .so file.

    After some debugging (and Claude assistance), I think the biggest difference is within src/frontend/inpcom.c. I attached the full diff of this file between the two versions as a text file but the relevant portion I think has to do with the detection of a user command ("ng_script") file and some related capitalization semantics? The snippet below is present in the Sourceforge version but not the Github mirror.

    if (first) {
        if (ciprefix("*ng_script", buffer))
            comfile = TRUE;
        first = FALSE;
    }
    

    Not 100% sure what the best path forward is to fix the Docker environment/Github mirror (or why the IIC-OSIC-TOOLS Docker container does not pull ngspice directly from Sourceforge) but thought it'd be good to share here since this was quite a little rabbit hole.

     
  • Matt Venn

    Matt Venn - 2026-06-12

    Sorry for not posting all the environment details. Yes Alan is correct, it's the OSIC tools docker with release 2026.05. I've let the maintainers know here: https://github.com/iic-jku/IIC-OSIC-TOOLS/issues/287

     
  • Giles Atkinson

    Giles Atkinson - 2026-06-12
    • status: open --> open-fixed
     
  • Giles Atkinson

    Giles Atkinson - 2026-06-12

    A little digging shows that the bug was introduced on February 23rd 2026 and fixed on March 28, before the release of 46, but merged later. (e42a9e6b5c) So it is in 46, and I probably made the mistake of testing my own branch, as a proxy for the release.

    While the provenance of the source used to fill that container is unknown, there seems no reason to believe it is not a faithful copy of 46. So this is our bug, not theirs. Fortunately, 47 is pending.

    Thanks for the reports.

     

Log in to post a comment.

Auth0 Logo